Skip to content

Commit

Permalink
add non-regression test for issue 126670
Browse files Browse the repository at this point in the history
  • Loading branch information
lqd committed Jun 25, 2024
1 parent 595550a commit 917c89d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/ui/impl-trait/in-trait/refine-resolution-errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// This is a non-regression test for issue #126670 where RPITIT refinement checking encountered
// errors during resolution and ICEd.

//@ edition: 2018

pub trait A {}

pub trait Mirror {
type Assoc: ?Sized;
}
impl<T: ?Sized> Mirror for dyn A {
//~^ ERROR the type parameter `T` is not constrained
type Assoc = T;
}

pub trait First {
async fn first() -> <dyn A + 'static as Mirror>::Assoc;
//~^ ERROR type annotations needed
}

impl First for dyn A {
async fn first() {}
}

fn main() {}
16 changes: 16 additions & 0 deletions tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
--> $DIR/refine-resolution-errors.rs:11:6
|
LL | impl<T: ?Sized> Mirror for dyn A {
| ^ unconstrained type parameter

error[E0282]: type annotations needed
--> $DIR/refine-resolution-errors.rs:17:5
|
LL | async fn first() -> <dyn A + 'static as Mirror>::Assoc;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0207, E0282.
For more information about an error, try `rustc --explain E0207`.

0 comments on commit 917c89d

Please sign in to comment.