Skip to content

Commit b7c1868

Browse files
committed
Cleanup not needed arguments
1 parent b398fa5 commit b7c1868

File tree

4 files changed

+10
-46
lines changed

4 files changed

+10
-46
lines changed

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ mod simd;
5555
pub(crate) use cpuid::codegen_cpuid_call;
5656
pub(crate) use llvm::codegen_llvm_intrinsic_call;
5757

58+
use rustc_const_eval::might_permit_raw_init::might_permit_raw_init;
5859
use rustc_middle::ty::print::with_no_trimmed_paths;
5960
use rustc_middle::ty::subst::SubstsRef;
6061
use rustc_span::symbol::{kw, sym, Symbol};
@@ -673,12 +674,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
673674
}
674675

675676
if intrinsic == sym::assert_zero_valid
676-
&& !rustc_const_eval::might_permit_raw_init::might_permit_raw_init(
677-
fx.tcx,
678-
source_info.span,
679-
layout,
680-
fx.tcx.sess.opts.debugging_opts.strict_init_checks,
681-
InitKind::Zero) {
677+
&& !might_permit_raw_init(fx.tcx, layout, InitKind::Zero) {
682678

683679
with_no_trimmed_paths!({
684680
crate::base::codegen_panic(
@@ -691,12 +687,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
691687
}
692688

693689
if intrinsic == sym::assert_uninit_valid
694-
&& !rustc_const_eval::might_permit_raw_init::might_permit_raw_init(
695-
fx.tcx,
696-
source_info.span,
697-
layout,
698-
fx.tcx.sess.opts.debugging_opts.strict_init_checks,
699-
InitKind::Uninit) {
690+
&& !might_permit_raw_init(fx.tcx, layout, InitKind::Uninit) {
700691

701692
with_no_trimmed_paths!({
702693
crate::base::codegen_panic(

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
528528
source_info: mir::SourceInfo,
529529
target: Option<mir::BasicBlock>,
530530
cleanup: Option<mir::BasicBlock>,
531-
strict_validity: bool,
532531
) -> bool {
533532
// Emit a panic or a no-op for `assert_*` intrinsics.
534533
// These are intrinsics that compile to panics so that we can get a message
@@ -553,20 +552,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
553552
let layout = bx.layout_of(ty);
554553
let do_panic = match intrinsic {
555554
Inhabited => layout.abi.is_uninhabited(),
556-
ZeroValid => !might_permit_raw_init(
557-
bx.tcx(),
558-
source_info.span,
559-
layout,
560-
strict_validity,
561-
InitKind::Zero,
562-
),
563-
UninitValid => !might_permit_raw_init(
564-
bx.tcx(),
565-
source_info.span,
566-
layout,
567-
strict_validity,
568-
InitKind::Uninit,
569-
),
555+
ZeroValid => !might_permit_raw_init(bx.tcx(), layout, InitKind::Zero),
556+
UninitValid => !might_permit_raw_init(bx.tcx(), layout, InitKind::Uninit),
570557
};
571558
if do_panic {
572559
let msg_str = with_no_visible_paths!({
@@ -701,7 +688,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
701688
source_info,
702689
target,
703690
cleanup,
704-
self.cx.tcx().sess.opts.debugging_opts.strict_init_checks,
705691
) {
706692
return;
707693
}

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
417417
}
418418

419419
if intrinsic_name == sym::assert_zero_valid {
420-
let should_panic = !might_permit_raw_init(
421-
*self.tcx,
422-
self.cur_span(),
423-
layout,
424-
self.tcx.sess.opts.debugging_opts.strict_init_checks,
425-
InitKind::Zero,
426-
);
420+
let should_panic = !might_permit_raw_init(*self.tcx, layout, InitKind::Zero);
427421

428422
if should_panic {
429423
M::abort(
@@ -437,13 +431,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
437431
}
438432

439433
if intrinsic_name == sym::assert_uninit_valid {
440-
let should_panic = !might_permit_raw_init(
441-
*self.tcx,
442-
self.cur_span(),
443-
layout,
444-
self.tcx.sess.opts.debugging_opts.strict_init_checks,
445-
InitKind::Uninit,
446-
);
434+
let should_panic = !might_permit_raw_init(*self.tcx, layout, InitKind::Uninit);
447435

448436
if should_panic {
449437
M::abort(

compiler/rustc_const_eval/src/might_permit_raw_init.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@ use crate::interpret::{InterpCx, MemoryKind, OpTy};
33
use rustc_middle::ty::layout::LayoutCx;
44
use rustc_middle::ty::{layout::TyAndLayout, ParamEnv, TyCtxt};
55
use rustc_session::Limit;
6-
use rustc_span::Span;
76
use rustc_target::abi::InitKind;
87

98
pub fn might_permit_raw_init<'tcx>(
109
tcx: TyCtxt<'tcx>,
11-
root_span: Span,
1210
ty: TyAndLayout<'tcx>,
13-
strict: bool,
1411
kind: InitKind,
1512
) -> bool {
13+
let strict = tcx.sess.opts.debugging_opts.strict_init_checks;
14+
1615
if strict {
1716
let machine = CompileTimeInterpreter::new(Limit::new(0), false);
1817

19-
let mut cx = InterpCx::new(tcx, root_span, ParamEnv::reveal_all(), machine);
18+
let mut cx = InterpCx::new(tcx, rustc_span::DUMMY_SP, ParamEnv::reveal_all(), machine);
2019

2120
// We could panic here... Or we could just return "yeah it's valid whatever". Or let
2221
// codegen_panic_intrinsic return an error that halts compilation.

0 commit comments

Comments
 (0)