Skip to content

Commit 21b078a

Browse files
Use FxIndexSet when updating obligation causes in adjust_fulfillment_errors_for_expr_obligation
1 parent b7cdb63 commit 21b078a

File tree

1 file changed

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

1 file changed

+9
-2
lines changed

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};
@@ -1689,7 +1689,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16891689
// even if their `ObligationCauseCode` isn't an `Expr*Obligation` kind.
16901690
// This is important since if we adjust one span but not the other, then
16911691
// we will have "duplicated" the error on the UI side.
1692-
let mut remap_cause = FxHashSet::default();
1692+
let mut remap_cause = FxIndexSet::default();
16931693
let mut not_adjusted = vec![];
16941694

16951695
for error in errors {
@@ -1717,6 +1717,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17171717
}
17181718
}
17191719

1720+
// Adjust any other errors that come from other cause codes, when these
1721+
// errors are of the same predicate as one we successfully adjusted, and
1722+
// when their spans overlap (suggesting they're due to the same root cause).
1723+
//
1724+
// This is because due to normalization, we often register duplicate
1725+
// obligations with misc obligations that are basically impossible to
1726+
// line back up with a useful ExprBindingObligation.
17201727
for error in not_adjusted {
17211728
for (span, predicate, cause) in &remap_cause {
17221729
if *predicate == error.obligation.predicate

0 commit comments

Comments
 (0)