Skip to content

Commit 3caa451

Browse files
author
Knight
committed
Updated E0394 to new error message
1 parent d2e7895 commit 3caa451

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
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/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
}

0 commit comments

Comments
 (0)