1
Fork 0

E0516 Update error format #36108

- fixes #36108
- part of #35233
This commit is contained in:
Gavin Baker 2016-08-30 11:04:55 +10:00
parent 2dbf600d15
commit d53ea97bfc
3 changed files with 18 additions and 8 deletions

View file

@ -56,18 +56,21 @@ impl<'a> CheckAttrVisitor<'a> {
let mut conflicting_reprs = 0; let mut conflicting_reprs = 0;
for word in words { for word in words {
let name = match word.name() { let name = match word.name() {
Some(word) => word, Some(word) => word,
None => continue, None => continue,
}; };
let message = match &*name { let word: &str = &word.name();
let (message, label) = match word {
"C" => { "C" => {
conflicting_reprs += 1; conflicting_reprs += 1;
if target != Target::Struct && if target != Target::Struct &&
target != Target::Union && target != Target::Union &&
target != Target::Enum { target != Target::Enum {
"attribute should be applied to struct, enum or union" ("attribute should be applied to struct, enum or union",
"a struct, enum or union")
} else { } else {
continue continue
} }
@ -85,7 +88,8 @@ impl<'a> CheckAttrVisitor<'a> {
"simd" => { "simd" => {
conflicting_reprs += 1; conflicting_reprs += 1;
if target != Target::Struct { if target != Target::Struct {
"attribute should be applied to struct" ("attribute should be applied to struct",
"a struct")
} else { } else {
continue continue
} }
@ -95,15 +99,17 @@ impl<'a> CheckAttrVisitor<'a> {
"isize" | "usize" => { "isize" | "usize" => {
conflicting_reprs += 1; conflicting_reprs += 1;
if target != Target::Enum { if target != Target::Enum {
"attribute should be applied to enum" ("attribute should be applied to enum",
"an enum")
} else { } else {
continue continue
} }
} }
_ => continue, _ => continue,
}; };
struct_span_err!(self.sess, attr.span, E0517, "{}", message)
span_err!(self.sess, attr.span, E0517, "{}", message); .span_label(attr.span, &format!("requires {}", label))
.emit();
} }
if conflicting_reprs > 1 { if conflicting_reprs > 1 {
span_warn!(self.sess, attr.span, E0566, span_warn!(self.sess, attr.span, E0566,

View file

@ -1769,8 +1769,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
} }
} }
hir::TyTypeof(ref _e) => { hir::TyTypeof(ref _e) => {
span_err!(tcx.sess, ast_ty.span, E0516, struct_span_err!(tcx.sess, ast_ty.span, E0516,
"`typeof` is a reserved keyword but unimplemented"); "`typeof` is a reserved keyword but unimplemented")
.span_label(ast_ty.span, &format!("reserved keyword"))
.emit();
tcx.types.err tcx.types.err
} }
hir::TyInfer => { hir::TyInfer => {

View file

@ -10,4 +10,5 @@
fn main() { fn main() {
let x: typeof(92) = 92; //~ ERROR E0516 let x: typeof(92) = 92; //~ ERROR E0516
//~| reserved keyword
} }