2021-03-04 07:35:11 -06:00
|
|
|
//@ compile-flags: -Z mir-opt-level=3
|
2020-10-20 03:07:27 -05:00
|
|
|
|
2021-07-26 15:01:16 -05:00
|
|
|
#![feature(type_alias_impl_trait, rustc_attrs)]
|
2020-10-20 03:07:27 -05:00
|
|
|
|
|
|
|
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>;
|
|
|
|
}
|
|
|
|
|
2024-06-10 11:17:38 -05:00
|
|
|
mod f {
|
|
|
|
pub trait F {}
|
|
|
|
impl F for () {}
|
|
|
|
pub type DummyT<T> = impl F;
|
|
|
|
fn _dummy_t<T>() -> DummyT<T> {}
|
|
|
|
}
|
|
|
|
use f::*;
|
2020-10-20 03:07:27 -05:00
|
|
|
|
|
|
|
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<Phantom1<T>> for Scope<U> {
|
|
|
|
type O = T;
|
|
|
|
fn my_index(self) -> Self::O {
|
|
|
|
MyFrom::my_from(self.0).ok().unwrap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-12 04:54:12 -06:00
|
|
|
#[rustc_error]
|
2020-10-20 03:07:27 -05:00
|
|
|
fn main() {
|
2021-07-16 08:06:26 -05:00
|
|
|
//~^ ERROR
|
2021-03-12 06:51:53 -06:00
|
|
|
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
|
2020-10-20 03:07:27 -05:00
|
|
|
}
|