Add test for assoc fn suggestion on enum variant
This commit is contained in:
parent
7c7bb7dc01
commit
06fc531c96
15
tests/ui/enum/assoc-fn-call-on-variant.rs
Normal file
15
tests/ui/enum/assoc-fn-call-on-variant.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#[derive(Default)]
|
||||||
|
enum E {
|
||||||
|
A {},
|
||||||
|
B {},
|
||||||
|
#[default]
|
||||||
|
C,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl E {
|
||||||
|
fn f() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
E::A::f(); //~ ERROR failed to resolve: `A` is a variant, not a module
|
||||||
|
}
|
14
tests/ui/enum/assoc-fn-call-on-variant.stderr
Normal file
14
tests/ui/enum/assoc-fn-call-on-variant.stderr
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
error[E0433]: failed to resolve: `A` is a variant, not a module
|
||||||
|
--> $DIR/assoc-fn-call-on-variant.rs:14:8
|
||||||
|
|
|
||||||
|
LL | E::A::f();
|
||||||
|
| ^ `A` is a variant, not a module
|
||||||
|
|
|
||||||
|
help: there is an enum variant `E::A`; try using the variant's enum
|
||||||
|
|
|
||||||
|
LL | E();
|
||||||
|
| ~
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0433`.
|
Loading…
Reference in New Issue
Block a user