Use ErrorGuaranteed
more
This commit is contained in:
parent
0f82cfffda
commit
8c8e8d35bc
2 changed files with 11 additions and 6 deletions
|
@ -19,7 +19,9 @@ use rustc_ast::visit::{
|
||||||
use rustc_ast::*;
|
use rustc_ast::*;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||||
use rustc_errors::codes::*;
|
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::Namespace::{self, *};
|
||||||
use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
|
use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
|
||||||
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId};
|
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId};
|
||||||
|
@ -264,7 +266,7 @@ impl RibKind<'_> {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct Rib<'ra, R = Res> {
|
pub(crate) struct Rib<'ra, R = Res> {
|
||||||
pub bindings: IdentMap<R>,
|
pub bindings: IdentMap<R>,
|
||||||
pub patterns_with_skipped_bindings: FxHashMap<DefId, Vec<(Span, bool /* recovered error */)>>,
|
pub patterns_with_skipped_bindings: FxHashMap<DefId, Vec<(Span, Result<(), ErrorGuaranteed>)>>,
|
||||||
pub kind: RibKind<'ra>,
|
pub kind: RibKind<'ra>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3841,7 +3843,10 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
||||||
.patterns_with_skipped_bindings
|
.patterns_with_skipped_bindings
|
||||||
.entry(def_id)
|
.entry(def_id)
|
||||||
.or_default()
|
.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 => {}
|
ast::PatFieldsRest::None => {}
|
||||||
|
|
|
@ -1134,7 +1134,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
|
||||||
if let Some(fields) = self.r.field_idents(*def_id) {
|
if let Some(fields) = self.r.field_idents(*def_id) {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
if field.name == segment.ident.name {
|
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
|
// This resolution error will likely be fixed by fixing a
|
||||||
// syntax error in a pattern, so it is irrelevant to the user.
|
// syntax error in a pattern, so it is irrelevant to the user.
|
||||||
let multispan: MultiSpan =
|
let multispan: MultiSpan =
|
||||||
|
@ -1148,7 +1148,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
|
||||||
}
|
}
|
||||||
let mut multispan: MultiSpan = spans
|
let mut multispan: MultiSpan = spans
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, was_recovered)| !was_recovered)
|
.filter(|(_, had_error)| had_error.is_ok())
|
||||||
.map(|(sp, _)| *sp)
|
.map(|(sp, _)| *sp)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.into();
|
.into();
|
||||||
|
@ -1156,7 +1156,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
|
||||||
let ty = self.r.tcx.item_name(*def_id);
|
let ty = self.r.tcx.item_name(*def_id);
|
||||||
multispan.push_span_label(def_span, String::new());
|
multispan.push_span_label(def_span, String::new());
|
||||||
multispan.push_span_label(field.span, "defined here".to_string());
|
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(
|
multispan.push_span_label(
|
||||||
*span,
|
*span,
|
||||||
format!(
|
format!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue