Skip to content

Commit 6d97415

Browse files
Fix tools
1 parent 10e62c3 commit 6d97415

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

compiler/rustc_codegen_cranelift/src/global_asm.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String,
3939
);
4040
global_asm.push_str(&string);
4141
}
42-
InlineAsmOperand::SymFn { anon_const } => {
43-
let ty = tcx.typeck_body(anon_const.body).node_type(anon_const.hir_id);
42+
InlineAsmOperand::SymFnInGlobal { anon_const } => {
43+
let ty = tcx
44+
.type_of(anon_const.def_id)
45+
.no_bound_vars()
46+
.expect("`sym` in `global_asm!` should not have generics");
4447
let instance = match ty.kind() {
4548
&ty::FnDef(def_id, args) => Instance::new(def_id, args),
4649
_ => 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,
5053
// current codegen unit
5154
global_asm.push_str(symbol.name);
5255
}
56+
InlineAsmOperand::SymFnInInline { .. } => {
57+
bug!("should not encounter `SymFnInInline` in `global_asm!`");
58+
}
5359
InlineAsmOperand::SymStatic { path: _, def_id } => {
5460
let instance = Instance::mono(tcx, def_id).polymorphize(tcx);
5561
let symbol = tcx.symbol_name(instance);

src/tools/clippy/clippy_lints/src/loops/never_loop.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,10 @@ fn never_loop_expr<'tcx>(
252252
local_labels,
253253
main_loop_id,
254254
),
255-
InlineAsmOperand::Const { .. } | InlineAsmOperand::SymFn { .. } | InlineAsmOperand::SymStatic { .. } => {
256-
NeverLoopResult::Normal
257-
},
255+
InlineAsmOperand::Const { .. }
256+
| InlineAsmOperand::SymFnInGlobal { .. }
257+
| InlineAsmOperand::SymFnInInline { .. }
258+
| InlineAsmOperand::SymStatic { .. } => NeverLoopResult::Normal,
258259
})),
259260
ExprKind::OffsetOf(_, _)
260261
| ExprKind::Yield(_, _)

src/tools/clippy/clippy_utils/src/hir_utils.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,12 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
781781
self.hash_expr(out_expr);
782782
}
783783
},
784-
InlineAsmOperand::Const { anon_const } | InlineAsmOperand::SymFn { anon_const } => {
784+
InlineAsmOperand::Const { anon_const } | InlineAsmOperand::SymFnInGlobal { anon_const } => {
785785
self.hash_body(anon_const.body);
786786
},
787+
InlineAsmOperand::SymFnInInline { expr } => {
788+
self.hash_expr(expr);
789+
}
787790
InlineAsmOperand::SymStatic { path, def_id: _ } => self.hash_qpath(path),
788791
}
789792
}

0 commit comments

Comments
 (0)