File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -1486,6 +1486,9 @@ pub fn match_function_call<'tcx>(
1486
1486
None
1487
1487
}
1488
1488
1489
+ // FIXME: Per https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/infer/at/struct.At.html#method.normalize
1490
+ // this function can be removed once the `normalizie` method does not panic when normalization does
1491
+ // not succeed
1489
1492
/// Checks if `Ty` is normalizable. This function is useful
1490
1493
/// to avoid crashes on `layout_of`.
1491
1494
pub fn is_normalizable < ' tcx > ( cx : & LateContext < ' tcx > , param_env : ty:: ParamEnv < ' tcx > , ty : Ty < ' tcx > ) -> bool {
@@ -1501,7 +1504,8 @@ fn is_normalizable_helper<'tcx>(
1501
1504
if let Some ( & cached_result) = cache. get ( ty) {
1502
1505
return cached_result;
1503
1506
}
1504
- cache. insert ( ty, false ) ; // prevent recursive loops
1507
+ // prevent recursive loops, false-negative is better than endless loop leading to stack overflow
1508
+ cache. insert ( ty, false ) ;
1505
1509
let result = cx. tcx . infer_ctxt ( ) . enter ( |infcx| {
1506
1510
let cause = rustc_middle:: traits:: ObligationCause :: dummy ( ) ;
1507
1511
if infcx. at ( & cause, param_env) . normalize ( ty) . is_ok ( ) {
You can’t perform that action at this time.
0 commit comments