Auto merge of #116548 - nnethercote:assert-long-condition, 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`
This commit is contained in:
bors 2023-10-10 08:02:20 +00:00
commit 091bb74e7e
3 changed files with 14 additions and 1 deletions

View File

@ -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)
)),
)],
);

View File

@ -0,0 +1,9 @@
// run-fail
// check-run-results
// exec-env:RUST_BACKTRACE=0
// 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);
}

View File

@ -0,0 +1,4 @@
thread 'main' panicked at $DIR/assert-long-condition.rs:8: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