]> git.lizzy.rs Git - rust.git/commitdiff
Make "type aliases cannot be used for traits" a note instead of a span_label.
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Sun, 31 Jul 2016 21:29:01 +0000 (21:29 +0000)
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Sun, 31 Jul 2016 21:29:01 +0000 (21:29 +0000)
src/librustc_resolve/lib.rs
src/test/compile-fail/issue-3907.rs
src/test/compile-fail/issue-5035.rs

index 33e5282188c2826f34e6381f32b2815a122b087a..c1511b29c9e0154f1649e8f49ac0cca04289c170 100644 (file)
@@ -1822,22 +1822,7 @@ fn resolve_trait_reference(&mut self,
 
             // If it's a typedef, give a note
             if let Def::TyAlias(..) = path_res.base_def {
-                let trait_name = trait_path.segments.last().unwrap().identifier.name;
-                err.span_label(trait_path.span, &format!("`{}` is not a trait", trait_name));
-
-                let definition_site = {
-                    let segments = &trait_path.segments;
-                    if trait_path.global {
-                        self.resolve_crate_relative_path(trait_path.span, segments, TypeNS)
-                    } else {
-                        self.resolve_module_relative_path(trait_path.span, segments, TypeNS)
-                    }.map(|binding| binding.span).unwrap_or(syntax_pos::DUMMY_SP)
-                };
-
-                if definition_site != syntax_pos::DUMMY_SP {
-                    err.span_label(definition_site,
-                                   &format!("type aliases cannot be used for traits"));
-                }
+                err.note(&format!("type aliases cannot be used for traits"));
             }
             err.emit();
             Err(true)
index c99ff1813e0d12b78cbefabba88b74551a4494b0..cbc09a028c2c6833cc24c22fa4d18caddbe16672 100644 (file)
 // aux-build:issue_3907.rs
 extern crate issue_3907;
 
-type Foo = issue_3907::Foo; //~ NOTE: type aliases cannot be used for traits
+type Foo = issue_3907::Foo;
 
 struct S {
     name: isize
 }
 
 impl Foo for S { //~ ERROR: `Foo` is not a trait
-    //~| `Foo` is not a trait
+                 //~| NOTE: type aliases cannot be used for traits
     fn bar() { }
 }
 
index 61080ef60964539a1d535db9f81a02e5efad4dd9..9648d64d1fb6ec0d086736c52d0baff31a9a8396 100644 (file)
@@ -10,9 +10,8 @@
 
 trait I {}
 type K = I;
-//~^ NOTE: aliases cannot be used for traits
 impl K for isize {} //~ ERROR: `K` is not a trait
-//~| is not a trait
+                    //~| NOTE: aliases cannot be used for traits
 
 use ImportError; //~ ERROR unresolved
 impl ImportError for () {} // check that this is not an additional error (c.f. #35142)