Skip to content

Commit c05760f

Browse files
committed
Fix macro_use_import ICE
1 parent 86fb0e8 commit c05760f

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

clippy_lints/src/macro_use.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
114114
.iter()
115115
.find(|attr| attr.ident().map(|s| s.to_string()) == Some("macro_use".to_string()));
116116
if let Res::Def(DefKind::Mod, id) = path.res;
117+
if !id.is_local();
117118
then {
118119
for kid in cx.tcx.item_children(id).iter() {
119120
if let Res::Def(DefKind::Macro(_mac_type), mac_id) = kid.res {

tests/ui/macro_use_imports.fixed

Lines changed: 5 additions & 1 deletion
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

Lines changed: 5 additions & 1 deletion
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)