about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-01-04 22:02:26 +0000
committerMichael Goulet <michael@errs.io>2023-01-04 22:07:04 +0000
commit21b078a64eaa2d708a793ec7d42665ba0a326fb0 (patch)
tree3d693f88086066901c15d0a90e3ba41d7237433f
parentb7cdb635c4b973572307ad288466fba64533369c (diff)
downloadrust-21b078a64eaa2d708a793ec7d42665ba0a326fb0.tar.gz
rust-21b078a64eaa2d708a793ec7d42665ba0a326fb0.zip
Use FxIndexSet when updating obligation causes in adjust_fulfillment_errors_for_expr_obligation
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index d342d96a10f..d45f28a5f65 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -9,7 +9,7 @@ use crate::{
     TupleArgumentsFlag,
 };
 use rustc_ast as ast;
-use rustc_data_structures::fx::FxHashSet;
+use rustc_data_structures::fx::FxIndexSet;
 use rustc_errors::{pluralize, Applicability, Diagnostic, DiagnosticId, MultiSpan};
 use rustc_hir as hir;
 use rustc_hir::def::{CtorOf, DefKind, Res};
@@ -1689,7 +1689,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         // even if their `ObligationCauseCode` isn't an `Expr*Obligation` kind.
         // This is important since if we adjust one span but not the other, then
         // we will have "duplicated" the error on the UI side.
-        let mut remap_cause = FxHashSet::default();
+        let mut remap_cause = FxIndexSet::default();
         let mut not_adjusted = vec![];
 
         for error in errors {
@@ -1717,6 +1717,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             }
         }
 
+        // Adjust any other errors that come from other cause codes, when these
+        // errors are of the same predicate as one we successfully adjusted, and
+        // when their spans overlap (suggesting they're due to the same root cause).
+        //
+        // This is because due to normalization, we often register duplicate
+        // obligations with misc obligations that are basically impossible to
+        // line back up with a useful ExprBindingObligation.
         for error in not_adjusted {
             for (span, predicate, cause) in &remap_cause {
                 if *predicate == error.obligation.predicate