Skip to content

Commit

Permalink
Rollup merge of rust-lang#116548 - nnethercote:assert-long-condition,…
Browse files Browse the repository at this point in the history
… r=matthewjasper

Improve handling of assertion failures with very long conditions

It's not perfectly clear what the best behaviour is here, but I think this is an improvement.

r? `@matthewjasper`
cc `@m-ou-se`
  • Loading branch information
matthiaskrgr committed Oct 9, 2023
2 parents 16836ee + a6abc50 commit d2d9302
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn expand_assert<'cx>(
DUMMY_SP,
Symbol::intern(&format!(
"assertion failed: {}",
pprust::expr_to_string(&cond_expr).escape_debug()
pprust::expr_to_string(&cond_expr)
)),
)],
);
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/macros/assert-long-condition.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// run-fail
// check-run-results
// ignore-emscripten no processes
// ignore-tidy-linelength

fn main() {
assert!(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0);
}
4 changes: 4 additions & 0 deletions tests/ui/macros/assert-long-condition.run.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
thread 'main' panicked at $DIR/assert-long-condition.rs:7:5:
assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18
+ 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

0 comments on commit d2d9302

Please sign in to comment.