Skip to content

Commit

Permalink
Fix tools
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Sep 23, 2023
1 parent 10e62c3 commit 6d97415
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
10 changes: 8 additions & 2 deletions compiler/rustc_codegen_cranelift/src/global_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/tools/clippy/clippy_lints/src/loops/never_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_, _)
Expand Down
5 changes: 4 additions & 1 deletion src/tools/clippy/clippy_utils/src/hir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand Down

0 comments on commit 6d97415

Please sign in to comment.