// 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)
// 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() { }
}
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)