Skip to content

Commit d15ec0f

Browse files
committed
Refactor crate_in_macro_def:
* Don't clone the token stream * Check the HIR tree before reading attributes
1 parent 1f530ab commit d15ec0f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

clippy_lints/src/crate_in_macro_def.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ declare_lint_pass!(CrateInMacroDef => [CRATE_IN_MACRO_DEF]);
5353

5454
impl EarlyLintPass for CrateInMacroDef {
5555
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
56-
if item.attrs.iter().any(is_macro_export)
57-
&& let ItemKind::MacroDef(macro_def) = &item.kind
58-
&& let tts = macro_def.body.tokens.clone()
59-
&& let Some(span) = contains_unhygienic_crate_reference(&tts)
56+
if let ItemKind::MacroDef(macro_def) = &item.kind
57+
&& item.attrs.iter().any(is_macro_export)
58+
&& let Some(span) = contains_unhygienic_crate_reference(&macro_def.body.tokens)
6059
{
6160
span_lint_and_sugg(
6261
cx,

0 commit comments

Comments
 (0)