Skip to content

Commit cf5748f

Browse files
committed
Make AnonConst in asm_consts generic
1 parent 77652b9 commit cf5748f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler/rustc_typeck/src/collect.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,18 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
15581558
Node::Expr(&Expr { kind: ExprKind::ConstBlock(_), .. }) => {
15591559
Some(tcx.typeck_root_def_id(def_id))
15601560
}
1561+
// Exclude `GlobalAsm` here which cannot have generics.
1562+
Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. })
1563+
if asm.operands.iter().any(|(op, _op_sp)| match op {
1564+
hir::InlineAsmOperand::Const { anon_const }
1565+
| hir::InlineAsmOperand::SymFn { anon_const } => {
1566+
anon_const.hir_id == hir_id
1567+
}
1568+
_ => false,
1569+
}) =>
1570+
{
1571+
Some(parent_def_id.to_def_id())
1572+
}
15611573
_ => None,
15621574
}
15631575
}

0 commit comments

Comments
 (0)