Skip to content

Commit c40fa00

Browse files
committed
Auto merge of rust-lang#7022 - Jarcho:macro_use_import_ice, r=flip1995
Fix `macro_use_import` ICE fixes: rust-lang#7015 changelog: Fix `macro_use_import` ICE
2 parents b40ea20 + c05760f commit c40fa00

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

clippy_lints/src/macro_use.rs

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
112112
let attrs = cx.tcx.hir().attrs(item.hir_id());
113113
if let Some(mac_attr) = attrs.iter().find(|attr| attr.has_name(sym::macro_use));
114114
if let Res::Def(DefKind::Mod, id) = path.res;
115+
if !id.is_local();
115116
then {
116117
for kid in cx.tcx.item_children(id).iter() {
117118
if let Res::Def(DefKind::Macro(_mac_type), mac_id) = kid.res {

tests/ui/macro_use_imports.fixed

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// run-rustfix
55
// ignore-32bit
66

7-
#![allow(unused_imports, unreachable_code, unused_variables, dead_code)]
7+
#![allow(unused_imports, unreachable_code, unused_variables, dead_code, unused_attributes)]
88
#![allow(clippy::single_component_path_imports)]
99
#![warn(clippy::macro_use_imports)]
1010

@@ -40,4 +40,8 @@ mod a {
4040
}
4141
}
4242

43+
// issue #7015, ICE due to calling `item_children` with local `DefId`
44+
#[macro_use]
45+
use a as b;
46+
4347
fn main() {}

tests/ui/macro_use_imports.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// run-rustfix
55
// ignore-32bit
66

7-
#![allow(unused_imports, unreachable_code, unused_variables, dead_code)]
7+
#![allow(unused_imports, unreachable_code, unused_variables, dead_code, unused_attributes)]
88
#![allow(clippy::single_component_path_imports)]
99
#![warn(clippy::macro_use_imports)]
1010

@@ -40,4 +40,8 @@ mod a {
4040
}
4141
}
4242

43+
// issue #7015, ICE due to calling `item_children` with local `DefId`
44+
#[macro_use]
45+
use a as b;
46+
4347
fn main() {}

0 commit comments

Comments
 (0)