Auto merge of #7022 - Jarcho:macro_use_import_ice, r=flip1995

Fix `macro_use_import` ICE

fixes: #7015
changelog: Fix `macro_use_import` ICE
This commit is contained in:
bors 2021-04-08 16:04:55 +00:00
commit c40fa00113
3 changed files with 11 additions and 2 deletions

View File

@ -112,6 +112,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
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 {

View File

@ -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)]
@ -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() {}

View File

@ -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)]
@ -40,4 +40,8 @@ fn test() {
}
}
// issue #7015, ICE due to calling `item_children` with local `DefId`
#[macro_use]
use a as b;
fn main() {}