Update E0560 to include label
This commit is contained in:
parent
af67f0b389
commit
23efc5453d
@ -3094,7 +3094,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
if let Some(field_name) = Self::suggest_field_name(variant,
|
||||
&field.name,
|
||||
skip_fields.collect()) {
|
||||
err.span_label(field.name.span,&format!("did you mean `{}`?",field_name));
|
||||
err.span_label(field.name.span,
|
||||
&format!("field does not exist - did you mean `{}`?", field_name));
|
||||
} else {
|
||||
match ty.sty {
|
||||
ty::TyAdt(adt, ..) if adt.is_enum() => {
|
||||
err.span_label(field.name.span, &format!("`{}::{}` does not have this field",
|
||||
ty, variant.name.as_str()));
|
||||
}
|
||||
_ => {
|
||||
err.span_label(field.name.span, &format!("`{}` does not have this field", ty));
|
||||
}
|
||||
}
|
||||
};
|
||||
err.emit();
|
||||
}
|
||||
|
@ -15,5 +15,5 @@ enum Field {
|
||||
fn main() {
|
||||
let s = Field::Fool { joke: 0 };
|
||||
//~^ ERROR E0559
|
||||
//~| NOTE did you mean `x`?
|
||||
//~| NOTE field does not exist - did you mean `x`?
|
||||
}
|
||||
|
@ -13,5 +13,7 @@ struct Simba {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s = Simba { mother: 1, father: 0 }; //~ ERROR E0560
|
||||
let s = Simba { mother: 1, father: 0 };
|
||||
//~^ ERROR E0560
|
||||
//~| NOTE `Simba` does not have this field
|
||||
}
|
||||
|
@ -15,4 +15,5 @@ enum Homura {
|
||||
fn main() {
|
||||
let homura = Homura::Akemi { kaname: () };
|
||||
//~^ ERROR variant `Homura::Akemi` has no field named `kaname`
|
||||
//~| NOTE field does not exist - did you mean `madoka`?
|
||||
}
|
||||
|
@ -13,8 +13,12 @@
|
||||
struct S(u8, u16);
|
||||
|
||||
fn main() {
|
||||
let s = S{0b1: 10, 0: 11}; //~ ERROR struct `S` has no field named `0b1`
|
||||
let s = S{0b1: 10, 0: 11};
|
||||
//~^ ERROR struct `S` has no field named `0b1`
|
||||
//~| NOTE field does not exist - did you mean `1`?
|
||||
match s {
|
||||
S{0: a, 0x1: b, ..} => {} //~ ERROR does not have a field named `0x1`
|
||||
S{0: a, 0x1: b, ..} => {}
|
||||
//~^ ERROR does not have a field named `0x1`
|
||||
//~| NOTE struct `S::{{constructor}}` does not have field `0x1`
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ fn main() {
|
||||
foo : 5,
|
||||
bar : 42,
|
||||
//~^ ERROR struct `A` has no field named `bar`
|
||||
//~| NOTE did you mean `barr`?
|
||||
//~| NOTE field does not exist - did you mean `barr`?
|
||||
car : 9,
|
||||
};
|
||||
}
|
||||
|
@ -19,6 +19,6 @@ fn main() {
|
||||
foo : 5,
|
||||
bar : 42,
|
||||
//~^ ERROR struct `A` has no field named `bar`
|
||||
//~| NOTE did you mean `car`?
|
||||
//~| NOTE field does not exist - did you mean `car`?
|
||||
};
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ struct BuildData {
|
||||
fn main() {
|
||||
let foo = BuildData {
|
||||
foo: 0,
|
||||
bar: 0 //~ ERROR struct `BuildData` has no field named `bar`
|
||||
bar: 0
|
||||
//~^ ERROR struct `BuildData` has no field named `bar`
|
||||
//~| NOTE `BuildData` does not have this field
|
||||
};
|
||||
}
|
||||
|
@ -24,18 +24,18 @@ fn main () {
|
||||
let k = B {
|
||||
aa: 20,
|
||||
//~^ ERROR struct `xc::B` has no field named `aa`
|
||||
//~| NOTE did you mean `a`?
|
||||
//~| NOTE field does not exist - did you mean `a`?
|
||||
bb: 20,
|
||||
//~^ ERROR struct `xc::B` has no field named `bb`
|
||||
//~| NOTE did you mean `a`?
|
||||
//~| NOTE field does not exist - did you mean `a`?
|
||||
};
|
||||
// local crate struct
|
||||
let l = A {
|
||||
aa: 20,
|
||||
//~^ ERROR struct `A` has no field named `aa`
|
||||
//~| NOTE did you mean `a`?
|
||||
//~| NOTE field does not exist - did you mean `a`?
|
||||
bb: 20,
|
||||
//~^ ERROR struct `A` has no field named `bb`
|
||||
//~| NOTE did you mean `b`?
|
||||
//~| NOTE field does not exist - did you mean `b`?
|
||||
};
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ fn main() {
|
||||
let u = U { a: 0, b: 1 }; //~ ERROR union expressions should have exactly one field
|
||||
let u = U { a: 0, b: 1, c: 2 }; //~ ERROR union expressions should have exactly one field
|
||||
//~^ ERROR union `U` has no field named `c`
|
||||
//~| NOTE `U` does not have this field
|
||||
let u = U { ..u }; //~ ERROR union expressions should have exactly one field
|
||||
//~^ ERROR functional record update syntax requires a struct
|
||||
|
||||
@ -29,6 +30,7 @@ fn main() {
|
||||
let U { a, b } = u; //~ ERROR union patterns should have exactly one field
|
||||
let U { a, b, c } = u; //~ ERROR union patterns should have exactly one field
|
||||
//~^ ERROR union `U` does not have a field named `c`
|
||||
//~| NOTE union `U` does not have field `c`
|
||||
let U { .. } = u; //~ ERROR union patterns should have exactly one field
|
||||
//~^ ERROR `..` cannot be used in union patterns
|
||||
let U { a, .. } = u; //~ ERROR `..` cannot be used in union patterns
|
||||
|
@ -21,7 +21,7 @@ impl U {
|
||||
fn main() {
|
||||
let u = U { principle: 0 };
|
||||
//~^ ERROR union `U` has no field named `principle`
|
||||
//~| NOTE did you mean `principal`?
|
||||
//~| NOTE field does not exist - did you mean `principal`?
|
||||
let w = u.principial; //~ ERROR attempted access of field `principial` on type `U`
|
||||
//~^ HELP did you mean `principal`?
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user