global_asm! consts do not depend on other items

This commit is contained in:
Amanieu d'Antras
2021-04-26 20:27:27 +01:00
parent bb6bec1d55
commit 40d9da4d8c

View File

@@ -397,13 +397,10 @@ fn collect_items_rec<'tcx>(
if let hir::ItemKind::GlobalAsm(asm) = item.kind { if let hir::ItemKind::GlobalAsm(asm) = item.kind {
for (op, op_sp) in asm.operands { for (op, op_sp) in asm.operands {
match op { match op {
hir::InlineAsmOperand::Const { ref anon_const } => { hir::InlineAsmOperand::Const { .. } => {
// Treat these the same way as ItemKind::Const // Only constants which resolve to a plain integer
let anon_const_def_id = // are supported. Therefore the value should not
tcx.hir().local_def_id(anon_const.hir_id).to_def_id(); // depend on any other items.
if let Ok(val) = tcx.const_eval_poly(anon_const_def_id) {
collect_const_value(tcx, val, &mut neighbors);
}
} }
_ => span_bug!(*op_sp, "invalid operand type for global_asm!"), _ => span_bug!(*op_sp, "invalid operand type for global_asm!"),
} }