summaryrefslogtreecommitdiffstats
path: root/tests/ui/generic-associated-types
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /tests/ui/generic-associated-types
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/generic-associated-types')
-rw-r--r--tests/ui/generic-associated-types/auxiliary/missing-item-sugg.rs5
-rw-r--r--tests/ui/generic-associated-types/equality-bound.stderr5
-rw-r--r--tests/ui/generic-associated-types/issue-76535.base.stderr3
-rw-r--r--tests/ui/generic-associated-types/issue-79422.base.stderr3
-rw-r--r--tests/ui/generic-associated-types/issue-79422.extended.stderr2
-rw-r--r--tests/ui/generic-associated-types/issue-88595.rs1
-rw-r--r--tests/ui/generic-associated-types/issue-88595.stderr34
-rw-r--r--tests/ui/generic-associated-types/missing-item-sugg.rs11
-rw-r--r--tests/ui/generic-associated-types/missing-item-sugg.stderr11
-rw-r--r--tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs3
-rw-r--r--tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr31
-rw-r--r--tests/ui/generic-associated-types/self-outlives-lint.rs2
12 files changed, 64 insertions, 47 deletions
diff --git a/tests/ui/generic-associated-types/auxiliary/missing-item-sugg.rs b/tests/ui/generic-associated-types/auxiliary/missing-item-sugg.rs
new file mode 100644
index 000000000..5b10aab4b
--- /dev/null
+++ b/tests/ui/generic-associated-types/auxiliary/missing-item-sugg.rs
@@ -0,0 +1,5 @@
+pub trait Foo {
+ type Gat<T>
+ where
+ T: std::fmt::Display;
+}
diff --git a/tests/ui/generic-associated-types/equality-bound.stderr b/tests/ui/generic-associated-types/equality-bound.stderr
index d78f7a7fb..b21ff30a2 100644
--- a/tests/ui/generic-associated-types/equality-bound.stderr
+++ b/tests/ui/generic-associated-types/equality-bound.stderr
@@ -36,7 +36,10 @@ error[E0433]: failed to resolve: use of undeclared type `I`
--> $DIR/equality-bound.rs:9:41
|
LL | fn sum3<J: Iterator>(i: J) -> i32 where I::Item = i32 {
- | ^ use of undeclared type `I`
+ | ^
+ | |
+ | use of undeclared type `I`
+ | help: a type parameter with a similar name exists: `J`
error: aborting due to 4 previous errors
diff --git a/tests/ui/generic-associated-types/issue-76535.base.stderr b/tests/ui/generic-associated-types/issue-76535.base.stderr
index 52c6e3eec..370329b9f 100644
--- a/tests/ui/generic-associated-types/issue-76535.base.stderr
+++ b/tests/ui/generic-associated-types/issue-76535.base.stderr
@@ -43,8 +43,7 @@ LL | pub trait SuperTrait {
LL | type SubType<'a>: SubTrait where Self: 'a;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
= help: consider moving `SubType` to another trait
- = note: required for `Box<SuperStruct>` to implement `CoerceUnsized<Box<dyn SuperTrait<SubType = SubStruct<'_>>>>`
- = note: required by cast to type `Box<dyn SuperTrait<SubType = SubStruct<'_>>>`
+ = note: required for the cast from `Box<SuperStruct>` to `Box<dyn SuperTrait<SubType = SubStruct<'_>>>`
error: aborting due to 3 previous errors
diff --git a/tests/ui/generic-associated-types/issue-79422.base.stderr b/tests/ui/generic-associated-types/issue-79422.base.stderr
index f1de77bc3..ad704f5e9 100644
--- a/tests/ui/generic-associated-types/issue-79422.base.stderr
+++ b/tests/ui/generic-associated-types/issue-79422.base.stderr
@@ -43,8 +43,7 @@ LL | trait MapLike<K, V> {
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= help: consider moving `VRefCont` to another trait
- = note: required for `Box<BTreeMap<u8, u8>>` to implement `CoerceUnsized<Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>>`
- = note: required by cast to type `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>`
+ = note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>`
error: aborting due to 3 previous errors
diff --git a/tests/ui/generic-associated-types/issue-79422.extended.stderr b/tests/ui/generic-associated-types/issue-79422.extended.stderr
index 04184fce9..14492266c 100644
--- a/tests/ui/generic-associated-types/issue-79422.extended.stderr
+++ b/tests/ui/generic-associated-types/issue-79422.extended.stderr
@@ -27,7 +27,7 @@ LL | type VRefCont<'a> = &'a V where Self: 'a;
| ^^^^^
= note: expected trait object `(dyn RefCont<'_, u8> + 'static)`
found reference `&u8`
- = note: required for the cast from `BTreeMap<u8, u8>` to the object type `dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>`
+ = note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>`
error: aborting due to 2 previous errors
diff --git a/tests/ui/generic-associated-types/issue-88595.rs b/tests/ui/generic-associated-types/issue-88595.rs
index 5a40a6129..7de906e7e 100644
--- a/tests/ui/generic-associated-types/issue-88595.rs
+++ b/tests/ui/generic-associated-types/issue-88595.rs
@@ -19,4 +19,5 @@ impl<'a> A<'a> for C {
type B<'b> = impl Clone;
fn a(&'a self) -> Self::B<'a> {} //~ ERROR: non-defining opaque type use in defining scope
+ //~^ ERROR: mismatched types
}
diff --git a/tests/ui/generic-associated-types/issue-88595.stderr b/tests/ui/generic-associated-types/issue-88595.stderr
index 79d3479af..d6caed854 100644
--- a/tests/ui/generic-associated-types/issue-88595.stderr
+++ b/tests/ui/generic-associated-types/issue-88595.stderr
@@ -1,16 +1,34 @@
error: non-defining opaque type use in defining scope
- --> $DIR/issue-88595.rs:21:35
+ --> $DIR/issue-88595.rs:21:5
|
LL | fn a(&'a self) -> Self::B<'a> {}
- | ^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ generic argument `'a` used twice
|
-note: lifetime used multiple times
- --> $DIR/issue-88595.rs:18:6
+note: for this opaque type
+ --> $DIR/issue-88595.rs:19:18
|
-LL | impl<'a> A<'a> for C {
- | ^^
LL | type B<'b> = impl Clone;
- | ^^
+ | ^^^^^^^^^^
-error: aborting due to previous error
+error[E0308]: mismatched types
+ --> $DIR/issue-88595.rs:21:23
+ |
+LL | type B<'b> = impl Clone;
+ | ---------- the expected opaque type
+LL |
+LL | fn a(&'a self) -> Self::B<'a> {}
+ | - ^^^^^^^^^^^ expected opaque type, found `()`
+ | |
+ | implicitly returns `()` as its body has no tail or `return` expression
+ |
+ = note: expected opaque type `<C as A<'a>>::B<'a>`
+ found unit type `()`
+note: this item must have the opaque type in its signature in order to be able to register hidden types
+ --> $DIR/issue-88595.rs:21:5
+ |
+LL | fn a(&'a self) -> Self::B<'a> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/generic-associated-types/missing-item-sugg.rs b/tests/ui/generic-associated-types/missing-item-sugg.rs
new file mode 100644
index 000000000..35d573d81
--- /dev/null
+++ b/tests/ui/generic-associated-types/missing-item-sugg.rs
@@ -0,0 +1,11 @@
+// aux-build:missing-item-sugg.rs
+
+extern crate missing_item_sugg;
+
+struct Local;
+impl missing_item_sugg::Foo for Local {
+ //~^ ERROR not all trait items implemented, missing: `Gat`
+}
+//~^ HELP implement the missing item: `type Gat<T> = /* Type */ where T: std::fmt::Display;`
+
+fn main() {}
diff --git a/tests/ui/generic-associated-types/missing-item-sugg.stderr b/tests/ui/generic-associated-types/missing-item-sugg.stderr
new file mode 100644
index 000000000..378115f6d
--- /dev/null
+++ b/tests/ui/generic-associated-types/missing-item-sugg.stderr
@@ -0,0 +1,11 @@
+error[E0046]: not all trait items implemented, missing: `Gat`
+ --> $DIR/missing-item-sugg.rs:6:1
+ |
+LL | impl missing_item_sugg::Foo for Local {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Gat` in implementation
+ |
+ = help: implement the missing item: `type Gat<T> = /* Type */ where T: std::fmt::Display;`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs
index ecabf8943..b7b93ef1c 100644
--- a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs
+++ b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs
@@ -5,9 +5,6 @@ trait X {
const _: () = {
fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
//~^ ERROR: expected one of `>`, a const expression, lifetime, or type, found `:`
- //~| ERROR: expected parameter name, found `>`
- //~| ERROR: expected one of `!`, `)`, `+`, `,`, or `::`, found `>`
- //~| ERROR: constant provided when a type was expected
};
const _: () = {
diff --git a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr
index 10ceccedc..bfddb6dc6 100644
--- a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr
+++ b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr
@@ -3,41 +3,14 @@ error: expected one of `>`, a const expression, lifetime, or type, found `:`
|
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
| ^ expected one of `>`, a const expression, lifetime, or type
- |
-help: expressions must be enclosed in braces to be used as const generic arguments
- |
-LL | fn f1<'a>(arg : Box<{ dyn X< : 32 } >>) {}
- | + +
-
-error: expected parameter name, found `>`
- --> $DIR/trait-path-missing-gen_arg.rs:6:36
- |
-LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
- | ^ expected parameter name
-
-error: expected one of `!`, `)`, `+`, `,`, or `::`, found `>`
- --> $DIR/trait-path-missing-gen_arg.rs:6:36
- |
-LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
- | ^
- | |
- | expected one of `!`, `)`, `+`, `,`, or `::`
- | help: missing `,`
error: expected one of `>`, a const expression, lifetime, or type, found `=`
- --> $DIR/trait-path-missing-gen_arg.rs:14:30
+ --> $DIR/trait-path-missing-gen_arg.rs:11:30
|
LL | fn f1<'a>(arg : Box<dyn X< = 32 >>) {}
| - ^ expected one of `>`, a const expression, lifetime, or type
| |
| maybe try to close unmatched angle bracket
-error[E0747]: constant provided when a type was expected
- --> $DIR/trait-path-missing-gen_arg.rs:6:23
- |
-LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
- | ^^^^^^^^^^^
-
-error: aborting due to 5 previous errors
+error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0747`.
diff --git a/tests/ui/generic-associated-types/self-outlives-lint.rs b/tests/ui/generic-associated-types/self-outlives-lint.rs
index 673891fc3..0ea81b5ae 100644
--- a/tests/ui/generic-associated-types/self-outlives-lint.rs
+++ b/tests/ui/generic-associated-types/self-outlives-lint.rs
@@ -189,7 +189,7 @@ trait MultipleMethods {
}
// We would normally require `Self: 'a`, but we can prove that `Self: 'static`
-// because of the the bounds on the trait, so the bound is proven
+// because of the bounds on the trait, so the bound is proven
trait Trait: 'static {
type Assoc<'a>;
fn make_assoc(_: &u32) -> Self::Assoc<'_>;