From 738b91e9976a41c7b0ab8cbf544cd971202bfa98 Mon Sep 17 00:00:00 2001 From: Shyam Sundar B Date: Sun, 21 Aug 2016 18:43:58 +0530 Subject: [PATCH] Update lib.rs Update lib.rs Update lib.rs Update E0438.rs Update E0437.rs Update E0435.rs --- src/librustc_resolve/lib.rs | 18 ++++++++++++------ src/test/compile-fail/E0435.rs | 1 + src/test/compile-fail/E0437.rs | 1 + src/test/compile-fail/E0438.rs | 1 + 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index b91ede5b2fa8a..d9132dc5c82a7 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -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, @@ -438,10 +442,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(); diff --git a/src/test/compile-fail/E0435.rs b/src/test/compile-fail/E0435.rs index f6cba15a0bff8..f687633d34d86 100644 --- a/src/test/compile-fail/E0435.rs +++ b/src/test/compile-fail/E0435.rs @@ -11,4 +11,5 @@ fn main () { let foo = 42u32; const FOO : u32 = foo; //~ ERROR E0435 + //~| NOTE non-constant used with constant } diff --git a/src/test/compile-fail/E0437.rs b/src/test/compile-fail/E0437.rs index 7440a82773e7a..62ee8dc346492 100644 --- a/src/test/compile-fail/E0437.rs +++ b/src/test/compile-fail/E0437.rs @@ -12,6 +12,7 @@ trait Foo {} impl Foo for i32 { type Bar = bool; //~ ERROR E0437 + //~| NOTE not a member of trait `Foo` } fn main () { diff --git a/src/test/compile-fail/E0438.rs b/src/test/compile-fail/E0438.rs index b3d453072049e..f549d62aebfea 100644 --- a/src/test/compile-fail/E0438.rs +++ b/src/test/compile-fail/E0438.rs @@ -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 () {