diff options
| author | Gary Guo <gary@garyguo.net> | 2022-05-07 02:55:13 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2022-05-07 03:32:27 +0100 |
| commit | cf5748f43f3796732248fc90a404b6fe6cb05ce3 (patch) | |
| tree | 5c8e236a5c0bd941ac855ee311a7338e20b3fb55 | |
| parent | 77652b9ef3fc98e2df0e260efedb80aa68c08c06 (diff) | |
| download | rust-cf5748f43f3796732248fc90a404b6fe6cb05ce3.tar.gz rust-cf5748f43f3796732248fc90a404b6fe6cb05ce3.zip | |
Make `AnonConst` in asm_consts generic
| -rw-r--r-- | compiler/rustc_typeck/src/collect.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index c1c63c46066..d083c872d2c 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -1558,6 +1558,18 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics { Node::Expr(&Expr { kind: ExprKind::ConstBlock(_), .. }) => { Some(tcx.typeck_root_def_id(def_id)) } + // Exclude `GlobalAsm` here which cannot have generics. + Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. }) + if asm.operands.iter().any(|(op, _op_sp)| match op { + hir::InlineAsmOperand::Const { anon_const } + | hir::InlineAsmOperand::SymFn { anon_const } => { + anon_const.hir_id == hir_id + } + _ => false, + }) => + { + Some(parent_def_id.to_def_id()) + } _ => None, } } |
