about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2023-03-14 14:19:06 +0100
committerlcnr <rust@lcnr.de>2023-03-21 09:57:20 +0100
commit791ce0b7b5d03649bc9014d5b0abb78f3c6f2cfd (patch)
tree4a321c50deba262c65a0dc552fbfaca8cc70de14 /compiler/rustc_lint/src
parent84c47b8279b39e165dfebeb529eb6d92592e4f8d (diff)
downloadrust-791ce0b7b5d03649bc9014d5b0abb78f3c6f2cfd.tar.gz
rust-791ce0b7b5d03649bc9014d5b0abb78f3c6f2cfd.zip
remove some trait solver helpers
they add more complexity then they are worth. It's confusing
which of these helpers should be used in which context.
Diffstat (limited to 'compiler/rustc_lint/src')
-rw-r--r--compiler/rustc_lint/src/for_loops_over_fallibles.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_lint/src/for_loops_over_fallibles.rs b/compiler/rustc_lint/src/for_loops_over_fallibles.rs
index a3367ae4a9f..cb7711034ed 100644
--- a/compiler/rustc_lint/src/for_loops_over_fallibles.rs
+++ b/compiler/rustc_lint/src/for_loops_over_fallibles.rs
@@ -11,6 +11,7 @@ use rustc_hir as hir;
 use rustc_infer::{infer::TyCtxtInferExt, traits::ObligationCause};
 use rustc_middle::ty::{self, List};
 use rustc_span::{sym, Span};
+use rustc_trait_selection::traits::ObligationCtxt;
 
 declare_lint! {
     /// The `for_loops_over_fallibles` lint checks for `for` loops over `Option` or `Result` values.
@@ -136,20 +137,23 @@ fn suggest_question_mark<'tcx>(
 
     let ty = substs.type_at(0);
     let infcx = cx.tcx.infer_ctxt().build();
+    let ocx = ObligationCtxt::new(&infcx);
+
     let body_def_id = cx.tcx.hir().body_owner_def_id(body_id);
     let cause = ObligationCause::new(
         span,
         body_def_id,
         rustc_infer::traits::ObligationCauseCode::MiscObligation,
     );
-    let errors = rustc_trait_selection::traits::fully_solve_bound(
-        &infcx,
+
+    ocx.register_bound(
         cause,
+        // FIXME: using the empty param env is wrong, should use the one from `body_id`.
         ty::ParamEnv::empty(),
         // Erase any region vids from the type, which may not be resolved
         infcx.tcx.erase_regions(ty),
         into_iterator_did,
     );
 
-    errors.is_empty()
+    ocx.select_all_or_error().is_empty()
 }