From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/qualified/qualified-path-params-2.rs | 21 +++++++++++++++++++ tests/ui/qualified/qualified-path-params-2.stderr | 14 +++++++++++++ tests/ui/qualified/qualified-path-params.rs | 25 +++++++++++++++++++++++ tests/ui/qualified/qualified-path-params.stderr | 18 ++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 tests/ui/qualified/qualified-path-params-2.rs create mode 100644 tests/ui/qualified/qualified-path-params-2.stderr create mode 100644 tests/ui/qualified/qualified-path-params.rs create mode 100644 tests/ui/qualified/qualified-path-params.stderr (limited to 'tests/ui/qualified') 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() {} +} + +type A = ::A::f; +//~^ 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 = ::A::f; + | ^^^^^^^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `f` implemented for `::A`, you could use the fully-qualified path + | +LL | type A = <::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() {} +} + +fn main() { + match 10 { + ::A::f:: => {} + //~^ ERROR expected unit struct, unit variant or constant, found associated function + 0 ..= ::A::f:: => {} + //~^ 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 `<::A>::f` + --> $DIR/qualified-path-params.rs:20:9 + | +LL | ::A::f:: => {} + | ^^^^^^^^^^^^^^^^^^^^^ 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 ..= ::A::f:: => {} + | - ^^^^^^^^^^^^^^^^^^^^^ this is of type `fn() {S::f::}` 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`. -- cgit v1.2.3