diff options
| author | bors <bors@rust-lang.org> | 2016-03-02 22:15:51 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-03-02 22:15:51 +0000 |
| commit | 7b0b80ae21a195a5dba91d557f94a96136c27eaf (patch) | |
| tree | 399dfca7a65a3ce7a65b597edf94814b19bc3a4c | |
| parent | b9e61c9f403e89415a3787fae90fef5aad8ee477 (diff) | |
| parent | 01a6e8653b070f07604b784919575a4fc132bb2d (diff) | |
| download | rust-7b0b80ae21a195a5dba91d557f94a96136c27eaf.tar.gz rust-7b0b80ae21a195a5dba91d557f94a96136c27eaf.zip | |
Auto merge of #32005 - vegai:31686, r=Manishearth
Fix note for type alias in trait position Fixes #31686
| -rw-r--r-- | src/librustc_resolve/lib.rs | 7 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-3907.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-5035.rs | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 067d83a17e5..e139ac8b2a0 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1988,9 +1988,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { path_depth))); // If it's a typedef, give a note - if let Def::TyAlias(..) = path_res.base_def { - err.span_note(trait_path.span, + if let Def::TyAlias(did) = path_res.base_def { + err.fileline_note(trait_path.span, "`type` aliases cannot be used for traits"); + if let Some(sp) = self.ast_map.span_if_local(did) { + err.span_note(sp, "type defined here"); + } } err.emit(); Err(()) diff --git a/src/test/compile-fail/issue-3907.rs b/src/test/compile-fail/issue-3907.rs index a3d90a00d03..1dbf211b269 100644 --- a/src/test/compile-fail/issue-3907.rs +++ b/src/test/compile-fail/issue-3907.rs @@ -11,7 +11,7 @@ // aux-build:issue_3907.rs extern crate issue_3907; -type Foo = issue_3907::Foo; +type Foo = issue_3907::Foo; //~ NOTE: type defined here struct S { name: isize diff --git a/src/test/compile-fail/issue-5035.rs b/src/test/compile-fail/issue-5035.rs index cdf9d3bd36e..dabeb503841 100644 --- a/src/test/compile-fail/issue-5035.rs +++ b/src/test/compile-fail/issue-5035.rs @@ -9,7 +9,7 @@ // except according to those terms. trait I {} -type K = I; +type K = I; //~ NOTE: type defined here impl K for isize {} //~ ERROR: `K` is not a trait //~^ NOTE: `type` aliases cannot be used for traits fn main() {} |
