From 6d974154679bcc3c458ceaf256eb667aa7f71b5a Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 23 Sep 2023 04:28:24 +0000 Subject: [PATCH] Fix tools --- compiler/rustc_codegen_cranelift/src/global_asm.rs | 10 ++++++++-- src/tools/clippy/clippy_lints/src/loops/never_loop.rs | 7 ++++--- src/tools/clippy/clippy_utils/src/hir_utils.rs | 5 ++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/global_asm.rs b/compiler/rustc_codegen_cranelift/src/global_asm.rs index baadd7a9e812b..fe0df813914db 100644 --- a/compiler/rustc_codegen_cranelift/src/global_asm.rs +++ b/compiler/rustc_codegen_cranelift/src/global_asm.rs @@ -39,8 +39,11 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String, ); global_asm.push_str(&string); } - InlineAsmOperand::SymFn { anon_const } => { - let ty = tcx.typeck_body(anon_const.body).node_type(anon_const.hir_id); + InlineAsmOperand::SymFnInGlobal { anon_const } => { + let ty = tcx + .type_of(anon_const.def_id) + .no_bound_vars() + .expect("`sym` in `global_asm!` should not have generics"); let instance = match ty.kind() { &ty::FnDef(def_id, args) => Instance::new(def_id, args), _ => span_bug!(op_sp, "asm sym is not a function"), @@ -50,6 +53,9 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String, // current codegen unit global_asm.push_str(symbol.name); } + InlineAsmOperand::SymFnInInline { .. } => { + bug!("should not encounter `SymFnInInline` in `global_asm!`"); + } InlineAsmOperand::SymStatic { path: _, def_id } => { let instance = Instance::mono(tcx, def_id).polymorphize(tcx); let symbol = tcx.symbol_name(instance); diff --git a/src/tools/clippy/clippy_lints/src/loops/never_loop.rs b/src/tools/clippy/clippy_lints/src/loops/never_loop.rs index 3d8a4cd948afc..282ef7b1730de 100644 --- a/src/tools/clippy/clippy_lints/src/loops/never_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/never_loop.rs @@ -252,9 +252,10 @@ fn never_loop_expr<'tcx>( local_labels, main_loop_id, ), - InlineAsmOperand::Const { .. } | InlineAsmOperand::SymFn { .. } | InlineAsmOperand::SymStatic { .. } => { - NeverLoopResult::Normal - }, + InlineAsmOperand::Const { .. } + | InlineAsmOperand::SymFnInGlobal { .. } + | InlineAsmOperand::SymFnInInline { .. } + | InlineAsmOperand::SymStatic { .. } => NeverLoopResult::Normal, })), ExprKind::OffsetOf(_, _) | ExprKind::Yield(_, _) diff --git a/src/tools/clippy/clippy_utils/src/hir_utils.rs b/src/tools/clippy/clippy_utils/src/hir_utils.rs index 52214e733f1a9..3ba86507f24ae 100644 --- a/src/tools/clippy/clippy_utils/src/hir_utils.rs +++ b/src/tools/clippy/clippy_utils/src/hir_utils.rs @@ -781,9 +781,12 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { self.hash_expr(out_expr); } }, - InlineAsmOperand::Const { anon_const } | InlineAsmOperand::SymFn { anon_const } => { + InlineAsmOperand::Const { anon_const } | InlineAsmOperand::SymFnInGlobal { anon_const } => { self.hash_body(anon_const.body); }, + InlineAsmOperand::SymFnInInline { expr } => { + self.hash_expr(expr); + } InlineAsmOperand::SymStatic { path, def_id: _ } => self.hash_qpath(path), } }