@@ -10,7 +10,6 @@ use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, layout};
10
10
use rustc_span:: { DUMMY_SP , Symbol , sym} ;
11
11
12
12
use crate :: simplify:: simplify_duplicate_switch_targets;
13
- use crate :: take_array;
14
13
15
14
pub ( super ) enum InstSimplify {
16
15
BeforeInline ,
@@ -229,39 +228,31 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
229
228
terminator : & mut Terminator < ' tcx > ,
230
229
statements : & mut Vec < Statement < ' tcx > > ,
231
230
) {
232
- let TerminatorKind :: Call { func, args, destination, target, .. } = & mut terminator. kind
231
+ let TerminatorKind :: Call {
232
+ func, args, destination, target : Some ( destination_block) , ..
233
+ } = & terminator. kind
233
234
else {
234
235
return ;
235
236
} ;
236
237
237
238
// It's definitely not a clone if there are multiple arguments
238
239
let [ arg] = & args[ ..] else { return } ;
239
240
240
- let Some ( destination_block) = * target else { return } ;
241
-
242
241
// Only bother looking more if it's easy to know what we're calling
243
- let Some ( ( fn_def_id, fn_args) ) = func. const_fn_def ( ) else { return } ;
244
-
245
- // Clone needs one arg, so we can cheaply rule out other stuff
246
- if fn_args. len ( ) != 1 {
247
- return ;
248
- }
242
+ let Some ( ( fn_def_id, ..) ) = func. const_fn_def ( ) else { return } ;
249
243
250
244
// These types are easily available from locals, so check that before
251
245
// doing DefId lookups to figure out what we're actually calling.
252
246
let arg_ty = arg. node . ty ( self . local_decls , self . tcx ) ;
253
247
254
248
let ty:: Ref ( _region, inner_ty, Mutability :: Not ) = * arg_ty. kind ( ) else { return } ;
255
249
256
- if !inner_ty. is_trivially_pure_clone_copy ( ) {
257
- return ;
258
- }
259
-
260
- if !self . tcx . is_lang_item ( fn_def_id, LangItem :: CloneFn ) {
250
+ if !self . tcx . is_lang_item ( fn_def_id, LangItem :: CloneFn )
251
+ || !inner_ty. is_trivially_pure_clone_copy ( )
252
+ {
261
253
return ;
262
254
}
263
255
264
- let Ok ( [ arg] ) = take_array ( args) else { return } ;
265
256
let Some ( arg_place) = arg. node . place ( ) else { return } ;
266
257
267
258
statements. push ( Statement {
@@ -273,7 +264,7 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
273
264
) ) ,
274
265
) ) ) ,
275
266
} ) ;
276
- terminator. kind = TerminatorKind :: Goto { target : destination_block } ;
267
+ terminator. kind = TerminatorKind :: Goto { target : * destination_block } ;
277
268
}
278
269
279
270
fn simplify_nounwind_call ( & self , terminator : & mut Terminator < ' tcx > ) {
0 commit comments