about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/type-alias-enum-variants/type-alias-enum-variants-priority.rs20
-rw-r--r--src/test/ui/type-alias-enum-variants/type-alias-enum-variants-priority.stderr6
2 files changed, 23 insertions, 3 deletions
diff --git a/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-priority.rs b/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-priority.rs
index 229046cc5cd..7f69590400b 100644
--- a/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-priority.rs
+++ b/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-priority.rs
@@ -1,3 +1,23 @@
+// Check that a projection `Self::V` in a trait implementation,
+// with an associated type named `V`, for an `enum` with a variant named `V`,
+// results in triggering the deny-by-default lint `ambiguous_associated_items`.
+// The lint suggests that qualified syntax should be used instead.
+// That is, the user would write `<Self as Tr>::V`.
+//
+// The rationale for this is that while `enum` variants do currently
+// not exist in the type namespace but solely in the value namespace,
+// RFC #2593 "Enum variant types", would add enum variants to the type namespace.
+// However, currently `enum` variants are resolved with high priority as
+// they are resolved as inherent associated items.
+// Should #2953 therefore be implemented, `Self::V` would suddenly switch
+// from referring to the associated type `V` instead of the variant `V`.
+// The lint exists to keep us forward compatible with #2593.
+//
+// As a closing note, provided that #2933 was implemented and
+// if `enum` variants were given lower priority than associated types,
+// it would be impossible to refer to the `enum` variant `V` whereas
+// the associated type could be referred to with qualified syntax as seen above.
+
 enum E {
     V
 }
diff --git a/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-priority.stderr b/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-priority.stderr
index df75cbc6b2b..05512ed2bca 100644
--- a/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-priority.stderr
+++ b/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-priority.stderr
@@ -1,5 +1,5 @@
 error: ambiguous associated item
-  --> $DIR/type-alias-enum-variants-priority.rs:12:15
+  --> $DIR/type-alias-enum-variants-priority.rs:32:15
    |
 LL |     fn f() -> Self::V { 0 }
    |               ^^^^^^^ help: use fully-qualified syntax: `<E as Trait>::V`
@@ -8,12 +8,12 @@ LL |     fn f() -> Self::V { 0 }
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #57644 <https://github.com/rust-lang/rust/issues/57644>
 note: `V` could refer to variant defined here
-  --> $DIR/type-alias-enum-variants-priority.rs:2:5
+  --> $DIR/type-alias-enum-variants-priority.rs:22:5
    |
 LL |     V
    |     ^
 note: `V` could also refer to associated type defined here
-  --> $DIR/type-alias-enum-variants-priority.rs:6:5
+  --> $DIR/type-alias-enum-variants-priority.rs:26:5
    |
 LL |     type V;
    |     ^^^^^^^