diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2025-06-18 22:10:53 +0200 |
|---|---|---|
| committer | León Orell Valerian Liehr <me@fmease.dev> | 2025-07-18 03:13:21 +0200 |
| commit | 1df99f22d3a1776b36fc00fc35626fd841f7242f (patch) | |
| tree | ee1b70a04b8964d3fa16f7bac12265e4f317026b /tests/ui | |
| parent | 9788f59bbf893965db98dc633e64e4405414b698 (diff) | |
| download | rust-1df99f22d3a1776b36fc00fc35626fd841f7242f.tar.gz rust-1df99f22d3a1776b36fc00fc35626fd841f7242f.zip | |
AST lowering: More robustly deal with relaxed bounds
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/associated-item/missing-associated_item_or_field_def_ids.rs | 5 | ||||
| -rw-r--r-- | tests/ui/associated-item/missing-associated_item_or_field_def_ids.stderr | 24 | ||||
| -rw-r--r-- | tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.rs | 5 | ||||
| -rw-r--r-- | tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.stderr | 27 | ||||
| -rw-r--r-- | tests/ui/feature-gates/feature-gate-more-maybe-bounds.stderr | 17 | ||||
| -rw-r--r-- | tests/ui/sized-hierarchy/default-supertrait.stderr | 4 | ||||
| -rw-r--r-- | tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/unsized/relaxed-bounds-invalid-places.rs (renamed from tests/ui/unsized/maybe-bounds-where.rs) | 3 | ||||
| -rw-r--r-- | tests/ui/unsized/relaxed-bounds-invalid-places.stderr (renamed from tests/ui/unsized/maybe-bounds-where.stderr) | 16 |
9 files changed, 43 insertions, 60 deletions
diff --git a/tests/ui/associated-item/missing-associated_item_or_field_def_ids.rs b/tests/ui/associated-item/missing-associated_item_or_field_def_ids.rs index b90bb9ea4dd..18c71e5c744 100644 --- a/tests/ui/associated-item/missing-associated_item_or_field_def_ids.rs +++ b/tests/ui/associated-item/missing-associated_item_or_field_def_ids.rs @@ -1,8 +1,7 @@ // Regression test for <https://github.com/rust-lang/rust/issues/137554>. fn main() -> dyn Iterator + ?Iterator::advance_by(usize) { - //~^ ERROR `?Trait` is not permitted in trait object types - //~| ERROR expected trait, found associated function `Iterator::advance_by` - //~| ERROR the value of the associated type `Item` in `Iterator` must be specified + //~^ ERROR expected trait, found associated function `Iterator::advance_by` + //~| ERROR `?Trait` is not permitted in trait object types todo!() } diff --git a/tests/ui/associated-item/missing-associated_item_or_field_def_ids.stderr b/tests/ui/associated-item/missing-associated_item_or_field_def_ids.stderr index 7f0fbc800ed..6ec8e01c78d 100644 --- a/tests/ui/associated-item/missing-associated_item_or_field_def_ids.stderr +++ b/tests/ui/associated-item/missing-associated_item_or_field_def_ids.stderr @@ -1,25 +1,19 @@ -error[E0658]: `?Trait` is not permitted in trait object types - --> $DIR/missing-associated_item_or_field_def_ids.rs:3:29 - | -LL | fn main() -> dyn Iterator + ?Iterator::advance_by(usize) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - error[E0404]: expected trait, found associated function `Iterator::advance_by` --> $DIR/missing-associated_item_or_field_def_ids.rs:3:30 | LL | fn main() -> dyn Iterator + ?Iterator::advance_by(usize) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a trait -error[E0191]: the value of the associated type `Item` in `Iterator` must be specified - --> $DIR/missing-associated_item_or_field_def_ids.rs:3:18 +error[E0658]: `?Trait` is not permitted in trait object types + --> $DIR/missing-associated_item_or_field_def_ids.rs:3:29 | LL | fn main() -> dyn Iterator + ?Iterator::advance_by(usize) { - | ^^^^^^^^ help: specify the associated type: `Iterator<Item = Type>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0191, E0404, E0658. -For more information about an error, try `rustc --explain E0191`. +Some errors have detailed explanations: E0404, E0658. +For more information about an error, try `rustc --explain E0404`. diff --git a/tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.rs b/tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.rs index f6b749a5100..9e0a86abb2e 100644 --- a/tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.rs +++ b/tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.rs @@ -6,7 +6,6 @@ trait Tr { fn main() { let _: dyn Tr + ?Foo<Assoc = ()>; - //~^ ERROR: `?Trait` is not permitted in trait object types - //~| ERROR: cannot find trait `Foo` in this scope - //~| ERROR: the value of the associated type `Item` in `Tr` must be specified + //~^ ERROR: cannot find trait `Foo` in this scope + //~| ERROR: `?Trait` is not permitted in trait object types } diff --git a/tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.stderr b/tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.stderr index f31a1de76a7..bd83c1a9ea8 100644 --- a/tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.stderr +++ b/tests/ui/associated-types/avoid-getting-associated-items-of-undefined-trait.stderr @@ -1,28 +1,19 @@ -error[E0658]: `?Trait` is not permitted in trait object types - --> $DIR/avoid-getting-associated-items-of-undefined-trait.rs:8:21 - | -LL | let _: dyn Tr + ?Foo<Assoc = ()>; - | ^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - error[E0405]: cannot find trait `Foo` in this scope --> $DIR/avoid-getting-associated-items-of-undefined-trait.rs:8:22 | LL | let _: dyn Tr + ?Foo<Assoc = ()>; | ^^^ not found in this scope -error[E0191]: the value of the associated type `Item` in `Tr` must be specified - --> $DIR/avoid-getting-associated-items-of-undefined-trait.rs:8:16 +error[E0658]: `?Trait` is not permitted in trait object types + --> $DIR/avoid-getting-associated-items-of-undefined-trait.rs:8:21 | -LL | type Item; - | --------- `Item` defined here -... LL | let _: dyn Tr + ?Foo<Assoc = ()>; - | ^^ help: specify the associated type: `Tr<Item = Type>` + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0191, E0405, E0658. -For more information about an error, try `rustc --explain E0191`. +Some errors have detailed explanations: E0405, E0658. +For more information about an error, try `rustc --explain E0405`. diff --git a/tests/ui/feature-gates/feature-gate-more-maybe-bounds.stderr b/tests/ui/feature-gates/feature-gate-more-maybe-bounds.stderr index 729df4eb37c..f52532a035b 100644 --- a/tests/ui/feature-gates/feature-gate-more-maybe-bounds.stderr +++ b/tests/ui/feature-gates/feature-gate-more-maybe-bounds.stderr @@ -4,24 +4,23 @@ error[E0658]: `?Trait` is not permitted in supertraits LL | trait Trait3: ?Trait1 {} | ^^^^^^^ | - = note: traits are `?Trait1` by default = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: `?Trait` is not permitted in trait object types - --> $DIR/feature-gate-more-maybe-bounds.rs:10:28 +error[E0658]: `?Trait` bounds are only permitted at the point where a type parameter is declared + --> $DIR/feature-gate-more-maybe-bounds.rs:7:26 | -LL | fn foo(_: Box<dyn Trait1 + ?Trait2>) {} - | ^^^^^^^ +LL | trait Trait4 where Self: ?Trait1 {} + | ^^^^^^^ | = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: `?Trait` bounds are only permitted at the point where a type parameter is declared - --> $DIR/feature-gate-more-maybe-bounds.rs:7:26 +error[E0658]: `?Trait` is not permitted in trait object types + --> $DIR/feature-gate-more-maybe-bounds.rs:10:28 | -LL | trait Trait4 where Self: ?Trait1 {} - | ^^^^^^^ +LL | fn foo(_: Box<dyn Trait1 + ?Trait2>) {} + | ^^^^^^^ | = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date diff --git a/tests/ui/sized-hierarchy/default-supertrait.stderr b/tests/ui/sized-hierarchy/default-supertrait.stderr index de23936b900..0cb4f346a63 100644 --- a/tests/ui/sized-hierarchy/default-supertrait.stderr +++ b/tests/ui/sized-hierarchy/default-supertrait.stderr @@ -4,9 +4,9 @@ error[E0658]: `?Trait` is not permitted in supertraits LL | trait NegSized: ?Sized { } | ^^^^^^ | - = note: traits are `?Sized` by default = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: traits are `?Sized` by default error[E0658]: `?Trait` is not permitted in supertraits --> $DIR/default-supertrait.rs:13:21 @@ -14,7 +14,6 @@ error[E0658]: `?Trait` is not permitted in supertraits LL | trait NegMetaSized: ?MetaSized { } | ^^^^^^^^^^ | - = note: traits are `?MetaSized` by default = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date @@ -24,7 +23,6 @@ error[E0658]: `?Trait` is not permitted in supertraits LL | trait NegPointeeSized: ?PointeeSized { } | ^^^^^^^^^^^^^ | - = note: traits are `?PointeeSized` by default = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date diff --git a/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr index bd0baa580bd..5c4100d0e26 100644 --- a/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr +++ b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr @@ -4,9 +4,9 @@ error[E0658]: `?Trait` is not permitted in supertraits LL | trait Tr: ?Sized {} | ^^^^^^ | - = note: traits are `?Sized` by default = help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: traits are `?Sized` by default error[E0658]: `?Trait` is not permitted in trait object types --> $DIR/maybe-trait-bounds-forbidden-locations.rs:13:20 diff --git a/tests/ui/unsized/maybe-bounds-where.rs b/tests/ui/unsized/relaxed-bounds-invalid-places.rs index 4c4141631a7..ce3f35608be 100644 --- a/tests/ui/unsized/maybe-bounds-where.rs +++ b/tests/ui/unsized/relaxed-bounds-invalid-places.rs @@ -1,3 +1,6 @@ +// Test that relaxed bounds can only be placed on type parameters defined by the closest item +// (ignoring relaxed bounds inside `impl Trait` and in associated type defs here). + struct S1<T>(T) where (T): ?Sized; //~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared diff --git a/tests/ui/unsized/maybe-bounds-where.stderr b/tests/ui/unsized/relaxed-bounds-invalid-places.stderr index fb6d37c2966..3287eb8d1e9 100644 --- a/tests/ui/unsized/maybe-bounds-where.stderr +++ b/tests/ui/unsized/relaxed-bounds-invalid-places.stderr @@ -1,5 +1,5 @@ error[E0658]: `?Trait` bounds are only permitted at the point where a type parameter is declared - --> $DIR/maybe-bounds-where.rs:1:28 + --> $DIR/relaxed-bounds-invalid-places.rs:4:28 | LL | struct S1<T>(T) where (T): ?Sized; | ^^^^^^ @@ -8,7 +8,7 @@ LL | struct S1<T>(T) where (T): ?Sized; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `?Trait` bounds are only permitted at the point where a type parameter is declared - --> $DIR/maybe-bounds-where.rs:4:27 + --> $DIR/relaxed-bounds-invalid-places.rs:7:27 | LL | struct S2<T>(T) where u8: ?Sized; | ^^^^^^ @@ -17,7 +17,7 @@ LL | struct S2<T>(T) where u8: ?Sized; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `?Trait` bounds are only permitted at the point where a type parameter is declared - --> $DIR/maybe-bounds-where.rs:7:35 + --> $DIR/relaxed-bounds-invalid-places.rs:10:35 | LL | struct S3<T>(T) where &'static T: ?Sized; | ^^^^^^ @@ -26,7 +26,7 @@ LL | struct S3<T>(T) where &'static T: ?Sized; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `?Trait` bounds are only permitted at the point where a type parameter is declared - --> $DIR/maybe-bounds-where.rs:12:34 + --> $DIR/relaxed-bounds-invalid-places.rs:15:34 | LL | struct S4<T>(T) where for<'a> T: ?Trait<'a>; | ^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | struct S4<T>(T) where for<'a> T: ?Trait<'a>; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `?Trait` bounds are only permitted at the point where a type parameter is declared - --> $DIR/maybe-bounds-where.rs:21:21 + --> $DIR/relaxed-bounds-invalid-places.rs:24:21 | LL | fn f() where T: ?Sized {} | ^^^^^^ @@ -44,13 +44,13 @@ LL | fn f() where T: ?Sized {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default - --> $DIR/maybe-bounds-where.rs:12:34 + --> $DIR/relaxed-bounds-invalid-places.rs:15:34 | LL | struct S4<T>(T) where for<'a> T: ?Trait<'a>; | ^^^^^^^^^^ error[E0203]: type parameter has more than one relaxed default bound, only one is supported - --> $DIR/maybe-bounds-where.rs:16:33 + --> $DIR/relaxed-bounds-invalid-places.rs:19:33 | LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized; | ^^^^^^^^^^^^^^^ ^^^^^^ @@ -59,7 +59,7 @@ LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default - --> $DIR/maybe-bounds-where.rs:16:33 + --> $DIR/relaxed-bounds-invalid-places.rs:19:33 | LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized; | ^^^^^^^^^^^^^^^ |
