about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-11-03 17:15:22 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-11-03 17:15:22 +0000
commit06fc531c9631989ed681fc7252929da3ff84225e (patch)
treeeb10386661adfdd46089c73bf38e458663a583cc
parent7c7bb7dc017545db732f5cffec684bbaeae0a9a0 (diff)
downloadrust-06fc531c9631989ed681fc7252929da3ff84225e.tar.gz
rust-06fc531c9631989ed681fc7252929da3ff84225e.zip
Add test for assoc fn suggestion on enum variant
-rw-r--r--tests/ui/enum/assoc-fn-call-on-variant.rs15
-rw-r--r--tests/ui/enum/assoc-fn-call-on-variant.stderr14
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/enum/assoc-fn-call-on-variant.rs b/tests/ui/enum/assoc-fn-call-on-variant.rs
new file mode 100644
index 00000000000..7fa8eb2da41
--- /dev/null
+++ b/tests/ui/enum/assoc-fn-call-on-variant.rs
@@ -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
+}
diff --git a/tests/ui/enum/assoc-fn-call-on-variant.stderr b/tests/ui/enum/assoc-fn-call-on-variant.stderr
new file mode 100644
index 00000000000..4775201d2bb
--- /dev/null
+++ b/tests/ui/enum/assoc-fn-call-on-variant.stderr
@@ -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`.