mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-04 01:42:54 +03:00
Ports #[macro_use] and #[macro_escape] to the new attribute parsing infrastructure
This commit is contained in:
@@ -7,8 +7,9 @@
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::impl_lint_pass;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::{Span, sym};
|
||||
use rustc_span::{Span};
|
||||
use std::collections::BTreeMap;
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
@@ -99,15 +100,14 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
|
||||
&& let hir::ItemKind::Use(path, _kind) = &item.kind
|
||||
&& let hir_id = item.hir_id()
|
||||
&& let attrs = cx.tcx.hir_attrs(hir_id)
|
||||
&& let Some(mac_attr) = attrs.iter().find(|attr| attr.has_name(sym::macro_use))
|
||||
&& let Some(mac_attr_span) = find_attr!(attrs, AttributeKind::MacroUse {span, ..} => *span)
|
||||
&& let Some(Res::Def(DefKind::Mod, id)) = path.res.type_ns
|
||||
&& !id.is_local()
|
||||
{
|
||||
for kid in cx.tcx.module_children(id) {
|
||||
if let Res::Def(DefKind::Macro(_mac_type), mac_id) = kid.res {
|
||||
let span = mac_attr.span();
|
||||
let def_path = cx.tcx.def_path_str(mac_id);
|
||||
self.imports.push((def_path, span, hir_id));
|
||||
self.imports.push((def_path, mac_attr_span, hir_id));
|
||||
}
|
||||
}
|
||||
} else if item.span.from_expansion() {
|
||||
|
||||
Reference in New Issue
Block a user