Avoid storing the LocalDefId
twice
This commit is contained in:
parent
f5c60f616f
commit
33a6820c2f
3 changed files with 5 additions and 7 deletions
|
@ -1209,7 +1209,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
|
||||||
.unused_macro_rules
|
.unused_macro_rules
|
||||||
.entry(node_id)
|
.entry(node_id)
|
||||||
.or_default()
|
.or_default()
|
||||||
.insert(*rule_i, (ident, *rule_span, def_id));
|
.insert(*rule_i, (ident, *rule_span));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1140,7 +1140,7 @@ pub struct Resolver<'ra, 'tcx> {
|
||||||
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
|
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
|
||||||
unused_macros: FxIndexMap<LocalDefId, (NodeId, Ident)>,
|
unused_macros: FxIndexMap<LocalDefId, (NodeId, Ident)>,
|
||||||
/// A map from the macro to all its potentially unused arms.
|
/// 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>,
|
proc_macro_stubs: FxHashSet<LocalDefId>,
|
||||||
/// Traces collected during macro resolution and validated when it's complete.
|
/// Traces collected during macro resolution and validated when it's complete.
|
||||||
single_segment_macro_resolutions:
|
single_segment_macro_resolutions:
|
||||||
|
|
|
@ -336,14 +336,12 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
|
||||||
ident.span,
|
ident.span,
|
||||||
BuiltinLintDiag::UnusedMacroDefinition(ident.name),
|
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 (&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() {
|
for (&arm_i, &(ident, rule_span)) in unused_arms.to_sorted_stable_ord() {
|
||||||
if self.unused_macros.contains_key(&def_id) {
|
|
||||||
// We already lint the entire macro as unused
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
self.lint_buffer.buffer_lint(
|
self.lint_buffer.buffer_lint(
|
||||||
UNUSED_MACRO_RULES,
|
UNUSED_MACRO_RULES,
|
||||||
node_id,
|
node_id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue