Collect function instance used in global_asm! sym operand

The constants used in SymFn operands have FnDef type,
so the type of the constant identifies the function.
This commit is contained in:
Tomasz Miąsko 2022-05-02 00:00:00 +00:00
parent 24c8985043
commit e62663492b
2 changed files with 8 additions and 6 deletions

View file

@ -445,12 +445,9 @@ fn collect_items_rec<'tcx>(
// depend on any other items.
}
hir::InlineAsmOperand::SymFn { anon_const } => {
let def_id = tcx.hir().body_owner_def_id(anon_const.body).to_def_id();
if let Ok(val) = tcx.const_eval_poly(def_id) {
rustc_data_structures::stack::ensure_sufficient_stack(|| {
collect_const_value(tcx, val, &mut neighbors);
});
}
let fn_ty =
tcx.typeck_body(anon_const.body).node_type(anon_const.hir_id);
visit_fn_use(tcx, fn_ty, false, *op_sp, &mut neighbors);
}
hir::InlineAsmOperand::SymStatic { path: _, def_id } => {
let instance = Instance::mono(tcx, *def_id);