Skip to content

Commit 98f30e8

Browse files
committed
Undo questionable changes
1 parent 66751ea commit 98f30e8

File tree

4 files changed

+25
-24
lines changed

4 files changed

+25
-24
lines changed

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub(super) fn op_to_const<'tcx>(
167167
}
168168
};
169169
match immediate {
170-
Left(mplace) => to_const_value(&mplace),
170+
Left(ref mplace) => to_const_value(mplace),
171171
// see comment on `let try_as_immediate` above
172172
Right(imm) => match *imm {
173173
_ if imm.layout.is_zst() => ConstValue::ZeroSized,

compiler/rustc_const_eval/src/interpret/operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
535535
use rustc_middle::mir::Operand::*;
536536
let op = match mir_op {
537537
// FIXME: do some more logic on `move` to invalidate the old location
538-
&(Copy(place) | Move(place)) => self.eval_place_to_op(place, layout)?,
538+
&Copy(place) | &Move(place) => self.eval_place_to_op(place, layout)?,
539539

540540
Constant(constant) => {
541541
let c =

compiler/rustc_const_eval/src/interpret/projection.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ where
8787
field: usize,
8888
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
8989
let base = match base.as_mplace_or_imm() {
90-
Left(mplace) => {
90+
Left(ref mplace) => {
9191
// We can reuse the mplace field computation logic for indirect operands.
92-
let field = self.mplace_field(&mplace, field)?;
92+
let field = self.mplace_field(mplace, field)?;
9393
return Ok(field.into());
9494
}
9595
Right(value) => value,

compiler/rustc_const_eval/src/interpret/terminator.rs

+21-20
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
2222
terminator: &mir::Terminator<'tcx>,
2323
) -> InterpResult<'tcx> {
2424
use rustc_middle::mir::TerminatorKind::*;
25-
match &terminator.kind {
25+
match terminator.kind {
2626
Return => {
2727
self.pop_stack_frame(/* unwinding */ false)?
2828
}
2929

30-
Goto { target } => self.go_to_block(*target),
30+
Goto { target } => self.go_to_block(target),
3131

32-
SwitchInt { discr, targets } => {
32+
SwitchInt { ref discr, ref targets } => {
3333
let discr = self.read_immediate(&self.eval_operand(discr, None)?)?;
3434
trace!("SwitchInt({:?})", *discr);
3535

3636
// Branch to the `otherwise` case by default, if no match is found.
3737
let mut target_block = targets.otherwise();
38-
3938
for (const_int, target) in targets.iter() {
4039
// Compare using MIR BinOp::Eq, to also support pointer values.
4140
// (Avoiding `self.binary_op` as that does some redundant layout computation.)
@@ -51,22 +50,27 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
5150
break;
5251
}
5352
}
54-
5553
self.go_to_block(target_block);
5654
}
5755

58-
Call { func, args, destination, target, cleanup, from_hir_call: _, fn_span: _ } => {
56+
Call {
57+
ref func,
58+
ref args,
59+
destination,
60+
target,
61+
ref cleanup,
62+
from_hir_call: _,
63+
fn_span: _,
64+
} => {
5965
let old_stack = self.frame_idx();
6066
let old_loc = self.frame().loc;
6167
let func = self.eval_operand(func, None)?;
6268
let args = self.eval_operands(args)?;
63-
6469
let fn_sig_binder = func.layout.ty.fn_sig(*self.tcx);
6570
let fn_sig =
6671
self.tcx.normalize_erasing_late_bound_regions(self.param_env, fn_sig_binder);
6772
let extra_args = &args[fn_sig.inputs().len()..];
6873
let extra_args = self.tcx.mk_type_list(extra_args.iter().map(|arg| arg.layout.ty));
69-
7074
let (fn_val, fn_abi, with_caller_location) = match *func.layout.ty.kind() {
7175
ty::FnPtr(_sig) => {
7276
let fn_ptr = self.read_pointer(&func)?;
@@ -89,14 +93,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
8993
),
9094
};
9195

92-
let destination = self.eval_place(*destination)?;
96+
let destination = self.eval_place(destination)?;
9397
self.eval_fn_call(
9498
fn_val,
9599
(fn_sig.abi, fn_abi),
96100
&args,
97101
with_caller_location,
98102
&destination,
99-
*target,
103+
target,
100104
match (cleanup, fn_abi.can_unwind) {
101105
(Some(cleanup), true) => StackPopUnwind::Cleanup(*cleanup),
102106
(None, true) => StackPopUnwind::Skip,
@@ -110,7 +114,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
110114
}
111115
}
112116

113-
&Drop { place, target, unwind } => {
117+
Drop { place, target, unwind } => {
114118
let frame = self.frame();
115119
let ty = place.ty(&frame.body.local_decls, *self.tcx).ty;
116120
let ty = self.subst_from_frame_and_normalize_erasing_regions(frame, ty)?;
@@ -128,19 +132,18 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
128132
self.drop_in_place(&place, instance, target, unwind)?;
129133
}
130134

131-
Assert { cond, expected, msg, target, cleanup } => {
135+
Assert { ref cond, expected, ref msg, target, cleanup } => {
132136
let cond_val = self.read_scalar(&self.eval_operand(cond, None)?)?.to_bool()?;
133-
if *expected == cond_val {
134-
self.go_to_block(*target);
137+
if expected == cond_val {
138+
self.go_to_block(target);
135139
} else {
136-
M::assert_panic(self, msg, *cleanup)?;
140+
M::assert_panic(self, msg, cleanup)?;
137141
}
138142
}
139143

140144
Abort => {
141145
M::abort(self, "the program aborted execution".to_owned())?;
142146
}
143-
144147
// When we encounter Resume, we've finished unwinding
145148
// cleanup for the current stack frame. We pop it in order
146149
// to continue unwinding the next frame
@@ -151,10 +154,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
151154
self.pop_stack_frame(/* unwinding */ true)?;
152155
return Ok(());
153156
}
154-
155157
// It is UB to ever encounter this.
156158
Unreachable => throw_ub!(Unreachable),
157-
158159
// These should never occur for MIR we actually run.
159160
DropAndReplace { .. }
160161
| FalseEdge { .. }
@@ -166,8 +167,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
166167
terminator.kind
167168
),
168169

169-
InlineAsm { template, operands, options, destination, .. } => {
170-
M::eval_inline_asm(self, template, operands, *options)?;
170+
InlineAsm { template, ref operands, options, destination, .. } => {
171+
M::eval_inline_asm(self, template, operands, options)?;
171172
if options.contains(InlineAsmOptions::NORETURN) {
172173
throw_ub_format!("returned from noreturn inline assembly");
173174
}

0 commit comments

Comments
 (0)