Skip to content

Commit 2f3c20f

Browse files
authored
Rollup merge of #157670 - GuillaumeGomez:rename-err-to-diag, r=JonathanBrouwer
Rename `errors.rs` file to `diagnostics.rs` (4/N) Follow-up of #157485. r? @JonathanBrouwer
2 parents 0bd32c0 + 96eb195 commit 2f3c20f

20 files changed

Lines changed: 139 additions & 104 deletions

compiler/rustc_expand/src/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw};
3232
use smallvec::{SmallVec, smallvec};
3333
use thin_vec::ThinVec;
3434

35-
use crate::errors;
35+
use crate::diagnostics;
3636
use crate::expand::{self, AstFragment, Invocation};
3737
use crate::mbe::macro_rules::ParserAnyMacro;
3838
use crate::module::DirOwnership;
@@ -954,7 +954,7 @@ impl SyntaxExtension {
954954
let stability = find_attr!(attrs, Stability { stability, .. } => *stability);
955955

956956
if let Some(sp) = find_attr!(attrs, RustcBodyStability{ span, .. } => *span) {
957-
sess.dcx().emit_err(errors::MacroBodyStability {
957+
sess.dcx().emit_err(diagnostics::MacroBodyStability {
958958
span: sp,
959959
head_span: sess.source_map().guess_head_span(span),
960960
});
@@ -1358,7 +1358,7 @@ impl<'a> ExtCtxt<'a> {
13581358

13591359
pub fn trace_macros_diag(&mut self) {
13601360
for (span, notes) in self.expansions.iter() {
1361-
let mut db = self.dcx().create_note(errors::TraceMacro { span: *span });
1361+
let mut db = self.dcx().create_note(diagnostics::TraceMacro { span: *span });
13621362
for note in notes {
13631363
db.note(note.clone());
13641364
}
@@ -1401,7 +1401,7 @@ pub fn resolve_path(sess: &Session, path: impl Into<PathBuf>, span: Span) -> PRe
14011401
let callsite = span.source_callsite();
14021402
let source_map = sess.source_map();
14031403
let Some(mut base_path) = source_map.span_to_filename(callsite).into_local_path() else {
1404-
return Err(sess.dcx().create_err(errors::ResolveRelativePath {
1404+
return Err(sess.dcx().create_err(diagnostics::ResolveRelativePath {
14051405
span,
14061406
path: source_map
14071407
.filename_for_diagnostics(&source_map.span_to_filename(callsite))

compiler/rustc_expand/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_session::errors::feature_err;
3131
use rustc_span::{STDLIB_STABLE_CRATES, Span, Symbol, sym};
3232
use tracing::instrument;
3333

34-
use crate::errors::{
34+
use crate::diagnostics::{
3535
CrateNameInCfgAttr, CrateTypeInCfgAttr, FeatureNotAllowed, FeatureRemoved,
3636
FeatureRemovedReason, InvalidCfg, RemoveExprNotSupported,
3737
};
@@ -282,7 +282,7 @@ impl<'a> StripUnconfigured<'a> {
282282
rustc_lint_defs::builtin::UNUSED_ATTRIBUTES,
283283
cfg_attr.span,
284284
ast::CRATE_NODE_ID,
285-
crate::errors::CfgAttrNoAttributes,
285+
crate::diagnostics::CfgAttrNoAttributes,
286286
);
287287
}
288288

compiler/rustc_expand/src/expand.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use smallvec::SmallVec;
3838

3939
use crate::base::*;
4040
use crate::config::{StripUnconfigured, attr_into_trace};
41-
use crate::errors::{
41+
use crate::diagnostics::{
4242
EmptyDelegationMac, GlobDelegationOutsideImpls, GlobDelegationTraitlessQpath, IncompleteParse,
4343
RecursionLimitReached, RemoveExprNotSupported, RemoveNodeNotSupported, UnsupportedKeyValue,
4444
WrongFragmentKind,
@@ -2283,7 +2283,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
22832283
UNUSED_DOC_COMMENTS,
22842284
current_span,
22852285
self.cx.current_expansion.lint_node_id,
2286-
crate::errors::MacroCallUnusedDocComment { span: attr.span },
2286+
crate::diagnostics::MacroCallUnusedDocComment { span: attr.span },
22872287
);
22882288
} else if rustc_attr_parsing::is_builtin_attr(attr)
22892289
&& !AttributeParser::is_parsed_attribute(&attr.path())
@@ -2293,7 +2293,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
22932293
UNUSED_ATTRIBUTES,
22942294
attr.span,
22952295
self.cx.current_expansion.lint_node_id,
2296-
crate::errors::UnusedBuiltinAttribute {
2296+
crate::diagnostics::UnusedBuiltinAttribute {
22972297
attr_name,
22982298
macro_name: pprust::path_to_string(&call.path),
22992299
invoc_span: call.path.span,

compiler/rustc_expand/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// tidy-alphabetical-end
1111

1212
mod build;
13-
mod errors;
13+
mod diagnostics;
1414
mod mbe;
1515
mod placeholders;
1616
mod proc_macro_server;

compiler/rustc_expand/src/mbe/macro_check.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ use rustc_session::parse::ParseSess;
114114
use rustc_span::{ErrorGuaranteed, MacroRulesNormalizedIdent, Span, kw};
115115
use smallvec::SmallVec;
116116

117-
use crate::errors;
117+
use crate::diagnostics;
118118
use crate::mbe::{KleeneToken, TokenTree};
119119

120120
/// Stack represented as linked list.
@@ -247,7 +247,7 @@ fn check_binders(
247247
psess,
248248
span,
249249
node_id,
250-
errors::DuplicateMatcherBindingLint { span, prev: prev_info.span },
250+
diagnostics::DuplicateMatcherBindingLint { span, prev: prev_info.span },
251251
);
252252
} else if get_binder_info(macros, binders, name).is_none() {
253253
// 2. The meta-variable is free: This is a binder.
@@ -266,11 +266,11 @@ fn check_binders(
266266
if let Some(prev_info) = get_binder_info(macros, binders, name) {
267267
// Duplicate binders at the top-level macro definition are errors. The lint is only
268268
// for nested macro definitions.
269-
*guar = Some(
270-
psess
271-
.dcx()
272-
.emit_err(errors::DuplicateMatcherBinding { span, prev: prev_info.span }),
273-
);
269+
*guar =
270+
Some(psess.dcx().emit_err(diagnostics::DuplicateMatcherBinding {
271+
span,
272+
prev: prev_info.span,
273+
}));
274274
} else {
275275
binders.insert(name, BinderInfo { span, ops: ops.into() });
276276
}
@@ -578,7 +578,7 @@ fn check_ops_is_prefix(
578578
return;
579579
}
580580
}
581-
buffer_lint(psess, span, node_id, errors::UnknownMacroVariable { name });
581+
buffer_lint(psess, span, node_id, diagnostics::UnknownMacroVariable { name });
582582
}
583583

584584
/// Returns whether `binder_ops` is a prefix of `occurrence_ops`.
@@ -613,7 +613,7 @@ fn ops_is_prefix(
613613
psess,
614614
span,
615615
node_id,
616-
errors::MetaVarStillRepeatingLint { label: binder.span, ident },
616+
diagnostics::MetaVarStillRepeatingLint { label: binder.span, ident },
617617
);
618618
return;
619619
}
@@ -623,7 +623,7 @@ fn ops_is_prefix(
623623
psess,
624624
span,
625625
node_id,
626-
errors::MetaVariableWrongOperator {
626+
diagnostics::MetaVariableWrongOperator {
627627
binder: binder.span,
628628
occurrence: occurrence.span,
629629
},

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ use rustc_span::hygiene::Transparency;
3030
use rustc_span::{Ident, Span, Symbol, kw, sym};
3131
use tracing::{debug, instrument, trace, trace_span};
3232

33+
use super::SequenceRepetition;
3334
use super::diagnostics::{FailedMacro, failed_to_match_macro};
3435
use super::macro_parser::{NamedMatches, NamedParseResult};
35-
use super::{SequenceRepetition, diagnostics};
3636
use crate::base::{
3737
AttrProcMacro, BangProcMacro, DummyResult, ExpandResult, ExtCtxt, MacResult,
3838
MacroExpanderResult, SyntaxExtension, SyntaxExtensionKind, TTMacroExpander,
3939
};
40-
use crate::errors;
40+
use crate::diagnostics;
4141
use crate::expand::{AstFragment, AstFragmentKind, ensure_complete_parse, parse_ast_fragment};
4242
use crate::mbe::macro_check::check_meta_variables;
4343
use crate::mbe::macro_parser::{Error, ErrorReported, Failure, MatcherLoc, Success, TtParser};
@@ -81,7 +81,7 @@ impl<'a, 'b> ParserAnyMacro<'a, 'b> {
8181
let fragment = match parse_ast_fragment(parser, kind) {
8282
Ok(f) => f,
8383
Err(err) => {
84-
let guar = diagnostics::emit_frag_parse_err(
84+
let guar = super::diagnostics::emit_frag_parse_err(
8585
err,
8686
parser,
8787
snapshot,
@@ -104,7 +104,7 @@ impl<'a, 'b> ParserAnyMacro<'a, 'b> {
104104
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
105105
parser.token.span,
106106
lint_node_id,
107-
errors::TrailingMacro { is_trailing: is_trailing_mac, name: macro_ident },
107+
diagnostics::TrailingMacro { is_trailing: is_trailing_mac, name: macro_ident },
108108
);
109109
}
110110
parser.bump();
@@ -903,9 +903,9 @@ fn check_args_parens(sess: &Session, rule_kw: Symbol, args: &tokenstream::TokenT
903903
if let tokenstream::TokenTree::Delimited(dspan, _, delim, _) = args
904904
&& *delim != Delimiter::Parenthesis
905905
{
906-
sess.dcx().emit_err(errors::MacroArgsBadDelim {
906+
sess.dcx().emit_err(diagnostics::MacroArgsBadDelim {
907907
span: dspan.entire(),
908-
sugg: errors::MacroArgsBadDelimSugg { open: dspan.open, close: dspan.close },
908+
sugg: diagnostics::MacroArgsBadDelimSugg { open: dspan.open, close: dspan.close },
909909
rule_kw,
910910
});
911911
}
@@ -1539,7 +1539,7 @@ fn check_matcher_core<'tt>(
15391539
RUST_2021_INCOMPATIBLE_OR_PATTERNS,
15401540
span,
15411541
ast::CRATE_NODE_ID,
1542-
errors::OrPatternsBackCompat { span, suggestion },
1542+
diagnostics::OrPatternsBackCompat { span, suggestion },
15431543
);
15441544
}
15451545
match is_in_follow(next_token, kind) {

compiler/rustc_expand/src/mbe/metavar_expr.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_macros::{Decodable, Encodable};
77
use rustc_session::parse::ParseSess;
88
use rustc_span::{Ident, Span, Symbol, sym};
99

10-
use crate::errors;
10+
use crate::diagnostics;
1111

1212
pub(crate) const RAW_IDENT_ERR: &str = "`${concat(..)}` currently does not support raw identifiers";
1313
pub(crate) const UNSUPPORTED_CONCAT_ELEM_ERR: &str = "expected identifier or string literal";
@@ -51,15 +51,18 @@ impl MetaVarExpr {
5151
Some(tt) => (Some(tt.span()), None),
5252
None => (None, Some(ident.span.shrink_to_hi())),
5353
};
54-
let err =
55-
errors::MveMissingParen { ident_span: ident.span, unexpected_span, insert_span };
54+
let err = diagnostics::MveMissingParen {
55+
ident_span: ident.span,
56+
unexpected_span,
57+
insert_span,
58+
};
5659
return Err(psess.dcx().create_err(err));
5760
};
5861

5962
// Ensure there are no trailing tokens in the braces, e.g. `${foo() extra}`
6063
if iter.peek().is_some() {
6164
let span = iter_span(&iter).expect("checked is_some above");
62-
let err = errors::MveExtraTokens {
65+
let err = diagnostics::MveExtraTokens {
6366
span,
6467
ident_span: ident.span,
6568
extra_count: iter.count(),
@@ -79,7 +82,7 @@ impl MetaVarExpr {
7982
sym::index => MetaVarExpr::Index(parse_depth(&mut iter, psess, ident.span)?),
8083
sym::len => MetaVarExpr::Len(parse_depth(&mut iter, psess, ident.span)?),
8184
_ => {
82-
let err = errors::MveUnrecognizedExpr {
85+
let err = diagnostics::MveUnrecognizedExpr {
8386
span: ident.span,
8487
valid_expr_list: "`count`, `ignore`, `index`, `len`, and `concat`",
8588
};
@@ -129,7 +132,7 @@ fn check_trailing_tokens<'psess>(
129132
other => unreachable!("unknown MVEs should be rejected earlier (got `{other}`)"),
130133
};
131134

132-
let err = errors::MveExtraTokens {
135+
let err = diagnostics::MveExtraTokens {
133136
span: iter_span(iter).expect("checked is_none above"),
134137
ident_span: ident.span,
135138
extra_count: iter.count(),

compiler/rustc_expand/src/mbe/quoted.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_session::errors::feature_err;
99
use rustc_span::edition::Edition;
1010
use rustc_span::{Ident, Span, kw, sym};
1111

12-
use crate::errors;
12+
use crate::diagnostics;
1313
use crate::mbe::macro_parser::count_metavar_decls;
1414
use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree};
1515

@@ -94,7 +94,7 @@ fn parse(
9494
// Emit a missing-fragment diagnostic and return a `TokenTree` fallback so parsing can
9595
// continue.
9696
let missing_fragment_specifier = |span, add_span| {
97-
sess.dcx().emit_err(errors::MissingFragmentSpecifier {
97+
sess.dcx().emit_err(diagnostics::MissingFragmentSpecifier {
9898
span,
9999
add_span,
100100
valid: VALID_FRAGMENT_NAMES_MSG,
@@ -163,7 +163,7 @@ fn parse(
163163
if !span.from_expansion() { edition } else { span.edition() }
164164
};
165165
let kind = NonterminalKind::from_symbol(fragment.name, edition).unwrap_or_else(|| {
166-
sess.dcx().emit_err(errors::InvalidFragmentSpecifier {
166+
sess.dcx().emit_err(diagnostics::InvalidFragmentSpecifier {
167167
span,
168168
fragment,
169169
help: VALID_FRAGMENT_NAMES_MSG,
@@ -299,7 +299,7 @@ fn parse_tree<'a>(
299299
_ => {
300300
let token =
301301
pprust::token_kind_to_string(&delim.as_open_token_kind());
302-
sess.dcx().emit_err(errors::ExpectedParenOrBrace {
302+
sess.dcx().emit_err(diagnostics::ExpectedParenOrBrace {
303303
span: delim_span.entire(),
304304
token,
305305
});

compiler/rustc_expand/src/mbe/transcribe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_span::{
1717
};
1818
use smallvec::{SmallVec, smallvec};
1919

20-
use crate::errors::{
20+
use crate::diagnostics::{
2121
ConcatInvalidIdent, CountRepetitionMisplaced, InvalidIdentReason, MacroVarStillRepeating,
2222
MetaVarsDifSeqMatchers, MustRepeatOnce, MveUnrecognizedVar, NoRepeatableVar,
2323
NoSyntaxVarsExprRepeat, VarNoTypo, VarTypoSuggestionRepeatable, VarTypoSuggestionUnrepeatable,

0 commit comments

Comments
 (0)