Skip to content

Commit d6b10be

Browse files
committed
Make "type aliases cannot be used for traits" a note instead of a span_label.
1 parent 93fd214 commit d6b10be

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

src/librustc_resolve/lib.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -1822,22 +1822,7 @@ impl<'a> Resolver<'a> {
18221822

18231823
// If it's a typedef, give a note
18241824
if let Def::TyAlias(..) = path_res.base_def {
1825-
let trait_name = trait_path.segments.last().unwrap().identifier.name;
1826-
err.span_label(trait_path.span, &format!("`{}` is not a trait", trait_name));
1827-
1828-
let definition_site = {
1829-
let segments = &trait_path.segments;
1830-
if trait_path.global {
1831-
self.resolve_crate_relative_path(trait_path.span, segments, TypeNS)
1832-
} else {
1833-
self.resolve_module_relative_path(trait_path.span, segments, TypeNS)
1834-
}.map(|binding| binding.span).unwrap_or(syntax_pos::DUMMY_SP)
1835-
};
1836-
1837-
if definition_site != syntax_pos::DUMMY_SP {
1838-
err.span_label(definition_site,
1839-
&format!("type aliases cannot be used for traits"));
1840-
}
1825+
err.note(&format!("type aliases cannot be used for traits"));
18411826
}
18421827
err.emit();
18431828
Err(true)

src/test/compile-fail/issue-3907.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
// aux-build:issue_3907.rs
1212
extern crate issue_3907;
1313

14-
type Foo = issue_3907::Foo; //~ NOTE: type aliases cannot be used for traits
14+
type Foo = issue_3907::Foo;
1515

1616
struct S {
1717
name: isize
1818
}
1919

2020
impl Foo for S { //~ ERROR: `Foo` is not a trait
21-
//~| `Foo` is not a trait
21+
//~| NOTE: type aliases cannot be used for traits
2222
fn bar() { }
2323
}
2424

src/test/compile-fail/issue-5035.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010

1111
trait I {}
1212
type K = I;
13-
//~^ NOTE: aliases cannot be used for traits
1413
impl K for isize {} //~ ERROR: `K` is not a trait
15-
//~| is not a trait
14+
//~| NOTE: aliases cannot be used for traits
1615

1716
use ImportError; //~ ERROR unresolved
1817
impl ImportError for () {} // check that this is not an additional error (c.f. #35142)

0 commit comments

Comments
 (0)