Skip to content

Commit edee23e

Browse files
committed
Avoid unnecessary opaque type errors in borrowck
1 parent d9b9f00 commit edee23e

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
@@ -136,6 +136,9 @@ fn do_mir_borrowck<'a, 'tcx>(
136136

137137
// Gather the upvars of a closure, if any.
138138
let tables = tcx.typeck_tables_of(def_id);
139+
if tables.tainted_by_errors {
140+
infcx.set_tainted_by_errors();
141+
}
139142
let upvars: Vec<_> = tables
140143
.upvar_list
141144
.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)