Skip to content

Commit

Permalink
Auto merge of #7022 - Jarcho:macro_use_import_ice, r=flip1995
Browse files Browse the repository at this point in the history
Fix `macro_use_import` ICE

fixes: #7015
changelog: Fix `macro_use_import` ICE
  • Loading branch information
bors committed Apr 8, 2021
2 parents b40ea20 + c05760f commit c40fa00
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions clippy_lints/src/macro_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
let attrs = cx.tcx.hir().attrs(item.hir_id());
if let Some(mac_attr) = attrs.iter().find(|attr| attr.has_name(sym::macro_use));
if let Res::Def(DefKind::Mod, id) = path.res;
if !id.is_local();
then {
for kid in cx.tcx.item_children(id).iter() {
if let Res::Def(DefKind::Macro(_mac_type), mac_id) = kid.res {
Expand Down
6 changes: 5 additions & 1 deletion tests/ui/macro_use_imports.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// run-rustfix
// ignore-32bit

#![allow(unused_imports, unreachable_code, unused_variables, dead_code)]
#![allow(unused_imports, unreachable_code, unused_variables, dead_code, unused_attributes)]
#![allow(clippy::single_component_path_imports)]
#![warn(clippy::macro_use_imports)]

Expand Down Expand Up @@ -40,4 +40,8 @@ mod a {
}
}

// issue #7015, ICE due to calling `item_children` with local `DefId`
#[macro_use]
use a as b;

fn main() {}
6 changes: 5 additions & 1 deletion tests/ui/macro_use_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// run-rustfix
// ignore-32bit

#![allow(unused_imports, unreachable_code, unused_variables, dead_code)]
#![allow(unused_imports, unreachable_code, unused_variables, dead_code, unused_attributes)]
#![allow(clippy::single_component_path_imports)]
#![warn(clippy::macro_use_imports)]

Expand Down Expand Up @@ -40,4 +40,8 @@ mod a {
}
}

// issue #7015, ICE due to calling `item_children` with local `DefId`
#[macro_use]
use a as b;

fn main() {}

0 comments on commit c40fa00

Please sign in to comment.