Skip to content

Commit f38e391

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35445 - pcn:update-E0017-to-new-format, r=arielb1
Update e0017 to new format Updated `span_err!` to use `struct_span_err!` and provide a `span_label` that describes the error in context. Updated the test to look for the `span_label`s that are provided now.
2 parents 3da08f3 + ec1ef79 commit f38e391

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
617617
if !allow {
618618
self.add(Qualif::NOT_CONST);
619619
if self.mode != Mode::Fn {
620-
span_err!(self.tcx.sess, self.span, E0017,
621-
"references in {}s may only refer \
622-
to immutable values", self.mode);
620+
struct_span_err!(self.tcx.sess, self.span, E0017,
621+
"references in {}s may only refer \
622+
to immutable values", self.mode)
623+
.span_label(self.span, &format!("{}s require immutable values",
624+
self.mode))
625+
.emit();
623626
}
624627
}
625628
} else {

src/test/compile-fail/E0017.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ static X: i32 = 1;
1212
const C: i32 = 2;
1313

1414
const CR: &'static mut i32 = &mut C; //~ ERROR E0017
15+
//~| NOTE constants require immutable values
1516
//~| ERROR E0017
17+
//~| NOTE constants require immutable values
1618
static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
19+
//~| NOTE statics require immutable values
1720
//~| ERROR E0017
21+
//~| NOTE statics require immutable values
1822
//~| ERROR E0388
1923
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
24+
//~| NOTE statics require immutable values
2025
//~| ERROR E0017
21-
26+
//~| NOTE statics require immutable values
2227
fn main() {}

0 commit comments

Comments
 (0)