diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 830b175b26b4a..4e57154ff2b55 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -19,7 +19,9 @@ use rustc_ast::visit::{ use rustc_ast::*; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_errors::codes::*; -use rustc_errors::{Applicability, DiagArgValue, IntoDiagArg, StashKey, Suggestions}; +use rustc_errors::{ + Applicability, DiagArgValue, ErrorGuaranteed, IntoDiagArg, StashKey, Suggestions, +}; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS}; use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId}; @@ -264,7 +266,7 @@ impl RibKind<'_> { #[derive(Debug)] pub(crate) struct Rib<'ra, R = Res> { pub bindings: IdentMap, - pub patterns_with_skipped_bindings: FxHashMap>, + pub patterns_with_skipped_bindings: FxHashMap)>>, pub kind: RibKind<'ra>, } @@ -3841,7 +3843,10 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { .patterns_with_skipped_bindings .entry(def_id) .or_default() - .push((pat.span, matches!(rest, ast::PatFieldsRest::Recovered(_)))); + .push((pat.span, match rest { + ast::PatFieldsRest::Recovered(guar) => Err(*guar), + _ => Ok(()), + })); } } ast::PatFieldsRest::None => {} diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 660ac2d37cc7e..bd4d166be0db5 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1134,7 +1134,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { if let Some(fields) = self.r.field_idents(*def_id) { for field in fields { if field.name == segment.ident.name { - if spans.iter().all(|(_, was_recovered)| *was_recovered) { + if spans.iter().all(|(_, had_error)| had_error.is_err()) { // This resolution error will likely be fixed by fixing a // syntax error in a pattern, so it is irrelevant to the user. let multispan: MultiSpan = @@ -1148,7 +1148,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { } let mut multispan: MultiSpan = spans .iter() - .filter(|(_, was_recovered)| !was_recovered) + .filter(|(_, had_error)| had_error.is_ok()) .map(|(sp, _)| *sp) .collect::>() .into(); @@ -1156,7 +1156,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { let ty = self.r.tcx.item_name(*def_id); multispan.push_span_label(def_span, String::new()); multispan.push_span_label(field.span, "defined here".to_string()); - for (span, _) in spans.iter().filter(|(_, r)| !r) { + for (span, _) in spans.iter().filter(|(_, had_err)| had_err.is_ok()) { multispan.push_span_label( *span, format!(