about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2022-10-07 18:21:32 +0000
committerMaybe Waffle <waffle.lapkin@gmail.com>2022-10-09 13:07:21 +0000
commit9d4edff1b0179e3514bcc27618edd6348903e99a (patch)
tree8a53eeb3bebaa98dc4271cf3bdad1bbfba6d4ac5
parent5347c819241135218418ce7f9c157dbd099fd41a (diff)
downloadrust-9d4edff1b0179e3514bcc27618edd6348903e99a.tar.gz
rust-9d4edff1b0179e3514bcc27618edd6348903e99a.zip
adopt to building infcx
-rw-r--r--compiler/rustc_lint/src/for_loops_over_fallibles.rs45
1 files changed, 21 insertions, 24 deletions
diff --git a/compiler/rustc_lint/src/for_loops_over_fallibles.rs b/compiler/rustc_lint/src/for_loops_over_fallibles.rs
index 4f0ae081166..ed8d424e0c6 100644
--- a/compiler/rustc_lint/src/for_loops_over_fallibles.rs
+++ b/compiler/rustc_lint/src/for_loops_over_fallibles.rs
@@ -159,28 +159,25 @@ fn suggest_question_mark<'tcx>(
     }
 
     let ty = substs.type_at(0);
-    let is_iterator = cx.tcx.infer_ctxt().enter(|infcx| {
-        let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
-
-        let cause = ObligationCause::new(
-            span,
-            body_id.hir_id,
-            rustc_infer::traits::ObligationCauseCode::MiscObligation,
-        );
-        fulfill_cx.register_bound(
-            &infcx,
-            ty::ParamEnv::empty(),
-            // Erase any region vids from the type, which may not be resolved
-            infcx.tcx.erase_regions(ty),
-            into_iterator_did,
-            cause,
-        );
-
-        // Select all, including ambiguous predicates
-        let errors = fulfill_cx.select_all_or_error(&infcx);
-
-        errors.is_empty()
-    });
-
-    is_iterator
+    let infcx = cx.tcx.infer_ctxt().build();
+    let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
+
+    let cause = ObligationCause::new(
+        span,
+        body_id.hir_id,
+        rustc_infer::traits::ObligationCauseCode::MiscObligation,
+    );
+    fulfill_cx.register_bound(
+        &infcx,
+        ty::ParamEnv::empty(),
+        // Erase any region vids from the type, which may not be resolved
+        infcx.tcx.erase_regions(ty),
+        into_iterator_did,
+        cause,
+    );
+
+    // Select all, including ambiguous predicates
+    let errors = fulfill_cx.select_all_or_error(&infcx);
+
+    errors.is_empty()
 }