Skip to content

Commit 0116942

Browse files
committed
Collect constants within global_asm! in collector
This is currently a no-op, but will be useful when const in `global_asm!` can be pointers.
1 parent 0208ee0 commit 0116942

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

compiler/rustc_monomorphize/src/collector.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,10 +508,18 @@ fn collect_items_rec<'tcx>(
508508
if let hir::ItemKind::GlobalAsm { asm, .. } = item.kind {
509509
for (op, op_sp) in asm.operands {
510510
match *op {
511-
hir::InlineAsmOperand::Const { .. } => {
512-
// Only constants which resolve to a plain integer
513-
// are supported. Therefore the value should not
514-
// depend on any other items.
511+
hir::InlineAsmOperand::Const { anon_const } => {
512+
match tcx.const_eval_poly(anon_const.def_id.to_def_id()) {
513+
Ok(val) => {
514+
collect_const_value(tcx, val, &mut used_items);
515+
}
516+
Err(ErrorHandled::TooGeneric(..)) => {
517+
span_bug!(*op_sp, "asm const cannot be resolved; too generic")
518+
}
519+
Err(ErrorHandled::Reported(..)) => {
520+
continue;
521+
}
522+
}
515523
}
516524
hir::InlineAsmOperand::SymFn { expr } => {
517525
let fn_ty = tcx.typeck(item_id.owner_id).expr_ty(expr);

0 commit comments

Comments
 (0)