File tree 3 files changed +29
-4
lines changed
compiler/rustc_infer/src/infer
3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -1580,11 +1580,16 @@ impl<'tcx> InferCtxt<'tcx> {
1580
1580
Ok ( None ) => {
1581
1581
let tcx = self . tcx ;
1582
1582
let def_id = unevaluated. def ;
1583
- span_bug ! (
1583
+ // HACK(generic_const_exprs): We delay the bug instead of immediately ICEing since
1584
+ // #117159 may cause us to try to evaluate unevaluatable consts that fail wfcheck
1585
+ // despite an error being constructed. See #118545
1586
+ Err ( ErrorHandled :: from ( tcx. dcx ( ) . span_delayed_bug (
1584
1587
tcx. def_span ( def_id) ,
1585
- "unable to construct a constant value for the unevaluated constant {:?}" ,
1586
- unevaluated
1587
- ) ;
1588
+ format ! (
1589
+ "unable to construct a constant value for the unevaluated constant {:?}" ,
1590
+ unevaluated
1591
+ ) ,
1592
+ ) ) )
1588
1593
}
1589
1594
Err ( err) => Err ( err) ,
1590
1595
}
Original file line number Diff line number Diff line change
1
+ #![ feature( generic_const_exprs) ]
2
+ #![ allow( incomplete_features) ]
3
+
4
+ struct Checked < const F : fn ( ) > ;
5
+ //~^ERROR: using function pointers as const generic parameters is forbidden
6
+
7
+ fn foo ( ) { }
8
+ const _: Checked < foo > = Checked :: < foo > ;
9
+
10
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: using function pointers as const generic parameters is forbidden
2
+ --> $DIR/issue-118545.rs:4:25
3
+ |
4
+ LL | struct Checked<const F: fn()>;
5
+ | ^^^^
6
+ |
7
+ = note: the only supported types are integers, `bool` and `char`
8
+
9
+ error: aborting due to 1 previous error
10
+
You can’t perform that action at this time.
0 commit comments