diff options
author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-10-03 21:10:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-10-03 21:10:32 +0200 |
commit | 0d0b695b9f6bbf83794c382effce7a54a0b61eda (patch) | |
tree | 5f81ed2199afdd92fdb4f41d01a11ddb3ef44404 | |
parent | 2e06dcdbeb45f1df32d97d7a85b923d8996b9592 (diff) | |
parent | fab9906c21e8c751943760d44c4a12cac2bceb05 (diff) | |
download | rust-0d0b695b9f6bbf83794c382effce7a54a0b61eda.tar.gz rust-0d0b695b9f6bbf83794c382effce7a54a0b61eda.zip |
Rollup merge of #147269 - reddevilmidzy:ice-fix, r=petrochenkov
Add regression test for 123953 close: rust-lang/rust#123953
-rw-r--r-- | tests/ui/associated-types/projection-dyn-associated-type.rs | 28 | ||||
-rw-r--r-- | tests/ui/associated-types/projection-dyn-associated-type.stderr | 52 |
2 files changed, 80 insertions, 0 deletions
diff --git a/tests/ui/associated-types/projection-dyn-associated-type.rs b/tests/ui/associated-types/projection-dyn-associated-type.rs new file mode 100644 index 00000000000..3b981e7987e --- /dev/null +++ b/tests/ui/associated-types/projection-dyn-associated-type.rs @@ -0,0 +1,28 @@ +// Regression test for the projection bug in <https://github.com/rust-lang/rust/issues/123953> +// +//@ compile-flags: -Zincremental-verify-ich=yes +//@ incremental + +pub trait A {} +pub trait B: A {} + +pub trait Mirror { + type Assoc: ?Sized; +} + +impl<T: ?Sized> Mirror for A { + //~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates [E0207] + //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] + //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + type Assoc = T; +} + +pub fn foo<'a>( + x: &'a <dyn A + 'static as Mirror>::Assoc +) -> &'a <dyn B + 'static as Mirror>::Assoc { + //~^ ERROR the trait bound `(dyn B + 'static): Mirror` is not satisfied [E0277] + //~| ERROR the trait bound `(dyn B + 'static): Mirror` is not satisfied [E0277] + static +} //~ ERROR expected identifier, found `}` + +pub fn main() {} diff --git a/tests/ui/associated-types/projection-dyn-associated-type.stderr b/tests/ui/associated-types/projection-dyn-associated-type.stderr new file mode 100644 index 00000000000..1ac2beb0414 --- /dev/null +++ b/tests/ui/associated-types/projection-dyn-associated-type.stderr @@ -0,0 +1,52 @@ +error: expected identifier, found `}` + --> $DIR/projection-dyn-associated-type.rs:26:1 + | +LL | } + | ^ expected identifier + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/projection-dyn-associated-type.rs:13:28 + | +LL | impl<T: ?Sized> Mirror for A { + | ^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html> + = note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default +help: if this is a dyn-compatible trait, use `dyn` + | +LL | impl<T: ?Sized> Mirror for dyn A { + | +++ +help: alternatively use a blanket implementation to implement `Mirror` for all types that also implement `A` + | +LL - impl<T: ?Sized> Mirror for A { +LL + impl<T: ?Sized, U: A> Mirror for U { + | + +error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates + --> $DIR/projection-dyn-associated-type.rs:13:6 + | +LL | impl<T: ?Sized> Mirror for A { + | ^ unconstrained type parameter + +error[E0277]: the trait bound `(dyn B + 'static): Mirror` is not satisfied + --> $DIR/projection-dyn-associated-type.rs:22:6 + | +LL | ) -> &'a <dyn B + 'static as Mirror>::Assoc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Mirror` is not implemented for `(dyn B + 'static)` + | + = help: the trait `Mirror` is implemented for `dyn A` + +error[E0277]: the trait bound `(dyn B + 'static): Mirror` is not satisfied + --> $DIR/projection-dyn-associated-type.rs:22:6 + | +LL | ) -> &'a <dyn B + 'static as Mirror>::Assoc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Mirror` is not implemented for `(dyn B + 'static)` + | + = help: the trait `Mirror` is implemented for `dyn A` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 4 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0207, E0277. +For more information about an error, try `rustc --explain E0207`. |