Skip to content

Commit

Permalink
add test for rust-lang#99945
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr authored and RenjiSann committed Mar 25, 2024
1 parent ab92699 commit 2f8b324
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/ui/type-alias-impl-trait/failed-to-normalize-ice-99945.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// issue: rust-lang/rust#99945
// ICE Failed to normalize

#![feature(type_alias_impl_trait)]

trait Widget<E> {
type State;

fn make_state(&self) -> Self::State;
}

impl<E> Widget<E> for () {
type State = ();

fn make_state(&self) -> Self::State {}
}

struct StatefulWidget<F>(F);

type StateWidget<'a> = impl Widget<&'a ()>;

impl<F: for<'a> Fn(&'a ()) -> StateWidget<'a>> Widget<()> for StatefulWidget<F> {
type State = ();

fn make_state(&self) -> Self::State {}
}

fn new_stateful_widget<F: for<'a> Fn(&'a ()) -> StateWidget<'a>>(build: F) -> impl Widget<()> {
StatefulWidget(build)
//~^ ERROR expected generic lifetime parameter, found `'a`
}

fn main() {
new_stateful_widget(|_| ()).make_state();
//~^ ERROR mismatched types
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error[E0308]: mismatched types
--> $DIR/failed-to-normalize-ice-99945.rs:34:29
|
LL | type StateWidget<'a> = impl Widget<&'a ()>;
| ------------------- the expected opaque type
...
LL | new_stateful_widget(|_| ()).make_state();
| ^^ expected opaque type, found `()`
|
= note: expected opaque type `StateWidget<'_>`
found unit type `()`

error[E0792]: expected generic lifetime parameter, found `'a`
--> $DIR/failed-to-normalize-ice-99945.rs:29:5
|
LL | type StateWidget<'a> = impl Widget<&'a ()>;
| -- this generic parameter must be used with a generic lifetime parameter
...
LL | StatefulWidget(build)
| ^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

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

0 comments on commit 2f8b324

Please sign in to comment.