Skip to content

Commit bf1e3f3

Browse files
committed
Auto merge of rust-lang#115513 - Urgau:normalize-msg-after-translate, r=petrochenkov
Don't forget to normalize the translated message This PR adds a missing call to `normalize_whitespace` after translating an label. Fixes rust-lang#115498
2 parents ce798a5 + ec0975d commit bf1e3f3

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

compiler/rustc_errors/src/emitter.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,13 @@ impl FileWithAnnotatedLines {
23482348
}
23492349

23502350
let label = label.as_ref().map(|m| {
2351-
emitter.translate_message(m, args).map_err(Report::new).unwrap().to_string()
2351+
normalize_whitespace(
2352+
&emitter
2353+
.translate_message(m, &args)
2354+
.map_err(Report::new)
2355+
.unwrap()
2356+
.to_string(),
2357+
)
23522358
});
23532359

23542360
if lo.line != hi.line {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![crate_type = "lib"]
2+
3+
struct Bug([u8; panic!{"\t"}]);
4+
//~^ ERROR evaluation of constant value failed
5+
//~| NOTE: in this expansion of panic!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0080]: evaluation of constant value failed
2+
--> $DIR/const_panic-normalize-tabs-115498.rs:3:17
3+
|
4+
LL | struct Bug([u8; panic!{"\t"}]);
5+
| ^^^^^^^^^^^^ the evaluated program panicked at ' ', $DIR/const_panic-normalize-tabs-115498.rs:3:17
6+
|
7+
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)