Skip to content

Commit d9e23bd

Browse files
committed
rustc_lint_defs: Eliminate the dependency on rustc_hir for Namespace
`rustc_lint_defs` uses `rustc_hir` solely for the `Namespace` type, which it only needs the static description from. Use the static description directly, to eliminate the dependency on `rustc_hir`. This reduces a long dependency chain: - Many things depend on `rustc_errors` - `rustc_errors` depends on `rustc_lint_defs` - `rustc_lint_defs` depended on `rustc_hir` prior to this commit - `rustc_hir` depends on `rustc_target`
1 parent 1e8f743 commit d9e23bd

File tree

7 files changed

+10
-12
lines changed

7 files changed

+10
-12
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4137,7 +4137,6 @@ dependencies = [
41374137
"rustc_ast",
41384138
"rustc_data_structures",
41394139
"rustc_error_messages",
4140-
"rustc_hir",
41414140
"rustc_hir_id",
41424141
"rustc_macros",
41434142
"rustc_serialize",

compiler/rustc_lint/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ lint_pattern_in_foreign = patterns aren't allowed in foreign function declaratio
732732
lint_private_extern_crate_reexport = extern crate `{$ident}` is private and cannot be re-exported
733733
.suggestion = consider making the `extern crate` item publicly accessible
734734
735-
lint_proc_macro_derive_resolution_fallback = cannot find {$ns} `{$ident}` in this scope
735+
lint_proc_macro_derive_resolution_fallback = cannot find {$ns_descr} `{$ident}` in this scope
736736
.label = names from parent modules are not accessible without an explicit import
737737
738738
lint_query_instability = using `{$query}` can result in unstable query results

compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ pub fn decorate_builtin_lint(
6464
}
6565
.decorate_lint(diag);
6666
}
67-
BuiltinLintDiag::ProcMacroDeriveResolutionFallback { span: macro_span, ns, ident } => {
68-
lints::ProcMacroDeriveResolutionFallback { span: macro_span, ns, ident }
69-
.decorate_lint(diag)
70-
}
67+
BuiltinLintDiag::ProcMacroDeriveResolutionFallback {
68+
span: macro_span,
69+
ns_descr,
70+
ident,
71+
} => lints::ProcMacroDeriveResolutionFallback { span: macro_span, ns_descr, ident }
72+
.decorate_lint(diag),
7173
BuiltinLintDiag::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => {
7274
lints::MacroExpandedMacroExportsAccessedByAbsolutePaths { definition: span_def }
7375
.decorate_lint(diag)

compiler/rustc_lint/src/lints.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_errors::{
88
EmissionGuarantee, LintDiagnostic, MultiSpan, Subdiagnostic, SuggestionStyle,
99
};
1010
use rustc_hir as hir;
11-
use rustc_hir::def::Namespace;
1211
use rustc_hir::def_id::DefId;
1312
use rustc_hir::intravisit::VisitorExt;
1413
use rustc_macros::{LintDiagnostic, Subdiagnostic};
@@ -2769,7 +2768,7 @@ pub(crate) struct AbsPathWithModuleSugg {
27692768
pub(crate) struct ProcMacroDeriveResolutionFallback {
27702769
#[label]
27712770
pub span: Span,
2772-
pub ns: Namespace,
2771+
pub ns_descr: &'static str,
27732772
pub ident: Ident,
27742773
}
27752774

compiler/rustc_lint_defs/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ rustc_abi = { path = "../rustc_abi" }
99
rustc_ast = { path = "../rustc_ast" }
1010
rustc_data_structures = { path = "../rustc_data_structures" }
1111
rustc_error_messages = { path = "../rustc_error_messages" }
12-
rustc_hir = { path = "../rustc_hir" }
1312
rustc_hir_id = { path = "../rustc_hir_id" }
1413
rustc_macros = { path = "../rustc_macros" }
1514
rustc_serialize = { path = "../rustc_serialize" }

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_data_structures::stable_hasher::{
99
HashStable, StableCompare, StableHasher, ToStableHashKey,
1010
};
1111
use rustc_error_messages::{DiagArgValue, DiagMessage, IntoDiagArg, MultiSpan};
12-
use rustc_hir::def::Namespace;
1312
use rustc_hir_id::{HashStableContext, HirId, ItemLocalId};
1413
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
1514
use rustc_span::def_id::DefPathHash;
@@ -625,7 +624,7 @@ pub enum BuiltinLintDiag {
625624
AbsPathWithModule(Span),
626625
ProcMacroDeriveResolutionFallback {
627626
span: Span,
628-
ns: Namespace,
627+
ns_descr: &'static str,
629628
ident: Ident,
630629
},
631630
MacroExpandedMacroExportsAccessedByAbsolutePaths(Span),

compiler/rustc_resolve/src/ident.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
538538
orig_ident.span,
539539
BuiltinLintDiag::ProcMacroDeriveResolutionFallback {
540540
span: orig_ident.span,
541-
ns,
541+
ns_descr: ns.descr(),
542542
ident,
543543
},
544544
);

0 commit comments

Comments
 (0)