diff options
| author | fee1-dead <ent3rm4n@gmail.com> | 2023-01-09 23:35:31 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-09 23:35:31 +0800 |
| commit | 357128ad2334b48d60801640a72970c1be41d16f (patch) | |
| tree | 7795df0429bff569cde426da96b89abb463f1f23 | |
| parent | f8319bb4035612f8387d590f384bb77ebda50ba1 (diff) | |
| parent | 21b078a64eaa2d708a793ec7d42665ba0a326fb0 (diff) | |
| download | rust-357128ad2334b48d60801640a72970c1be41d16f.tar.gz rust-357128ad2334b48d60801640a72970c1be41d16f.zip | |
Rollup merge of #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 #106417 that isn't due to dtolnay/trybuild#212. Fixes #106417
| -rw-r--r-- | compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs | 11 |
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 7d6b4aaebf4..4e1398826bc 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}; @@ -1698,7 +1698,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 { @@ -1726,6 +1726,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 |
