-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
assert_eq! message format (take 2) #111030
Conversation
resolve conflicts and stringify original tokens accept local changes
Apply comments from the rust-lang#94016 review by @yaahc
r? @m-ou-se (rustbot has picked a reviewer for you, use r? to override) |
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
These are in the UI test suite. You should be able to bless them with
I don't know what exactly is causing these, but you can safely ignore them. Also, the clippy CI failure looks legit, you need to figure out why this program is failing now: #![deny(clippy::missing_assert_message)]
fn main() {
assert_eq!(1, 2, "oops");
} |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@lukas-code thank you so much for such a quick feedback!!! Clippy Issue (CI failures)It seems the cc: @unexge @weihanglo @flip1995 CompilingSo the
|
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (1c0c8b84d3fd5510f913b517c1a537ab0ab005e0): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 656.548s -> 656.35s (-0.03%) |
@m-ou-se so it seems the new version is faster, but still slower than the primary branch. Any thoughts? |
The simpler #111071 showed no performance impact, and I think it should be merged first, as it solves 90% of the issue. This PR should be rebased on top of it and we will discuss if adding a slightly better assert context is worth an extra 1% of compiler performance. |
Closing this in favor of #111071 |
Modify panic message for `assert_eq!`, `assert_ne!`, the currently unstable `assert_matches!`, as well as the corresponding `debug_assert_*` macros. ```rust assert_eq!(1 + 1, 3); assert_eq!(1 + 1, 3, "my custom message value={}!", 42); ``` ```plain thread 'main' panicked at $DIR/main.rs:6:5: assertion failed: `(left == right)` left: `2`, right: `3` ``` ```plain thread 'main' panicked at $DIR/main.rs:6:5: assertion failed: `(left == right)` left: `2`, right: `3`: my custom message value=42! ``` ```plain thread 'main' panicked at $DIR/main.rs:6:5: assertion `left == right` failed left: 2 right: 3 ``` ```plain thread 'main' panicked at $DIR/main.rs:6:5: assertion `left == right` failed: my custom message value=42! left: 2 right: 3 ``` This PR is a simpler subset of the rust-lang#111030, but it does NOT stringify the original left and right source code assert expressions, thus should be faster to compile.
Cleaner assert_eq! & assert_ne! panic messages This PR finishes refactoring of the assert messages per rust-lang#94005. The panic message format change rust-lang#112849 used to be part of this PR, but has been factored out and just merged. It might be better to keep both changes in the same release once FCP vote completes. Modify panic message for `assert_eq!`, `assert_ne!`, the currently unstable `assert_matches!`, as well as the corresponding `debug_assert_*` macros. ```rust assert_eq!(1 + 1, 3); assert_eq!(1 + 1, 3, "my custom message value={}!", 42); ``` #### Old messages ```plain thread 'main' panicked at $DIR/main.rs:6:5: assertion failed: `(left == right)` left: `2`, right: `3` ``` ```plain thread 'main' panicked at $DIR/main.rs:6:5: assertion failed: `(left == right)` left: `2`, right: `3`: my custom message value=42! ``` #### New messages ```plain thread 'main' panicked at $DIR/main.rs:6:5: assertion `left == right` failed left: 2 right: 3 ``` ```plain thread 'main' panicked at $DIR/main.rs:6:5: assertion `left == right` failed: my custom message value=42! left: 2 right: 3 ``` History of fixing rust-lang#94005 * rust-lang#94016 was a lengthy PR that was abandoned * rust-lang#111030 was similar, but it stringified left and right arguments, and thus caused compile time performance issues, thus closed * rust-lang#112849 factored out the two-line formatting of all panic messages Fixes rust-lang#94005 r? `@m-ou-se`
This takes over the stale #94016 by @MakitaToki (thx for amazing work!), and addresses comments by @yaahc. The code was rebased on the primary branch, preserving the history/contributions.
Fixes #94005
Note that there is a simpler alternative #111071 which does not improve the
assertion failed
message, only the formatting of the entire output.