@@ -22,20 +22,19 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
22
22
terminator : & mir:: Terminator < ' tcx > ,
23
23
) -> InterpResult < ' tcx > {
24
24
use rustc_middle:: mir:: TerminatorKind :: * ;
25
- match & terminator. kind {
25
+ match terminator. kind {
26
26
Return => {
27
27
self . pop_stack_frame ( /* unwinding */ false ) ?
28
28
}
29
29
30
- Goto { target } => self . go_to_block ( * target) ,
30
+ Goto { target } => self . go_to_block ( target) ,
31
31
32
- SwitchInt { discr, targets } => {
32
+ SwitchInt { ref discr, ref targets } => {
33
33
let discr = self . read_immediate ( & self . eval_operand ( discr, None ) ?) ?;
34
34
trace ! ( "SwitchInt({:?})" , * discr) ;
35
35
36
36
// Branch to the `otherwise` case by default, if no match is found.
37
37
let mut target_block = targets. otherwise ( ) ;
38
-
39
38
for ( const_int, target) in targets. iter ( ) {
40
39
// Compare using MIR BinOp::Eq, to also support pointer values.
41
40
// (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> {
51
50
break ;
52
51
}
53
52
}
54
-
55
53
self . go_to_block ( target_block) ;
56
54
}
57
55
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
+ } => {
59
65
let old_stack = self . frame_idx ( ) ;
60
66
let old_loc = self . frame ( ) . loc ;
61
67
let func = self . eval_operand ( func, None ) ?;
62
68
let args = self . eval_operands ( args) ?;
63
-
64
69
let fn_sig_binder = func. layout . ty . fn_sig ( * self . tcx ) ;
65
70
let fn_sig =
66
71
self . tcx . normalize_erasing_late_bound_regions ( self . param_env , fn_sig_binder) ;
67
72
let extra_args = & args[ fn_sig. inputs ( ) . len ( ) ..] ;
68
73
let extra_args = self . tcx . mk_type_list ( extra_args. iter ( ) . map ( |arg| arg. layout . ty ) ) ;
69
-
70
74
let ( fn_val, fn_abi, with_caller_location) = match * func. layout . ty . kind ( ) {
71
75
ty:: FnPtr ( _sig) => {
72
76
let fn_ptr = self . read_pointer ( & func) ?;
@@ -89,14 +93,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
89
93
) ,
90
94
} ;
91
95
92
- let destination = self . eval_place ( * destination) ?;
96
+ let destination = self . eval_place ( destination) ?;
93
97
self . eval_fn_call (
94
98
fn_val,
95
99
( fn_sig. abi , fn_abi) ,
96
100
& args,
97
101
with_caller_location,
98
102
& destination,
99
- * target,
103
+ target,
100
104
match ( cleanup, fn_abi. can_unwind ) {
101
105
( Some ( cleanup) , true ) => StackPopUnwind :: Cleanup ( * cleanup) ,
102
106
( None , true ) => StackPopUnwind :: Skip ,
@@ -110,7 +114,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
110
114
}
111
115
}
112
116
113
- & Drop { place, target, unwind } => {
117
+ Drop { place, target, unwind } => {
114
118
let frame = self . frame ( ) ;
115
119
let ty = place. ty ( & frame. body . local_decls , * self . tcx ) . ty ;
116
120
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> {
128
132
self . drop_in_place ( & place, instance, target, unwind) ?;
129
133
}
130
134
131
- Assert { cond, expected, msg, target, cleanup } => {
135
+ Assert { ref cond, expected, ref msg, target, cleanup } => {
132
136
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) ;
135
139
} else {
136
- M :: assert_panic ( self , msg, * cleanup) ?;
140
+ M :: assert_panic ( self , msg, cleanup) ?;
137
141
}
138
142
}
139
143
140
144
Abort => {
141
145
M :: abort ( self , "the program aborted execution" . to_owned ( ) ) ?;
142
146
}
143
-
144
147
// When we encounter Resume, we've finished unwinding
145
148
// cleanup for the current stack frame. We pop it in order
146
149
// to continue unwinding the next frame
@@ -151,10 +154,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
151
154
self . pop_stack_frame ( /* unwinding */ true ) ?;
152
155
return Ok ( ( ) ) ;
153
156
}
154
-
155
157
// It is UB to ever encounter this.
156
158
Unreachable => throw_ub ! ( Unreachable ) ,
157
-
158
159
// These should never occur for MIR we actually run.
159
160
DropAndReplace { .. }
160
161
| FalseEdge { .. }
@@ -166,8 +167,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
166
167
terminator. kind
167
168
) ,
168
169
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) ?;
171
172
if options. contains ( InlineAsmOptions :: NORETURN ) {
172
173
throw_ub_format ! ( "returned from noreturn inline assembly" ) ;
173
174
}
0 commit comments