Skip to content

Commit 8c8e8d3

Browse files
committed
Use ErrorGuaranteed more
1 parent 0f82cff commit 8c8e8d3

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

compiler/rustc_resolve/src/late.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ use rustc_ast::visit::{
1919
use rustc_ast::*;
2020
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
2121
use rustc_errors::codes::*;
22-
use rustc_errors::{Applicability, DiagArgValue, IntoDiagArg, StashKey, Suggestions};
22+
use rustc_errors::{
23+
Applicability, DiagArgValue, ErrorGuaranteed, IntoDiagArg, StashKey, Suggestions,
24+
};
2325
use rustc_hir::def::Namespace::{self, *};
2426
use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
2527
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId};
@@ -264,7 +266,7 @@ impl RibKind<'_> {
264266
#[derive(Debug)]
265267
pub(crate) struct Rib<'ra, R = Res> {
266268
pub bindings: IdentMap<R>,
267-
pub patterns_with_skipped_bindings: FxHashMap<DefId, Vec<(Span, bool /* recovered error */)>>,
269+
pub patterns_with_skipped_bindings: FxHashMap<DefId, Vec<(Span, Result<(), ErrorGuaranteed>)>>,
268270
pub kind: RibKind<'ra>,
269271
}
270272

@@ -3841,7 +3843,10 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
38413843
.patterns_with_skipped_bindings
38423844
.entry(def_id)
38433845
.or_default()
3844-
.push((pat.span, matches!(rest, ast::PatFieldsRest::Recovered(_))));
3846+
.push((pat.span, match rest {
3847+
ast::PatFieldsRest::Recovered(guar) => Err(*guar),
3848+
_ => Ok(()),
3849+
}));
38453850
}
38463851
}
38473852
ast::PatFieldsRest::None => {}

compiler/rustc_resolve/src/late/diagnostics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
11341134
if let Some(fields) = self.r.field_idents(*def_id) {
11351135
for field in fields {
11361136
if field.name == segment.ident.name {
1137-
if spans.iter().all(|(_, was_recovered)| *was_recovered) {
1137+
if spans.iter().all(|(_, had_error)| had_error.is_err()) {
11381138
// This resolution error will likely be fixed by fixing a
11391139
// syntax error in a pattern, so it is irrelevant to the user.
11401140
let multispan: MultiSpan =
@@ -1148,15 +1148,15 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
11481148
}
11491149
let mut multispan: MultiSpan = spans
11501150
.iter()
1151-
.filter(|(_, was_recovered)| !was_recovered)
1151+
.filter(|(_, had_error)| had_error.is_ok())
11521152
.map(|(sp, _)| *sp)
11531153
.collect::<Vec<_>>()
11541154
.into();
11551155
let def_span = self.r.def_span(*def_id);
11561156
let ty = self.r.tcx.item_name(*def_id);
11571157
multispan.push_span_label(def_span, String::new());
11581158
multispan.push_span_label(field.span, "defined here".to_string());
1159-
for (span, _) in spans.iter().filter(|(_, r)| !r) {
1159+
for (span, _) in spans.iter().filter(|(_, had_err)| had_err.is_ok()) {
11601160
multispan.push_span_label(
11611161
*span,
11621162
format!(

0 commit comments

Comments
 (0)