Skip to content

Commit 7b0b80a

Browse files
committed
Auto merge of #32005 - vegai:31686, r=Manishearth
Fix note for type alias in trait position Fixes #31686
2 parents b9e61c9 + 01a6e86 commit 7b0b80a

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/librustc_resolve/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1988,9 +1988,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
19881988
path_depth)));
19891989

19901990
// If it's a typedef, give a note
1991-
if let Def::TyAlias(..) = path_res.base_def {
1992-
err.span_note(trait_path.span,
1991+
if let Def::TyAlias(did) = path_res.base_def {
1992+
err.fileline_note(trait_path.span,
19931993
"`type` aliases cannot be used for traits");
1994+
if let Some(sp) = self.ast_map.span_if_local(did) {
1995+
err.span_note(sp, "type defined here");
1996+
}
19941997
}
19951998
err.emit();
19961999
Err(())

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

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

14-
type Foo = issue_3907::Foo;
14+
type Foo = issue_3907::Foo; //~ NOTE: type defined here
1515

1616
struct S {
1717
name: isize

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
trait I {}
12-
type K = I;
12+
type K = I; //~ NOTE: type defined here
1313
impl K for isize {} //~ ERROR: `K` is not a trait
1414
//~^ NOTE: `type` aliases cannot be used for traits
1515
fn main() {}

0 commit comments

Comments
 (0)