Skip to content

Two improvements of the latest i128 numbers change - #2732

Merged
bors merged 2 commits into
rust-lang:masterfrom
est31:master
Mar 27, 2022
Merged

Two improvements of the latest i128 numbers change#2732
bors merged 2 commits into
rust-lang:masterfrom
est31:master

Conversation

@est31

@est31 est31 commented Mar 24, 2022

Copy link
Copy Markdown
Member

Two improvements of #2719:

  • First, a typo/grammar fix
  • Second, a fix to avoid usage of the anti pattern of == inside an assert macro. Since a few releases, assert is usable inside const expressions, but for the purpose of ==, superior alternatives exist that also work at compile time but print the two values at a mismatch. assert_eq is not yet usable in const contexts due to formatting.

est31 added 2 commits March 24, 2022 11:47
This macro bases on the static_assert_size macro from the rust compiler.
Its advantage is greater compatibility with older rust versions as well
as better error messages on a mismatch, as both numbers are printed.
The assert macro does not print the mismatching numbers as it only gets
the bool from the == comparison.
@rust-highfive

Copy link
Copy Markdown

r? @Amanieu

(rust-highfive has picked a reviewer for you, use r? to override)

@Amanieu

Amanieu commented Mar 24, 2022

Copy link
Copy Markdown
Member

cc @Gankra

@Gankra

Gankra commented Mar 25, 2022

Copy link
Copy Markdown
Contributor

TIL! neat!

@Amanieu

Amanieu commented Mar 26, 2022

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Mar 26, 2022

Copy link
Copy Markdown
Contributor

📌 Commit e1d9927 has been approved by Amanieu

@bors

bors commented Mar 26, 2022

Copy link
Copy Markdown
Contributor

⌛ Testing commit e1d9927 with merge 115c769...

bors added a commit that referenced this pull request Mar 26, 2022
Two improvements of the latest i128 numbers change

Two improvements of #2719:

* First, a typo/grammar fix
* Second, a fix to avoid usage of the anti pattern of `==` inside an `assert` macro. Since a few releases, `assert` is usable inside `const` expressions, but for the purpose of `==`, superior alternatives exist that also work at compile time but print the two values at a mismatch. `assert_eq` is not yet usable in const contexts due to formatting.
@bors

bors commented Mar 26, 2022

Copy link
Copy Markdown
Contributor

💔 Test failed - checks-cirrus-freebsd-13

@Gankra

Gankra commented Mar 27, 2022

Copy link
Copy Markdown
Contributor

looks like a CI error, retry seems appropriate

@Amanieu

Amanieu commented Mar 27, 2022

Copy link
Copy Markdown
Member

@bors retry

@bors

bors commented Mar 27, 2022

Copy link
Copy Markdown
Contributor

⌛ Testing commit e1d9927 with merge 9d1d40a...

@bors

bors commented Mar 27, 2022

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-actions, checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13
Approved by: Amanieu
Pushing 9d1d40a to master...

@bors
bors merged commit 9d1d40a into rust-lang:master Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants