File tree 2 files changed +61
-0
lines changed
tests/ui/type-alias-impl-trait
2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ // issue: rust-lang/rust#99945
2
+ // ICE Failed to normalize
3
+
4
+ #![ feature( type_alias_impl_trait) ]
5
+
6
+ trait Widget < E > {
7
+ type State ;
8
+
9
+ fn make_state ( & self ) -> Self :: State ;
10
+ }
11
+
12
+ impl < E > Widget < E > for ( ) {
13
+ type State = ( ) ;
14
+
15
+ fn make_state ( & self ) -> Self :: State { }
16
+ }
17
+
18
+ struct StatefulWidget < F > ( F ) ;
19
+
20
+ type StateWidget < ' a > = impl Widget < & ' a ( ) > ;
21
+
22
+ impl < F : for < ' a > Fn ( & ' a ( ) ) -> StateWidget < ' a > > Widget < ( ) > for StatefulWidget < F > {
23
+ type State = ( ) ;
24
+
25
+ fn make_state ( & self ) -> Self :: State { }
26
+ }
27
+
28
+ fn new_stateful_widget < F : for < ' a > Fn ( & ' a ( ) ) -> StateWidget < ' a > > ( build : F ) -> impl Widget < ( ) > {
29
+ StatefulWidget ( build)
30
+ //~^ ERROR expected generic lifetime parameter, found `'a`
31
+ }
32
+
33
+ fn main ( ) {
34
+ new_stateful_widget ( |_| ( ) ) . make_state ( ) ;
35
+ //~^ ERROR mismatched types
36
+ }
Original file line number Diff line number Diff line change
1
+ error[E0308]: mismatched types
2
+ --> $DIR/failed-to-normalize-ice-99945.rs:34:29
3
+ |
4
+ LL | type StateWidget<'a> = impl Widget<&'a ()>;
5
+ | ------------------- the expected opaque type
6
+ ...
7
+ LL | new_stateful_widget(|_| ()).make_state();
8
+ | ^^ expected opaque type, found `()`
9
+ |
10
+ = note: expected opaque type `StateWidget<'_>`
11
+ found unit type `()`
12
+
13
+ error[E0792]: expected generic lifetime parameter, found `'a`
14
+ --> $DIR/failed-to-normalize-ice-99945.rs:29:5
15
+ |
16
+ LL | type StateWidget<'a> = impl Widget<&'a ()>;
17
+ | -- this generic parameter must be used with a generic lifetime parameter
18
+ ...
19
+ LL | StatefulWidget(build)
20
+ | ^^^^^^^^^^^^^^^^^^^^^
21
+
22
+ error: aborting due to 2 previous errors
23
+
24
+ Some errors have detailed explanations: E0308, E0792.
25
+ For more information about an error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments