summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_lint/src/for_loops_over_fallibles.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_lint/src/for_loops_over_fallibles.rs')
-rw-r--r--compiler/rustc_lint/src/for_loops_over_fallibles.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/rustc_lint/src/for_loops_over_fallibles.rs b/compiler/rustc_lint/src/for_loops_over_fallibles.rs
index 5219992ee..a3367ae4a 100644
--- a/compiler/rustc_lint/src/for_loops_over_fallibles.rs
+++ b/compiler/rustc_lint/src/for_loops_over_fallibles.rs
@@ -65,11 +65,8 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
} else {
ForLoopsOverFalliblesLoopSub::UseWhileLet { start_span: expr.span.with_hi(pat.span.lo()), end_span: pat.span.between(arg.span), var }
} ;
- let question_mark = if suggest_question_mark(cx, adt, substs, expr.span) {
- Some(ForLoopsOverFalliblesQuestionMark { suggestion: arg.span.shrink_to_hi() })
- } else {
- None
- };
+ let question_mark = suggest_question_mark(cx, adt, substs, expr.span)
+ .then(|| ForLoopsOverFalliblesQuestionMark { suggestion: arg.span.shrink_to_hi() });
let suggestion = ForLoopsOverFalliblesSuggestion {
var,
start_span: expr.span.with_hi(pat.span.lo()),
@@ -139,9 +136,10 @@ fn suggest_question_mark<'tcx>(
let ty = substs.type_at(0);
let infcx = cx.tcx.infer_ctxt().build();
+ let body_def_id = cx.tcx.hir().body_owner_def_id(body_id);
let cause = ObligationCause::new(
span,
- body_id.hir_id,
+ body_def_id,
rustc_infer::traits::ObligationCauseCode::MiscObligation,
);
let errors = rustc_trait_selection::traits::fully_solve_bound(