-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |