mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-25 14:13:38 +00:00
Add note when trying to use Self
as a ctor
This commit is contained in:
parent
ce9ef37fe6
commit
38546ba9fa
@ -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");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user