File tree 2 files changed +58
-0
lines changed
2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ // ICE failed to resolve instance for <fn() -> impl MyFnOnce ...
2
+ // issue: rust-lang/rust#105488
3
+ //@ build-fail
4
+ //~^^^ ERROR overflow evaluating the requirement `fn() -> impl MyFnOnce
5
+
6
+ pub trait MyFnOnce {
7
+ type Output ;
8
+
9
+ fn call_my_fn_once ( self ) -> Self :: Output ;
10
+ }
11
+
12
+ pub struct WrapFnOnce < F > ( F ) ;
13
+
14
+ impl < F : FnOnce ( ) -> D , D : MyFnOnce > MyFnOnce for WrapFnOnce < F > {
15
+ type Output = D :: Output ;
16
+
17
+ fn call_my_fn_once ( self ) -> Self :: Output {
18
+ D :: call_my_fn_once ( self . 0 ( ) )
19
+ }
20
+ }
21
+
22
+ impl < F : FnOnce ( ) -> D , D : MyFnOnce > MyFnOnce for F {
23
+ type Output = D :: Output ;
24
+
25
+ fn call_my_fn_once ( self ) -> Self :: Output {
26
+ D :: call_my_fn_once ( self ( ) )
27
+ }
28
+ }
29
+
30
+ pub fn my_fn_1 ( ) -> impl MyFnOnce {
31
+ my_fn_2
32
+ }
33
+
34
+ pub fn my_fn_2 ( ) -> impl MyFnOnce {
35
+ WrapFnOnce ( my_fn_1)
36
+ }
37
+
38
+ fn main ( ) {
39
+ let v = my_fn_1 ( ) ;
40
+
41
+ let _ = v. call_my_fn_once ( ) ;
42
+ }
Original file line number Diff line number Diff line change
1
+ error[E0275]: overflow evaluating the requirement `fn() -> impl MyFnOnce {my_fn_2}: MyFnOnce`
2
+ |
3
+ = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`failed_to_resolve_instance_ice_105488`)
4
+ note: required for `WrapFnOnce<fn() -> impl MyFnOnce {my_fn_1}>` to implement `MyFnOnce`
5
+ --> $DIR/failed-to-resolve-instance-ice-105488.rs:14:37
6
+ |
7
+ LL | impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for WrapFnOnce<F> {
8
+ | -------- ^^^^^^^^ ^^^^^^^^^^^^^
9
+ | |
10
+ | unsatisfied trait bound introduced here
11
+ = note: 126 redundant requirements hidden
12
+ = note: required for `WrapFnOnce<fn() -> impl MyFnOnce {my_fn_1}>` to implement `MyFnOnce`
13
+
14
+ error: aborting due to 1 previous error
15
+
16
+ For more information about this error, try `rustc --explain E0275`.
You can’t perform that action at this time.
0 commit comments