Skip to content

Commit 1bcbed1

Browse files
committed
add test for #110696
Fixes #110696
1 parent cdb683f commit 1bcbed1

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// test for #110696
2+
// failed to resolve instance for <Scope<()> as MyIndex<()>>::my_index
3+
// ignore-tidy-linelength
4+
5+
#![feature(type_alias_impl_trait)]
6+
7+
use std::marker::PhantomData;
8+
9+
10+
trait MyIndex<T> {
11+
type O;
12+
fn my_index(self) -> Self::O;
13+
}
14+
trait MyFrom<T>: Sized {
15+
type Error;
16+
fn my_from(value: T) -> Result<Self, Self::Error>;
17+
}
18+
19+
20+
trait F {}
21+
impl F for () {}
22+
type DummyT<T> = impl F;
23+
fn _dummy_t<T>() -> DummyT<T> {}
24+
25+
struct Phantom1<T>(PhantomData<T>);
26+
struct Phantom2<T>(PhantomData<T>);
27+
struct Scope<T>(Phantom2<DummyT<T>>);
28+
29+
impl<T> Scope<T> {
30+
fn new() -> Self {
31+
unimplemented!()
32+
}
33+
}
34+
35+
impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
36+
type Error = ();
37+
fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
38+
unimplemented!()
39+
}
40+
}
41+
42+
impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> {
43+
//~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates
44+
type O = T;
45+
fn my_index(self) -> Self::O {
46+
MyFrom::my_from(self.0).ok().unwrap()
47+
}
48+
}
49+
50+
fn main() {
51+
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
2+
--> $DIR/ice-failed-to-resolve-instance-for-110696.rs:42:6
3+
|
4+
LL | impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> {
5+
| ^ unconstrained type parameter
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0207`.

0 commit comments

Comments
 (0)