Auto merge of #32005 - vegai:31686, r=Manishearth
Fix note for type alias in trait position Fixes #31686
This commit is contained in:
commit
7b0b80ae21
3 changed files with 7 additions and 4 deletions
|
@ -1988,9 +1988,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
path_depth)));
|
path_depth)));
|
||||||
|
|
||||||
// If it's a typedef, give a note
|
// If it's a typedef, give a note
|
||||||
if let Def::TyAlias(..) = path_res.base_def {
|
if let Def::TyAlias(did) = path_res.base_def {
|
||||||
err.span_note(trait_path.span,
|
err.fileline_note(trait_path.span,
|
||||||
"`type` aliases cannot be used for traits");
|
"`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.emit();
|
||||||
Err(())
|
Err(())
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// aux-build:issue_3907.rs
|
// aux-build:issue_3907.rs
|
||||||
extern crate issue_3907;
|
extern crate issue_3907;
|
||||||
|
|
||||||
type Foo = issue_3907::Foo;
|
type Foo = issue_3907::Foo; //~ NOTE: type defined here
|
||||||
|
|
||||||
struct S {
|
struct S {
|
||||||
name: isize
|
name: isize
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
trait I {}
|
trait I {}
|
||||||
type K = I;
|
type K = I; //~ NOTE: type defined here
|
||||||
impl K for isize {} //~ ERROR: `K` is not a trait
|
impl K for isize {} //~ ERROR: `K` is not a trait
|
||||||
//~^ NOTE: `type` aliases cannot be used for traits
|
//~^ NOTE: `type` aliases cannot be used for traits
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue