mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Refactor crate_in_macro_def
:
* Don't clone the token stream * Check the HIR tree before reading attributes
This commit is contained in:
parent
1f530ab7e2
commit
d15ec0ff85
1 changed files with 3 additions and 4 deletions
|
@ -53,10 +53,9 @@ declare_lint_pass!(CrateInMacroDef => [CRATE_IN_MACRO_DEF]);
|
|||
|
||||
impl EarlyLintPass for CrateInMacroDef {
|
||||
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
|
||||
if item.attrs.iter().any(is_macro_export)
|
||||
&& let ItemKind::MacroDef(macro_def) = &item.kind
|
||||
&& let tts = macro_def.body.tokens.clone()
|
||||
&& let Some(span) = contains_unhygienic_crate_reference(&tts)
|
||||
if let ItemKind::MacroDef(macro_def) = &item.kind
|
||||
&& item.attrs.iter().any(is_macro_export)
|
||||
&& let Some(span) = contains_unhygienic_crate_reference(¯o_def.body.tokens)
|
||||
{
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
|
|
Loading…
Reference in a new issue