Skip to content

Commit 0feb5df

Browse files
Rollup merge of #157974 - GuillaumeGomez:rename-err-to-diag, r=JonathanBrouwer
Rename `errors.rs` file to `diagnostics.rs` (11/N) Follow-up of #157485. This one is a bit different than the previous ones: it had both `diagnostics.rs` and `errors.rs` files, but both were switched compared to what the other compiler crates do (for `diagnostics.rs` in particular). So first we switched the two files, and then, to avoid confusion between `errors.rs` and `diagnostics.rs`, I renamed `errors.rs` into `error_helper.rs`. r? @JonathanBrouwer
2 parents a7333a6 + 4f6a600 commit 0feb5df

11 files changed

Lines changed: 5692 additions & 5626 deletions

File tree

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ use tracing::debug;
3131

3232
use crate::Namespace::{MacroNS, TypeNS, ValueNS};
3333
use crate::def_collector::DefCollector;
34-
use crate::diagnostics::StructCtor;
34+
use crate::error_helper::StructCtor;
3535
use crate::imports::{ImportData, ImportKind, OnUnknownData};
3636
use crate::macros::{MacroRulesDecl, MacroRulesScope, MacroRulesScopeRef};
3737
use crate::ref_mut::CmCell;
3838
use crate::{
3939
BindingKey, Decl, DeclData, DeclKind, DelayedVisResolutionError, ExternModule,
4040
ExternPreludeEntry, Finalize, IdentKey, LocalModule, Module, ModuleKind, ModuleOrUniformRoot,
41-
ParentScope, PathResult, Res, Resolver, Segment, Used, VisResolutionError, errors,
41+
ParentScope, PathResult, Res, Resolver, Segment, Used, VisResolutionError, diagnostics,
4242
};
4343

4444
impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
@@ -706,9 +706,9 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
706706
// Deny importing path-kw without renaming
707707
if rename.is_none() && ident.is_path_segment_keyword() {
708708
let ident = use_tree.ident();
709-
self.r.dcx().emit_err(errors::UnnamedImport {
709+
self.r.dcx().emit_err(diagnostics::UnnamedImport {
710710
span: ident.span,
711-
sugg: errors::UnnamedImportSugg { span: ident.span, ident },
711+
sugg: diagnostics::UnnamedImportSugg { span: ident.span, ident },
712712
});
713713
return;
714714
}
@@ -996,7 +996,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
996996
let expansion = parent_scope.expansion;
997997

998998
let (used, module, decl) = if orig_name.is_none() && orig_ident.name == kw::SelfLower {
999-
self.r.dcx().emit_err(errors::ExternCrateSelfRequiresRenaming { span: sp });
999+
self.r.dcx().emit_err(diagnostics::ExternCrateSelfRequiresRenaming { span: sp });
10001000
return;
10011001
} else if orig_name == Some(kw::SelfLower) {
10021002
Some(self.r.graph_root.to_module())
@@ -1054,7 +1054,9 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
10541054
&& entry.item_decl.is_none()
10551055
{
10561056
self.r.dcx().emit_err(
1057-
errors::MacroExpandedExternCrateCannotShadowExternArguments { span: item.span },
1057+
diagnostics::MacroExpandedExternCrateCannotShadowExternArguments {
1058+
span: item.span,
1059+
},
10581060
);
10591061
}
10601062

@@ -1125,7 +1127,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
11251127
allow_shadowing: bool,
11261128
) {
11271129
if self.r.macro_use_prelude.insert(name, decl).is_some() && !allow_shadowing {
1128-
self.r.dcx().emit_err(errors::MacroUseNameAlreadyInUse { span, name });
1130+
self.r.dcx().emit_err(diagnostics::MacroUseNameAlreadyInUse { span, name });
11291131
}
11301132
}
11311133

@@ -1137,14 +1139,14 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
11371139
AttributeParser::parse_limited(self.r.tcx.sess, &item.attrs, &[sym::macro_use])
11381140
{
11391141
if self.parent_scope.module.expect_local().parent.is_some() {
1140-
self.r
1141-
.dcx()
1142-
.emit_err(errors::ExternCrateLoadingMacroNotAtCrateRoot { span: item.span });
1142+
self.r.dcx().emit_err(diagnostics::ExternCrateLoadingMacroNotAtCrateRoot {
1143+
span: item.span,
1144+
});
11431145
}
11441146
if let ItemKind::ExternCrate(Some(orig_name), _) = item.kind
11451147
&& orig_name == kw::SelfLower
11461148
{
1147-
self.r.dcx().emit_err(errors::MacroUseExternCrateSelf { span });
1149+
self.r.dcx().emit_err(diagnostics::MacroUseExternCrateSelf { span });
11481150
}
11491151

11501152
match arguments {
@@ -1208,7 +1210,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
12081210
let import_decl = self.r.new_import_decl(binding, import);
12091211
self.add_macro_use_decl(ident.name, import_decl, ident.span, allow_shadowing);
12101212
} else {
1211-
self.r.dcx().emit_err(errors::ImportedMacroNotFound { span: ident.span });
1213+
self.r.dcx().emit_err(diagnostics::ImportedMacroNotFound { span: ident.span });
12121214
}
12131215
}
12141216
}
@@ -1220,15 +1222,16 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
12201222
for attr in attrs {
12211223
if attr.has_name(sym::macro_escape) {
12221224
let inner_attribute = matches!(attr.style, ast::AttrStyle::Inner);
1223-
self.r
1224-
.dcx()
1225-
.emit_warn(errors::MacroExternDeprecated { span: attr.span, inner_attribute });
1225+
self.r.dcx().emit_warn(diagnostics::MacroExternDeprecated {
1226+
span: attr.span,
1227+
inner_attribute,
1228+
});
12261229
} else if !attr.has_name(sym::macro_use) {
12271230
continue;
12281231
}
12291232

12301233
if !attr.is_word() {
1231-
self.r.dcx().emit_err(errors::ArgumentsMacroUseNotAllowed { span: attr.span });
1234+
self.r.dcx().emit_err(diagnostics::ArgumentsMacroUseNotAllowed { span: attr.span });
12321235
}
12331236
return true;
12341237
}

compiler/rustc_resolve/src/check_unused.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use rustc_session::lint::builtin::{
3838
use rustc_span::{DUMMY_SP, Ident, Span, kw};
3939

4040
use crate::imports::{Import, ImportKind};
41-
use crate::{DeclKind, IdentKey, LateDecl, Resolver, errors, module_to_string};
41+
use crate::{DeclKind, IdentKey, LateDecl, Resolver, diagnostics, module_to_string};
4242

4343
struct UnusedImport {
4444
use_tree: ast::UseTree,
@@ -170,7 +170,7 @@ impl<'a, 'ra, 'tcx> UnusedImportCheckVisitor<'a, 'ra, 'tcx> {
170170
UNUSED_EXTERN_CRATES,
171171
extern_crate.id,
172172
span,
173-
crate::errors::UnusedExternCrate {
173+
crate::diagnostics::UnusedExternCrate {
174174
span: extern_crate.span,
175175
removal_span: extern_crate.span_with_attributes,
176176
},
@@ -234,7 +234,7 @@ impl<'a, 'ra, 'tcx> UnusedImportCheckVisitor<'a, 'ra, 'tcx> {
234234
UNUSED_EXTERN_CRATES,
235235
extern_crate.id,
236236
extern_crate.span,
237-
crate::errors::ExternCrateNotIdiomatic {
237+
crate::diagnostics::ExternCrateNotIdiomatic {
238238
span: vis_span.between(ident_span),
239239
code: if vis_span.is_empty() { "use " } else { " use " },
240240
},
@@ -426,7 +426,7 @@ impl Resolver<'_, '_> {
426426
MACRO_USE_EXTERN_CRATE,
427427
import.root_id,
428428
import.span,
429-
crate::errors::MacroUseDeprecated,
429+
crate::diagnostics::MacroUseDeprecated,
430430
);
431431
}
432432
}
@@ -450,7 +450,7 @@ impl Resolver<'_, '_> {
450450
UNUSED_IMPORTS,
451451
import.root_id,
452452
import.span,
453-
crate::errors::UnusedMacroUse,
453+
crate::diagnostics::UnusedMacroUse,
454454
);
455455
}
456456
_ => {}
@@ -524,9 +524,12 @@ impl Resolver<'_, '_> {
524524
move |dcx, level, sess| {
525525
let sugg = can_suggest_removal.then(|| {
526526
if remove_whole_use {
527-
errors::UnusedImportsSugg::RemoveWholeUse { span: remove_spans[0] }
527+
diagnostics::UnusedImportsSugg::RemoveWholeUse { span: remove_spans[0] }
528528
} else {
529-
errors::UnusedImportsSugg::RemoveImports { remove_spans, num_to_remove }
529+
diagnostics::UnusedImportsSugg::RemoveImports {
530+
remove_spans,
531+
num_to_remove,
532+
}
530533
}
531534
});
532535
let test_module_span = test_module_span.map(|span| {
@@ -536,7 +539,7 @@ impl Resolver<'_, '_> {
536539
.guess_head_span(span)
537540
});
538541

539-
errors::UnusedImports {
542+
diagnostics::UnusedImports {
540543
sugg,
541544
test_module_span,
542545
num_snippets: span_snippets.len(),
@@ -593,7 +596,7 @@ impl Resolver<'_, '_> {
593596
UNUSED_QUALIFICATIONS,
594597
unn_qua.node_id,
595598
unn_qua.path_span,
596-
errors::UnusedQualifications { removal_span: unn_qua.removal_span },
599+
diagnostics::UnusedQualifications { removal_span: unn_qua.removal_span },
597600
);
598601
}
599602

0 commit comments

Comments
 (0)