summaryrefslogtreecommitdiffstats
path: root/src/test/ui/qualified
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/qualified')
-rw-r--r--src/test/ui/qualified/qualified-path-params-2.rs21
-rw-r--r--src/test/ui/qualified/qualified-path-params-2.stderr9
-rw-r--r--src/test/ui/qualified/qualified-path-params.rs25
-rw-r--r--src/test/ui/qualified/qualified-path-params.stderr18
4 files changed, 73 insertions, 0 deletions
diff --git a/src/test/ui/qualified/qualified-path-params-2.rs b/src/test/ui/qualified/qualified-path-params-2.rs
new file mode 100644
index 000000000..d0cc1fa3d
--- /dev/null
+++ b/src/test/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/src/test/ui/qualified/qualified-path-params-2.stderr b/src/test/ui/qualified/qualified-path-params-2.stderr
new file mode 100644
index 000000000..948f21fce
--- /dev/null
+++ b/src/test/ui/qualified/qualified-path-params-2.stderr
@@ -0,0 +1,9 @@
+error[E0223]: ambiguous associated type
+ --> $DIR/qualified-path-params-2.rs:18:10
+ |
+LL | type A = <S as Tr>::A::f<u8>;
+ | ^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<<S as Tr>::A as Trait>::f`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0223`.
diff --git a/src/test/ui/qualified/qualified-path-params.rs b/src/test/ui/qualified/qualified-path-params.rs
new file mode 100644
index 000000000..e8a95a460
--- /dev/null
+++ b/src/test/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/src/test/ui/qualified/qualified-path-params.stderr b/src/test/ui/qualified/qualified-path-params.stderr
new file mode 100644
index 000000000..82cc6e19f
--- /dev/null
+++ b/src/test/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> => {}
+ | ^^^^^^^^^^^^^^^^^^^^^
+
+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`.