Skip to content

Two improvements of the latest i128 numbers change #2732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2022
Merged

Conversation

est31
Copy link
Member

@est31 est31 commented Mar 24, 2022

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

r? @Amanieu

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

@Amanieu
Copy link
Member

Amanieu commented Mar 24, 2022

cc @Gankra

@Gankra
Copy link
Contributor

Gankra commented Mar 25, 2022

TIL! neat!

@Amanieu
Copy link
Member

Amanieu commented Mar 26, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Mar 26, 2022

📌 Commit e1d9927 has been approved by Amanieu

@bors
Copy link
Contributor

bors commented Mar 26, 2022

⌛ 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
Copy link
Contributor

bors commented Mar 26, 2022

💔 Test failed - checks-cirrus-freebsd-13

@Gankra
Copy link
Contributor

Gankra commented Mar 27, 2022

looks like a CI error, retry seems appropriate

@Amanieu
Copy link
Member

Amanieu commented Mar 27, 2022

@bors retry

@bors
Copy link
Contributor

bors commented Mar 27, 2022

⌛ Testing commit e1d9927 with merge 9d1d40a...

@bors
Copy link
Contributor

bors commented Mar 27, 2022

☀️ 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