Rollup merge of #35722 - knight42:update-error-msg, r=jonathandturner

Updated E0394 & E0422 to new format

Fixes #35692 and #35700, as part of #35233.

r? @jonathandturner
This commit is contained in:
Jonathan Turner 2016-08-17 06:25:27 -07:00 committed by GitHub
commit 5fc58dcaff
4 changed files with 15 additions and 5 deletions

View File

@ -277,7 +277,10 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
} else {
"cannot refer to statics by value, use a constant instead"
};
span_err!(self.tcx.sess, self.span, E0394, "{}", msg);
struct_span_err!(self.tcx.sess, self.span, E0394, "{}", msg)
.span_label(self.span, &format!("referring to another static by value"))
.note(&format!("use the address-of operator or a constant instead"))
.emit();
// Replace STATIC with NOT_CONST to avoid further errors.
self.qualif = self.qualif - Qualif::STATIC;

View File

@ -316,11 +316,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
err
}
ResolutionError::DoesNotNameAStruct(name) => {
struct_span_err!(resolver.session,
let mut err = struct_span_err!(resolver.session,
span,
E0422,
"`{}` does not name a structure",
name)
name);
err.span_label(span, &format!("not a structure"));
err
}
ResolutionError::StructVariantUsedAsFunction(path_name) => {
struct_span_err!(resolver.session,

View File

@ -9,7 +9,10 @@
// except according to those terms.
static A: u32 = 0;
static B: u32 = A; //~ ERROR E0394
static B: u32 = A;
//~^ ERROR E0394
//~| NOTE referring to another static by value
//~| NOTE use the address-of operator or a constant instead
fn main() {
}

View File

@ -9,5 +9,7 @@
// except according to those terms.
fn main () {
let x = Foo { x: 1, y: 2 }; //~ ERROR E0422
let x = Foo { x: 1, y: 2 };
//~^ ERROR E0422
//~| NOTE not a structure
}