summaryrefslogtreecommitdiffstats
path: root/tests/ui/qualified
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/qualified
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/qualified')
-rw-r--r--tests/ui/qualified/qualified-path-params-2.rs21
-rw-r--r--tests/ui/qualified/qualified-path-params-2.stderr14
-rw-r--r--tests/ui/qualified/qualified-path-params.rs25
-rw-r--r--tests/ui/qualified/qualified-path-params.stderr18
4 files changed, 78 insertions, 0 deletions
diff --git a/tests/ui/qualified/qualified-path-params-2.rs b/tests/ui/qualified/qualified-path-params-2.rs
new file mode 100644
index 000000000..d0cc1fa3d
--- /dev/null
+++ b/tests/ui/qualified/qualified-path-params-2.rs
@@ -0,0 +1,21 @@
+// Check that qualified paths with type parameters
+// fail during type checking and not during parsing
+
+struct S;
+
+trait Tr {
+ type A;
+}
+
+impl Tr for S {
+ type A = S;
+}
+
+impl S {
+ fn f<T>() {}
+}
+
+type A = <S as Tr>::A::f<u8>;
+//~^ ERROR ambiguous associated type
+
+fn main() {}
diff --git a/tests/ui/qualified/qualified-path-params-2.stderr b/tests/ui/qualified/qualified-path-params-2.stderr
new file mode 100644
index 000000000..b6cf19b82
--- /dev/null
+++ b/tests/ui/qualified/qualified-path-params-2.stderr
@@ -0,0 +1,14 @@
+error[E0223]: ambiguous associated type
+ --> $DIR/qualified-path-params-2.rs:18:10
+ |
+LL | type A = <S as Tr>::A::f<u8>;
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+help: if there were a trait named `Example` with associated type `f` implemented for `<S as Tr>::A`, you could use the fully-qualified path
+ |
+LL | type A = <<S as Tr>::A as Example>::f;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0223`.
diff --git a/tests/ui/qualified/qualified-path-params.rs b/tests/ui/qualified/qualified-path-params.rs
new file mode 100644
index 000000000..e8a95a460
--- /dev/null
+++ b/tests/ui/qualified/qualified-path-params.rs
@@ -0,0 +1,25 @@
+// Check that qualified paths with type parameters
+// fail during type checking and not during parsing
+
+struct S;
+
+trait Tr {
+ type A;
+}
+
+impl Tr for S {
+ type A = S;
+}
+
+impl S {
+ fn f<T>() {}
+}
+
+fn main() {
+ match 10 {
+ <S as Tr>::A::f::<u8> => {}
+ //~^ ERROR expected unit struct, unit variant or constant, found associated function
+ 0 ..= <S as Tr>::A::f::<u8> => {}
+ //~^ ERROR only `char` and numeric types are allowed in range
+ }
+}
diff --git a/tests/ui/qualified/qualified-path-params.stderr b/tests/ui/qualified/qualified-path-params.stderr
new file mode 100644
index 000000000..a49ed6c8f
--- /dev/null
+++ b/tests/ui/qualified/qualified-path-params.stderr
@@ -0,0 +1,18 @@
+error[E0533]: expected unit struct, unit variant or constant, found associated function `<<S as Tr>::A>::f<u8>`
+ --> $DIR/qualified-path-params.rs:20:9
+ |
+LL | <S as Tr>::A::f::<u8> => {}
+ | ^^^^^^^^^^^^^^^^^^^^^ not a unit struct, unit variant or constant
+
+error[E0029]: only `char` and numeric types are allowed in range patterns
+ --> $DIR/qualified-path-params.rs:22:15
+ |
+LL | 0 ..= <S as Tr>::A::f::<u8> => {}
+ | - ^^^^^^^^^^^^^^^^^^^^^ this is of type `fn() {S::f::<u8>}` but it should be `char` or numeric
+ | |
+ | this is of type `{integer}`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0029, E0533.
+For more information about an error, try `rustc --explain E0029`.