Skip to content

Commit 72cddd6

Browse files
author
Yuki Okushi
authored
Rollup merge of rust-lang#106468 - compiler-errors:err-instability, r=lcnr
Use FxIndexSet when updating obligation causes in `adjust_fulfillment_errors_for_expr_obligation` I have no idea how to test this reliably, but I've **manually** verified it fixes the instability in rust-lang#106417 that isn't due to dtolnay/trybuild#212. Fixes rust-lang#106417
2 parents 2184581 + 21b078a commit 72cddd6

File tree

1 file changed

+9
-2
lines changed
  • compiler/rustc_hir_typeck/src/fn_ctxt

1 file changed

+9
-2
lines changed

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
TupleArgumentsFlag,
1010
};
1111
use rustc_ast as ast;
12-
use rustc_data_structures::fx::FxHashSet;
12+
use rustc_data_structures::fx::FxIndexSet;
1313
use rustc_errors::{pluralize, Applicability, Diagnostic, DiagnosticId, MultiSpan};
1414
use rustc_hir as hir;
1515
use rustc_hir::def::{CtorOf, DefKind, Res};
@@ -1698,7 +1698,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16981698
// even if their `ObligationCauseCode` isn't an `Expr*Obligation` kind.
16991699
// This is important since if we adjust one span but not the other, then
17001700
// we will have "duplicated" the error on the UI side.
1701-
let mut remap_cause = FxHashSet::default();
1701+
let mut remap_cause = FxIndexSet::default();
17021702
let mut not_adjusted = vec![];
17031703

17041704
for error in errors {
@@ -1726,6 +1726,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17261726
}
17271727
}
17281728

1729+
// Adjust any other errors that come from other cause codes, when these
1730+
// errors are of the same predicate as one we successfully adjusted, and
1731+
// when their spans overlap (suggesting they're due to the same root cause).
1732+
//
1733+
// This is because due to normalization, we often register duplicate
1734+
// obligations with misc obligations that are basically impossible to
1735+
// line back up with a useful ExprBindingObligation.
17291736
for error in not_adjusted {
17301737
for (span, predicate, cause) in &remap_cause {
17311738
if *predicate == error.obligation.predicate

0 commit comments

Comments
 (0)