diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-22 08:13:54 +0100 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-22 08:13:54 +0100 |
| commit | 1bcbed19d1629d8a67f322c76b8fc4a29e51539f (patch) | |
| tree | 72c36c7f861cbfcb753de3aae56d29d662ab97e4 | |
| parent | cdb683f6e4b0774b85c60eebe12af87f29d8ee4d (diff) | |
| download | rust-1bcbed19d1629d8a67f322c76b8fc4a29e51539f.tar.gz rust-1bcbed19d1629d8a67f322c76b8fc4a29e51539f.zip | |
add test for #110696
Fixes #110696
| -rw-r--r-- | tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs | 52 | ||||
| -rw-r--r-- | tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr | 9 |
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs new file mode 100644 index 00000000000..840be25dd2e --- /dev/null +++ b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs @@ -0,0 +1,52 @@ +// test for #110696 +// failed to resolve instance for <Scope<()> as MyIndex<()>>::my_index +// ignore-tidy-linelength + +#![feature(type_alias_impl_trait)] + +use std::marker::PhantomData; + + +trait MyIndex<T> { + type O; + fn my_index(self) -> Self::O; +} +trait MyFrom<T>: Sized { + type Error; + fn my_from(value: T) -> Result<Self, Self::Error>; +} + + +trait F {} +impl F for () {} +type DummyT<T> = impl F; +fn _dummy_t<T>() -> DummyT<T> {} + +struct Phantom1<T>(PhantomData<T>); +struct Phantom2<T>(PhantomData<T>); +struct Scope<T>(Phantom2<DummyT<T>>); + +impl<T> Scope<T> { + fn new() -> Self { + unimplemented!() + } +} + +impl<T> MyFrom<Phantom2<T>> for Phantom1<T> { + type Error = (); + fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> { + unimplemented!() + } +} + +impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> { + //~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates + type O = T; + fn my_index(self) -> Self::O { + MyFrom::my_from(self.0).ok().unwrap() + } +} + +fn main() { + let _pos: Phantom1<DummyT<()>> = Scope::new().my_index(); +} diff --git a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr new file mode 100644 index 00000000000..a39f77ce17f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr @@ -0,0 +1,9 @@ +error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates + --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:42:6 + | +LL | impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> { + | ^ unconstrained type parameter + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0207`. |
