Add note when trying to use Self as a ctor

This commit is contained in:
Esteban Küber 2018-01-01 21:21:11 -08:00
parent ce9ef37fe6
commit 38546ba9fa
2 changed files with 9 additions and 1 deletions

View File

@ -898,7 +898,7 @@ impl<'a> LexicalScopeBinding<'a> {
}
}
#[derive(Clone)]
#[derive(Clone, Debug)]
enum PathResult<'a> {
Module(Module<'a>),
NonModule(PathResolution),
@ -2742,6 +2742,10 @@ impl<'a> Resolver<'a> {
block));
return (err, candidates);
}
(Def::SelfTy(_, _), _) if ns == ValueNS && is_struct_like(def) => {
err.note("can't instantiate `Self`, you must use the implemented struct \
directly");
}
_ => {}
}
}

View File

@ -3,12 +3,16 @@ error[E0423]: expected function, found self type `Self`
|
16 | let s = Self(0, 1); //~ ERROR expected function
| ^^^^ not a function
|
= note: can't instantiate `Self`, you must use the implemented struct directly
error[E0532]: expected tuple struct/variant, found self type `Self`
--> $DIR/tuple-struct-alias.rs:18:13
|
18 | Self(..) => {} //~ ERROR expected tuple struct/variant
| ^^^^ not a tuple struct/variant
|
= note: can't instantiate `Self`, you must use the implemented struct directly
error[E0423]: expected function, found type alias `A`
--> $DIR/tuple-struct-alias.rs:24:13