]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_lint/src/for_loops_over_fallibles.rs
Rollup merge of #104193 - TaKO8Ki:fix-104142, r=cjgillot
[rust.git] / compiler / rustc_lint / src / for_loops_over_fallibles.rs
index ed8d424e0c62d489f30906b770c0fd54d3eaced2..4187850153ccd001c22f3659f4803a0f5b1ea75c 100644 (file)
@@ -3,11 +3,9 @@
 use hir::{Expr, Pat};
 use rustc_errors::{Applicability, DelayDm};
 use rustc_hir as hir;
-use rustc_infer::traits::TraitEngine;
 use rustc_infer::{infer::TyCtxtInferExt, traits::ObligationCause};
 use rustc_middle::ty::{self, List};
 use rustc_span::{sym, Span};
-use rustc_trait_selection::traits::TraitEngineExt;
 
 declare_lint! {
     /// The `for_loops_over_fallibles` lint checks for `for` loops over `Option` or `Result` values.
@@ -160,24 +158,19 @@ fn suggest_question_mark<'tcx>(
 
     let ty = substs.type_at(0);
     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(
+    let errors = rustc_trait_selection::traits::fully_solve_bound(
         &infcx,
+        cause,
         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()
 }