Constify assert_eq! and assert_ne!#103639
Constify assert_eq! and assert_ne!#103639fee1-dead wants to merge 3 commits intorust-lang:masterfrom
assert_eq! and assert_ne!#103639Conversation
|
r? @thomcc (rustbot has picked a reviewer for you, use r? to override) |
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
This comment has been minimized.
This comment has been minimized.
7b4bc71 to
e0e35db
Compare
This comment has been minimized.
This comment has been minimized.
e0e35db to
3749356
Compare
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #103787) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Rerolling this. I think it's a good idea but I'm not sure if this is "api change" or "just let wg-const-eval do their thing" r? libs |
|
I am not sure this needs T-compiler review/signoff. In case, please re-add the team, thanks :) @rustbot label -T-compiler |
|
r? libs |
b48319c to
2353dcf
Compare
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #105323) made this pull request unmergeable. Please resolve the merge conflicts. |
library/core/src/macros/mod.rs
Outdated
There was a problem hiding this comment.
This means that at compile-time, assert_eq/ne will print the stringify'd form of the values, rather than Debug format them, right?
There was a problem hiding this comment.
Yes, because we can't format the actual values in compile time unless there is a way to make Display const.
There was a problem hiding this comment.
But this PR requires us to always support the stringify fallback, no? That is, we won't be able to add a ~const Display requirement to the arguments in the future, if this PR is merged.
We might still support printing via specialization though, if ~const Display is available. Maybe, to ensure we've not painted ourselves into a corner, the stringify fallback could also be enabled via specialization on non-const contexts?
There was a problem hiding this comment.
What do you mean? This isn't and shouldn't be insta-stable, which means we can change the implementation should future developments allow const display.
There was a problem hiding this comment.
Oh right sorry I've missed the #[rustc_const_unstable(feature = "const_assert_eq", issue = "none")] annotation. Should also answer the question of @Mark-Simulacrum .
|
Is this immediately accessible on stable? If not, is there a test validating that already? |
We provide an inferior type of formatting for use when panicking in compile time, which should not come with additional costs as the additional argument should be inlined and optimized away when in runtime
2353dcf to
89dac4c
Compare
|
@rustbot ready |
|
☔ The latest upstream changes (presumably #107267) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Preview work on #79100 showed that these macros are quite perf-sensitive, and adding a |
We provide an inferior type of formatting for use when panicking in compile time, which should not come with additional costs as the additional argument should be inlined and optimized away when in runtime.
As for additional code in
assert_failed: this is an implementation detail that is hard to find and not intended to be exposed anyways, so I don't think it will hurt readability much.