Rename struct_span_err!
as struct_span_code_err!
.
Because it takes an error code after the span. This avoids the confusing overlap with the `DiagCtxt::struct_span_err` method, which doesn't take an error code.
This commit is contained in:
parent
99b1b0f85c
commit
4864cb8aef
46 changed files with 277 additions and 224 deletions
|
@ -19,7 +19,7 @@ use rustc_ast::{self as ast, AssocItem, AssocItemKind, MetaItemKind, StmtKind};
|
|||
use rustc_ast::{Block, Fn, ForeignItem, ForeignItemKind, Impl, Item, ItemKind, NodeId};
|
||||
use rustc_attr as attr;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{struct_span_err, Applicability};
|
||||
use rustc_errors::{struct_span_code_err, Applicability};
|
||||
use rustc_expand::expand::AstFragment;
|
||||
use rustc_hir::def::{self, *};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
|
||||
|
@ -1010,7 +1010,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||
for attr in &item.attrs {
|
||||
if attr.has_name(sym::macro_use) {
|
||||
if self.parent_scope.module.parent.is_some() {
|
||||
struct_span_err!(
|
||||
struct_span_code_err!(
|
||||
self.r.dcx(),
|
||||
item.span,
|
||||
E0468,
|
||||
|
@ -1024,7 +1024,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||
}
|
||||
}
|
||||
let ill_formed = |span| {
|
||||
struct_span_err!(self.r.dcx(), span, E0466, "bad macro import").emit();
|
||||
struct_span_code_err!(self.r.dcx(), span, E0466, "bad macro import").emit();
|
||||
};
|
||||
match attr.meta() {
|
||||
Some(meta) => match meta.kind {
|
||||
|
@ -1095,8 +1095,13 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||
allow_shadowing,
|
||||
);
|
||||
} else {
|
||||
struct_span_err!(self.r.dcx(), ident.span, E0469, "imported macro not found")
|
||||
.emit();
|
||||
struct_span_code_err!(
|
||||
self.r.dcx(),
|
||||
ident.span,
|
||||
E0469,
|
||||
"imported macro not found"
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use rustc_ast::{MetaItemKind, NestedMetaItem};
|
|||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{
|
||||
pluralize, report_ambiguity_error, struct_span_err, Applicability, DiagCtxt, Diagnostic,
|
||||
pluralize, report_ambiguity_error, struct_span_code_err, Applicability, DiagCtxt, Diagnostic,
|
||||
DiagnosticBuilder, ErrorGuaranteed, MultiSpan, SuggestionStyle,
|
||||
};
|
||||
use rustc_feature::BUILTIN_ATTRIBUTES;
|
||||
|
@ -153,7 +153,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
BuiltinLintDiagnostics::AmbiguousGlobImports { diag },
|
||||
);
|
||||
} else {
|
||||
let mut err = struct_span_err!(self.dcx(), diag.span, E0659, "{}", &diag.msg);
|
||||
let mut err = struct_span_code_err!(self.dcx(), diag.span, E0659, "{}", &diag.msg);
|
||||
report_ambiguity_error(&mut err, diag);
|
||||
err.emit();
|
||||
}
|
||||
|
@ -254,15 +254,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let msg = format!("the name `{name}` is defined multiple times");
|
||||
|
||||
let mut err = match (old_binding.is_extern_crate(), new_binding.is_extern_crate()) {
|
||||
(true, true) => struct_span_err!(self.dcx(), span, E0259, "{}", msg),
|
||||
(true, true) => struct_span_code_err!(self.dcx(), span, E0259, "{}", msg),
|
||||
(true, _) | (_, true) => match new_binding.is_import() && old_binding.is_import() {
|
||||
true => struct_span_err!(self.dcx(), span, E0254, "{}", msg),
|
||||
false => struct_span_err!(self.dcx(), span, E0260, "{}", msg),
|
||||
true => struct_span_code_err!(self.dcx(), span, E0254, "{}", msg),
|
||||
false => struct_span_code_err!(self.dcx(), span, E0260, "{}", msg),
|
||||
},
|
||||
_ => match (old_binding.is_import_user_facing(), new_binding.is_import_user_facing()) {
|
||||
(false, false) => struct_span_err!(self.dcx(), span, E0428, "{}", msg),
|
||||
(true, true) => struct_span_err!(self.dcx(), span, E0252, "{}", msg),
|
||||
_ => struct_span_err!(self.dcx(), span, E0255, "{}", msg),
|
||||
(false, false) => struct_span_code_err!(self.dcx(), span, E0428, "{}", msg),
|
||||
(true, true) => struct_span_code_err!(self.dcx(), span, E0252, "{}", msg),
|
||||
_ => struct_span_code_err!(self.dcx(), span, E0255, "{}", msg),
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -659,7 +659,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let origin_sp = origin.iter().copied().collect::<Vec<_>>();
|
||||
|
||||
let msp = MultiSpan::from_spans(target_sp.clone());
|
||||
let mut err = struct_span_err!(
|
||||
let mut err = struct_span_code_err!(
|
||||
self.dcx(),
|
||||
msp,
|
||||
E0408,
|
||||
|
@ -788,7 +788,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
}
|
||||
ResolutionError::FailedToResolve { last_segment, label, suggestion, module } => {
|
||||
let mut err =
|
||||
struct_span_err!(self.dcx(), span, E0433, "failed to resolve: {}", &label);
|
||||
struct_span_code_err!(self.dcx(), span, E0433, "failed to resolve: {}", &label);
|
||||
err.span_label(span, label);
|
||||
|
||||
if let Some((suggestions, msg, applicability)) = suggestion {
|
||||
|
@ -1702,8 +1702,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
|
||||
// Print the primary message.
|
||||
let descr = get_descr(binding);
|
||||
let mut err =
|
||||
struct_span_err!(self.dcx(), ident.span, E0603, "{} `{}` is private", descr, ident);
|
||||
let mut err = struct_span_code_err!(
|
||||
self.dcx(),
|
||||
ident.span,
|
||||
E0603,
|
||||
"{} `{}` is private",
|
||||
descr,
|
||||
ident
|
||||
);
|
||||
err.span_label(ident.span, format!("private {descr}"));
|
||||
|
||||
let mut not_publicly_reexported = false;
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::{NameBinding, NameBindingData, NameBindingKind, PathResult};
|
|||
use rustc_ast::NodeId;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_errors::{pluralize, struct_span_err, Applicability, MultiSpan};
|
||||
use rustc_errors::{pluralize, struct_span_code_err, Applicability, MultiSpan};
|
||||
use rustc_hir::def::{self, DefKind, PartialRes};
|
||||
use rustc_middle::metadata::ModChild;
|
||||
use rustc_middle::metadata::Reexport;
|
||||
|
@ -686,7 +686,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
.collect::<Vec<_>>();
|
||||
let msg = format!("unresolved import{} {}", pluralize!(paths.len()), paths.join(", "),);
|
||||
|
||||
let mut diag = struct_span_err!(self.dcx(), span, E0432, "{}", &msg);
|
||||
let mut diag = struct_span_code_err!(self.dcx(), span, E0432, "{}", &msg);
|
||||
|
||||
if let Some((_, UnresolvedImportError { note: Some(note), .. })) = errors.iter().last() {
|
||||
diag.note(note.clone());
|
||||
|
|
|
@ -1664,7 +1664,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
} else {
|
||||
("`'_` cannot be used here", "`'_` is a reserved lifetime name")
|
||||
};
|
||||
let mut diag = rustc_errors::struct_span_err!(
|
||||
let mut diag = rustc_errors::struct_span_code_err!(
|
||||
self.r.dcx(),
|
||||
lifetime.ident.span,
|
||||
E0637,
|
||||
|
@ -1853,7 +1853,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
LifetimeRibKind::AnonymousCreateParameter { report_in_path: true, .. }
|
||||
| LifetimeRibKind::AnonymousWarn(_) => {
|
||||
let sess = self.r.tcx.sess;
|
||||
let mut err = rustc_errors::struct_span_err!(
|
||||
let mut err = rustc_errors::struct_span_code_err!(
|
||||
sess.dcx(),
|
||||
path_span,
|
||||
E0726,
|
||||
|
@ -2594,7 +2594,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
}
|
||||
|
||||
if param.ident.name == kw::UnderscoreLifetime {
|
||||
rustc_errors::struct_span_err!(
|
||||
rustc_errors::struct_span_code_err!(
|
||||
self.r.dcx(),
|
||||
param.ident.span,
|
||||
E0637,
|
||||
|
@ -2608,7 +2608,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
}
|
||||
|
||||
if param.ident.name == kw::StaticLifetime {
|
||||
rustc_errors::struct_span_err!(
|
||||
rustc_errors::struct_span_code_err!(
|
||||
self.r.dcx(),
|
||||
param.ident.span,
|
||||
E0262,
|
||||
|
|
|
@ -16,7 +16,7 @@ use rustc_ast::{
|
|||
use rustc_ast_pretty::pprust::where_bound_predicate_to_string;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{
|
||||
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
|
||||
pluralize, struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
|
||||
MultiSpan, SuggestionStyle,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
|
@ -2603,7 +2603,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
) {
|
||||
debug_assert_ne!(lifetime_ref.ident.name, kw::UnderscoreLifetime);
|
||||
let mut err = if let Some(outer) = outer_lifetime_ref {
|
||||
struct_span_err!(
|
||||
struct_span_code_err!(
|
||||
self.r.dcx(),
|
||||
lifetime_ref.ident.span,
|
||||
E0401,
|
||||
|
@ -2612,7 +2612,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
.span_label_mv(lifetime_ref.ident.span, "use of generic parameter from outer item")
|
||||
.span_label_mv(outer.span, "lifetime parameter from outer item")
|
||||
} else {
|
||||
struct_span_err!(
|
||||
struct_span_code_err!(
|
||||
self.r.dcx(),
|
||||
lifetime_ref.ident.span,
|
||||
E0261,
|
||||
|
@ -2777,7 +2777,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
let num_lifetimes: usize = lifetime_refs.iter().map(|lt| lt.count).sum();
|
||||
let spans: Vec<_> = lifetime_refs.iter().map(|lt| lt.span).collect();
|
||||
|
||||
let mut err = struct_span_err!(
|
||||
let mut err = struct_span_code_err!(
|
||||
self.r.dcx(),
|
||||
spans,
|
||||
E0106,
|
||||
|
@ -3282,7 +3282,7 @@ fn mk_where_bound_predicate(
|
|||
|
||||
/// Report lifetime/lifetime shadowing as an error.
|
||||
pub(super) fn signal_lifetime_shadowing(sess: &Session, orig: Ident, shadower: Ident) {
|
||||
struct_span_err!(
|
||||
struct_span_code_err!(
|
||||
sess.dcx(),
|
||||
shadower.span,
|
||||
E0496,
|
||||
|
|
|
@ -15,7 +15,7 @@ use rustc_ast_pretty::pprust;
|
|||
use rustc_attr::StabilityLevel;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{struct_span_err, Applicability};
|
||||
use rustc_errors::{struct_span_code_err, Applicability};
|
||||
use rustc_expand::base::{Annotatable, DeriveResolutions, Indeterminate, ResolverExpand};
|
||||
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
|
||||
use rustc_expand::compile_declarative_macro;
|
||||
|
@ -948,7 +948,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
rule_spans = Vec::new();
|
||||
}
|
||||
BuiltinMacroState::AlreadySeen(span) => {
|
||||
struct_span_err!(
|
||||
struct_span_code_err!(
|
||||
self.dcx(),
|
||||
item.span,
|
||||
E0773,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue