Skip to content

Commit 5fc58dc

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35722 - knight42:update-error-msg, r=jonathandturner
Updated E0394 & E0422 to new format Fixes rust-lang#35692 and rust-lang#35700, as part of rust-lang#35233. r? @jonathandturner
2 parents 75454f7 + 3caa451 commit 5fc58dc

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/librustc_mir/transform/qualify_consts.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,10 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
277277
} else {
278278
"cannot refer to statics by value, use a constant instead"
279279
};
280-
span_err!(self.tcx.sess, self.span, E0394, "{}", msg);
280+
struct_span_err!(self.tcx.sess, self.span, E0394, "{}", msg)
281+
.span_label(self.span, &format!("referring to another static by value"))
282+
.note(&format!("use the address-of operator or a constant instead"))
283+
.emit();
281284

282285
// Replace STATIC with NOT_CONST to avoid further errors.
283286
self.qualif = self.qualif - Qualif::STATIC;

src/librustc_resolve/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
316316
err
317317
}
318318
ResolutionError::DoesNotNameAStruct(name) => {
319-
struct_span_err!(resolver.session,
319+
let mut err = struct_span_err!(resolver.session,
320320
span,
321321
E0422,
322322
"`{}` does not name a structure",
323-
name)
323+
name);
324+
err.span_label(span, &format!("not a structure"));
325+
err
324326
}
325327
ResolutionError::StructVariantUsedAsFunction(path_name) => {
326328
struct_span_err!(resolver.session,

src/test/compile-fail/E0394.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
// except according to those terms.
1010

1111
static A: u32 = 0;
12-
static B: u32 = A; //~ ERROR E0394
12+
static B: u32 = A;
13+
//~^ ERROR E0394
14+
//~| NOTE referring to another static by value
15+
//~| NOTE use the address-of operator or a constant instead
1316

1417
fn main() {
1518
}

src/test/compile-fail/E0422.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@
99
// except according to those terms.
1010

1111
fn main () {
12-
let x = Foo { x: 1, y: 2 }; //~ ERROR E0422
12+
let x = Foo { x: 1, y: 2 };
13+
//~^ ERROR E0422
14+
//~| NOTE not a structure
1315
}

0 commit comments

Comments
 (0)