File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 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>(
14861486 None
14871487}
14881488
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
14891492/// Checks if `Ty` is normalizable. This function is useful
14901493/// to avoid crashes on `layout_of`.
14911494pub 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>(
15011504 if let Some ( & cached_result) = cache. get ( ty) {
15021505 return cached_result;
15031506 }
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 ) ;
15051509 let result = cx. tcx . infer_ctxt ( ) . enter ( |infcx| {
15061510 let cause = rustc_middle:: traits:: ObligationCause :: dummy ( ) ;
15071511 if infcx. at ( & cause, param_env) . normalize ( ty) . is_ok ( ) {
You can’t perform that action at this time.
0 commit comments