Rollup merge of #35858 - shyaamsundhar:patch-1, r=GuillaumeGomez

E0435, E0437 & E0438 New Error Format

Part of #35801 , #35802 and #35803
r? @GuillaumeGomez

Hi! Please review the changes.
This commit is contained in:
Jonathan Turner 2016-08-22 15:34:21 -07:00 committed by GitHub
commit 0c84ac124a
4 changed files with 15 additions and 6 deletions

View File

@ -251,20 +251,24 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
err
}
ResolutionError::TypeNotMemberOfTrait(type_, trait_) => {
struct_span_err!(resolver.session,
let mut err = struct_span_err!(resolver.session,
span,
E0437,
"type `{}` is not a member of trait `{}`",
type_,
trait_)
trait_);
err.span_label(span, &format!("not a member of trait `Foo`"));
err
}
ResolutionError::ConstNotMemberOfTrait(const_, trait_) => {
struct_span_err!(resolver.session,
let mut err = struct_span_err!(resolver.session,
span,
E0438,
"const `{}` is not a member of trait `{}`",
const_,
trait_)
trait_);
err.span_label(span, &format!("not a member of trait `Foo`"));
err
}
ResolutionError::VariableNotBoundInPattern(variable_name, from, to) => {
struct_span_err!(resolver.session,
@ -448,10 +452,12 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
closure form instead")
}
ResolutionError::AttemptToUseNonConstantValueInConstant => {
struct_span_err!(resolver.session,
let mut err = struct_span_err!(resolver.session,
span,
E0435,
"attempt to use a non-constant value in a constant")
"attempt to use a non-constant value in a constant");
err.span_label(span, &format!("non-constant used with constant"));
err
}
ResolutionError::BindingShadowsSomethingUnacceptable(what_binding, name, binding) => {
let shadows_what = PathResolution::new(binding.def().unwrap()).kind_name();

View File

@ -11,4 +11,5 @@
fn main () {
let foo = 42u32;
const FOO : u32 = foo; //~ ERROR E0435
//~| NOTE non-constant used with constant
}

View File

@ -12,6 +12,7 @@ trait Foo {}
impl Foo for i32 {
type Bar = bool; //~ ERROR E0437
//~| NOTE not a member of trait `Foo`
}
fn main () {

View File

@ -14,6 +14,7 @@ trait Foo {}
impl Foo for i32 {
const BAR: bool = true; //~ ERROR E0438
//~| NOTE not a member of trait `Foo`
}
fn main () {