Skip to content

Commit 6e2aa42

Browse files
committed
Avoid unnecessary opaque type errors in borrowck
1 parent 5a21467 commit 6e2aa42

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/librustc_mir/borrow_check/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ fn do_mir_borrowck<'a, 'tcx>(
139139

140140
// Gather the upvars of a closure, if any.
141141
let tables = tcx.typeck_tables_of(def_id);
142+
if tables.tainted_by_errors {
143+
infcx.set_tainted_by_errors();
144+
}
142145
let upvars: Vec<_> = tables
143146
.upvar_list
144147
.get(&def_id)

src/librustc_mir/borrow_check/nll.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
282282
let (closure_region_requirements, nll_errors) =
283283
regioncx.solve(infcx, &body, def_id, polonius_output.clone());
284284

285+
if !nll_errors.is_empty() {
286+
// Suppress unhelpful extra errors in `infer_opaque_types`.
287+
infcx.set_tainted_by_errors();
288+
}
289+
285290
let remapped_opaque_tys = regioncx.infer_opaque_types(&infcx, opaque_type_values, body.span);
286291

287292
NllOutput {

0 commit comments

Comments
 (0)