]> git.lizzy.rs Git - rust.git/commitdiff
fix "X is not a member of trait Y" span labels
authorAlex Burka <durka42+github@gmail.com>
Mon, 12 Sep 2016 21:47:59 +0000 (17:47 -0400)
committerAlex Burka <durka42@gmail.com>
Tue, 13 Sep 2016 03:13:13 +0000 (03:13 +0000)
The span labels for associated types and consts were hardcoded to `Foo`
rather than substituting the name of the trait.

This also normalizes the wording for associated methods', traits', and
consts' span labels.

Fixes #36428.

src/librustc_resolve/lib.rs
src/test/compile-fail/E0407.rs
src/test/compile-fail/E0438.rs

index c5b505fba38e9669c76f2f1f60f89a50587a0e28..a11ef6e221dc23efe5f52e203ee621fae1c97587 100644 (file)
@@ -247,7 +247,7 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
                                            "method `{}` is not a member of trait `{}`",
                                            method,
                                            trait_);
-            err.span_label(span, &format!("not a member of `{}`", trait_));
+            err.span_label(span, &format!("not a member of trait `{}`", trait_));
             err
         }
         ResolutionError::TypeNotMemberOfTrait(type_, trait_) => {
@@ -257,7 +257,7 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
                              "type `{}` is not a member of trait `{}`",
                              type_,
                              trait_);
-            err.span_label(span, &format!("not a member of trait `Foo`"));
+            err.span_label(span, &format!("not a member of trait `{}`", trait_));
             err
         }
         ResolutionError::ConstNotMemberOfTrait(const_, trait_) => {
@@ -267,7 +267,7 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
                              "const `{}` is not a member of trait `{}`",
                              const_,
                              trait_);
-            err.span_label(span, &format!("not a member of trait `Foo`"));
+            err.span_label(span, &format!("not a member of trait `{}`", trait_));
             err
         }
         ResolutionError::VariableNotBoundInPattern(variable_name, from, to) => {
index 2a150b7451210a7a380c98b19a80c0a6857958ca..c207dbfca5565753f8f79b8a705af0e5b6e4a404 100644 (file)
@@ -18,7 +18,7 @@ impl Foo for Bar {
     fn a() {}
     fn b() {}
     //~^ ERROR E0407
-    //~| NOTE not a member of `Foo`
+    //~| NOTE not a member of trait `Foo`
 }
 
 fn main() {
index f549d62aebfea1a98d496bf065d23a74cb322e69..2e2df4bee5a35242caa2451d02dac642e9a9d436 100644 (file)
 
 #![feature(associated_consts)]
 
-trait Foo {}
+trait Bar {}
 
-impl Foo for i32 {
+impl Bar for i32 {
     const BAR: bool = true; //~ ERROR E0438
-        //~| NOTE not a member of trait `Foo`
+        //~| NOTE not a member of trait `Bar`
 }
 
 fn main () {