diff options
| author | Oli Scherer <github333195615777966@oli-obk.de> | 2025-04-11 09:52:47 +0000 |
|---|---|---|
| committer | Oli Scherer <github333195615777966@oli-obk.de> | 2025-04-11 10:04:27 +0000 |
| commit | 33a6820c2f3087e1fc5b69a2367b6d3528b767b9 (patch) | |
| tree | 3c4e1168bbdc240adb5185b8d5d8ccfca2f66276 /compiler/rustc_resolve/src | |
| parent | f5c60f616f13e1267c1eb4df94a5a9c23c18b997 (diff) | |
| download | rust-33a6820c2f3087e1fc5b69a2367b6d3528b767b9.tar.gz rust-33a6820c2f3087e1fc5b69a2367b6d3528b767b9.zip | |
Avoid storing the `LocalDefId` twice
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/build_reduced_graph.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/macros.rs | 8 |
3 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 99c5cadd634..cb328022c76 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -1209,7 +1209,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { .unused_macro_rules .entry(node_id) .or_default() - .insert(*rule_i, (ident, *rule_span, def_id)); + .insert(*rule_i, (ident, *rule_span)); } } } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 1815dd7d6c8..f6d67b67518 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1140,7 +1140,7 @@ pub struct Resolver<'ra, 'tcx> { ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>, unused_macros: FxIndexMap<LocalDefId, (NodeId, Ident)>, /// A map from the macro to all its potentially unused arms. - unused_macro_rules: FxIndexMap<NodeId, UnordMap<usize, (Ident, Span, LocalDefId)>>, + unused_macro_rules: FxIndexMap<NodeId, UnordMap<usize, (Ident, Span)>>, proc_macro_stubs: FxHashSet<LocalDefId>, /// Traces collected during macro resolution and validated when it's complete. single_segment_macro_resolutions: diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 47e5d366107..aee6acd7725 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -336,14 +336,12 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> { ident.span, BuiltinLintDiag::UnusedMacroDefinition(ident.name), ); + // Do not report unused individual rules if the entire macro is unused + self.unused_macro_rules.swap_remove(&node_id); } for (&node_id, unused_arms) in self.unused_macro_rules.iter() { - for (&arm_i, &(ident, rule_span, def_id)) in unused_arms.to_sorted_stable_ord() { - if self.unused_macros.contains_key(&def_id) { - // We already lint the entire macro as unused - continue; - } + for (&arm_i, &(ident, rule_span)) in unused_arms.to_sorted_stable_ord() { self.lint_buffer.buffer_lint( UNUSED_MACRO_RULES, node_id, |
