]> git.lizzy.rs Git - rust.git/blob - src/librustc_trans/trans/mir/rvalue.rs
Auto merge of #31996 - gandro:update-libc, r=alexcrichton
[rust.git] / src / librustc_trans / trans / mir / rvalue.rs
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use llvm::ValueRef;
12 use rustc::middle::ty::{self, Ty};
13 use middle::ty::cast::{CastTy, IntTy};
14 use rustc::mir::repr as mir;
15
16 use trans::asm;
17 use trans::base;
18 use trans::common::{self, BlockAndBuilder, Result};
19 use trans::debuginfo::DebugLoc;
20 use trans::declare;
21 use trans::expr;
22 use trans::adt;
23 use trans::machine;
24 use trans::type_::Type;
25 use trans::type_of;
26 use trans::tvec;
27 use trans::Disr;
28
29 use super::MirContext;
30 use super::operand::{OperandRef, OperandValue};
31 use super::lvalue::LvalueRef;
32
33 impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
34     pub fn trans_rvalue(&mut self,
35                         bcx: BlockAndBuilder<'bcx, 'tcx>,
36                         dest: LvalueRef<'tcx>,
37                         rvalue: &mir::Rvalue<'tcx>)
38                         -> BlockAndBuilder<'bcx, 'tcx>
39     {
40         debug!("trans_rvalue(dest.llval={}, rvalue={:?})",
41                bcx.val_to_string(dest.llval),
42                rvalue);
43
44         match *rvalue {
45            mir::Rvalue::Use(ref operand) => {
46                let tr_operand = self.trans_operand(&bcx, operand);
47                // FIXME: consider not copying constants through stack. (fixable by translating
48                // constants into OperandValue::Ref, why don’t we do that yet if we don’t?)
49                self.store_operand(&bcx, dest.llval, tr_operand);
50                self.set_operand_dropped(&bcx, operand);
51                bcx
52            }
53
54             mir::Rvalue::Cast(mir::CastKind::Unsize, ref operand, cast_ty) => {
55                 if common::type_is_fat_ptr(bcx.tcx(), cast_ty) {
56                     // into-coerce of a thin pointer to a fat pointer - just
57                     // use the operand path.
58                     let (bcx, temp) = self.trans_rvalue_operand(bcx, rvalue);
59                     self.store_operand(&bcx, dest.llval, temp);
60                     return bcx;
61                 }
62
63                 // Unsize of a nontrivial struct. I would prefer for
64                 // this to be eliminated by MIR translation, but
65                 // `CoerceUnsized` can be passed by a where-clause,
66                 // so the (generic) MIR may not be able to expand it.
67                 let operand = self.trans_operand(&bcx, operand);
68                 bcx.with_block(|bcx| {
69                     match operand.val {
70                         OperandValue::FatPtr(..) => unreachable!(),
71                         OperandValue::Immediate(llval) => {
72                             // unsize from an immediate structure. We don't
73                             // really need a temporary alloca here, but
74                             // avoiding it would require us to have
75                             // `coerce_unsized_into` use extractvalue to
76                             // index into the struct, and this case isn't
77                             // important enough for it.
78                             debug!("trans_rvalue: creating ugly alloca");
79                             let lltemp = base::alloc_ty(bcx, operand.ty, "__unsize_temp");
80                             base::store_ty(bcx, llval, lltemp, operand.ty);
81                             base::coerce_unsized_into(bcx,
82                                                       lltemp, operand.ty,
83                                                       dest.llval, cast_ty);
84                         }
85                         OperandValue::Ref(llref) => {
86                             base::coerce_unsized_into(bcx,
87                                                       llref, operand.ty,
88                                                       dest.llval, cast_ty);
89                         }
90                     }
91                 });
92                 bcx
93             }
94
95             mir::Rvalue::Repeat(ref elem, ref count) => {
96                 let tr_elem = self.trans_operand(&bcx, elem);
97                 let size = self.trans_constval(&bcx, &count.value, count.ty).immediate();
98                 let bcx = bcx.map_block(|block| {
99                     let base = expr::get_dataptr(block, dest.llval);
100                     tvec::iter_vec_raw(block, base, tr_elem.ty, size, |block, llslot, _| {
101                         self.store_operand_direct(block, llslot, tr_elem);
102                         block
103                     })
104                 });
105                 self.set_operand_dropped(&bcx, elem);
106                 bcx
107             }
108
109             mir::Rvalue::Aggregate(ref kind, ref operands) => {
110                 match *kind {
111                     mir::AggregateKind::Adt(adt_def, index, _) => {
112                         let repr = adt::represent_type(bcx.ccx(), dest.ty.to_ty(bcx.tcx()));
113                         let disr = Disr::from(adt_def.variants[index].disr_val);
114                         bcx.with_block(|bcx| {
115                             adt::trans_set_discr(bcx, &repr, dest.llval, Disr::from(disr));
116                         });
117                         for (i, operand) in operands.iter().enumerate() {
118                             let op = self.trans_operand(&bcx, operand);
119                             // Do not generate stores and GEPis for zero-sized fields.
120                             if !common::type_is_zero_size(bcx.ccx(), op.ty) {
121                                 let val = adt::MaybeSizedValue::sized(dest.llval);
122                                 let lldest_i = bcx.with_block(|bcx| {
123                                     adt::trans_field_ptr(bcx, &repr, val, disr, i)
124                                 });
125                                 self.store_operand(&bcx, lldest_i, op);
126                                 self.set_operand_dropped(&bcx, operand);
127                             }
128                         }
129                     },
130                     _ => {
131                         for (i, operand) in operands.iter().enumerate() {
132                             let op = self.trans_operand(&bcx, operand);
133                             // Do not generate stores and GEPis for zero-sized fields.
134                             if !common::type_is_zero_size(bcx.ccx(), op.ty) {
135                                 // Note: perhaps this should be StructGep, but
136                                 // note that in some cases the values here will
137                                 // not be structs but arrays.
138                                 let dest = bcx.gepi(dest.llval, &[0, i]);
139                                 self.store_operand(&bcx, dest, op);
140                                 self.set_operand_dropped(&bcx, operand);
141                             }
142                         }
143                     }
144                 }
145                 bcx
146             }
147
148             mir::Rvalue::Slice { ref input, from_start, from_end } => {
149                 let ccx = bcx.ccx();
150                 let input = self.trans_lvalue(&bcx, input);
151                 let (llbase, lllen) = bcx.with_block(|bcx| {
152                     tvec::get_base_and_len(bcx,
153                                            input.llval,
154                                            input.ty.to_ty(bcx.tcx()))
155                 });
156                 let llbase1 = bcx.gepi(llbase, &[from_start]);
157                 let adj = common::C_uint(ccx, from_start + from_end);
158                 let lllen1 = bcx.sub(lllen, adj);
159                 let (lladdrdest, llmetadest) = bcx.with_block(|bcx| {
160                     (expr::get_dataptr(bcx, dest.llval), expr::get_meta(bcx, dest.llval))
161                 });
162                 bcx.store(llbase1, lladdrdest);
163                 bcx.store(lllen1, llmetadest);
164                 bcx
165             }
166
167             mir::Rvalue::InlineAsm(ref inline_asm) => {
168                 bcx.map_block(|bcx| {
169                     asm::trans_inline_asm(bcx, inline_asm)
170                 })
171             }
172
173             _ => {
174                 assert!(rvalue_creates_operand(rvalue));
175                 let (bcx, temp) = self.trans_rvalue_operand(bcx, rvalue);
176                 self.store_operand(&bcx, dest.llval, temp);
177                 bcx
178             }
179         }
180     }
181
182     pub fn trans_rvalue_operand(&mut self,
183                                 bcx: BlockAndBuilder<'bcx, 'tcx>,
184                                 rvalue: &mir::Rvalue<'tcx>)
185                                 -> (BlockAndBuilder<'bcx, 'tcx>, OperandRef<'tcx>)
186     {
187         assert!(rvalue_creates_operand(rvalue), "cannot trans {:?} to operand", rvalue);
188
189         match *rvalue {
190             mir::Rvalue::Cast(ref kind, ref operand, cast_ty) => {
191                 let operand = self.trans_operand(&bcx, operand);
192                 debug!("cast operand is {}", operand.repr(&bcx));
193                 let cast_ty = bcx.monomorphize(&cast_ty);
194
195                 let val = match *kind {
196                     mir::CastKind::ReifyFnPointer |
197                     mir::CastKind::UnsafeFnPointer => {
198                         // these are no-ops at the LLVM level
199                         operand.val
200                     }
201                     mir::CastKind::Unsize => {
202                         // unsize targets other than to a fat pointer currently
203                         // can't be operands.
204                         assert!(common::type_is_fat_ptr(bcx.tcx(), cast_ty));
205
206                         match operand.val {
207                             OperandValue::FatPtr(..) => {
208                                 // unsize from a fat pointer - this is a
209                                 // "trait-object-to-supertrait" coercion, for
210                                 // example,
211                                 //   &'a fmt::Debug+Send => &'a fmt::Debug,
212                                 // and is a no-op at the LLVM level
213                                 operand.val
214                             }
215                             OperandValue::Immediate(lldata) => {
216                                 // "standard" unsize
217                                 let (lldata, llextra) = bcx.with_block(|bcx| {
218                                     base::unsize_thin_ptr(bcx, lldata,
219                                                           operand.ty, cast_ty)
220                                 });
221                                 OperandValue::FatPtr(lldata, llextra)
222                             }
223                             OperandValue::Ref(_) => {
224                                 bcx.sess().bug(
225                                     &format!("by-ref operand {} in trans_rvalue_operand",
226                                              operand.repr(&bcx)));
227                             }
228                         }
229                     }
230                     mir::CastKind::Misc if common::type_is_immediate(bcx.ccx(), operand.ty) => {
231                         debug_assert!(common::type_is_immediate(bcx.ccx(), cast_ty));
232                         let r_t_in = CastTy::from_ty(operand.ty).expect("bad input type for cast");
233                         let r_t_out = CastTy::from_ty(cast_ty).expect("bad output type for cast");
234                         let ll_t_in = type_of::arg_type_of(bcx.ccx(), operand.ty);
235                         let ll_t_out = type_of::arg_type_of(bcx.ccx(), cast_ty);
236                         let (llval, ll_t_in, signed) = if let CastTy::Int(IntTy::CEnum) = r_t_in {
237                             let repr = adt::represent_type(bcx.ccx(), operand.ty);
238                             let llval = operand.immediate();
239                             let discr = bcx.with_block(|bcx| {
240                                 adt::trans_get_discr(bcx, &repr, llval, None, true)
241                             });
242                             (discr, common::val_ty(discr), adt::is_discr_signed(&repr))
243                         } else {
244                             (operand.immediate(), ll_t_in, operand.ty.is_signed())
245                         };
246
247                         let newval = match (r_t_in, r_t_out) {
248                             (CastTy::Int(_), CastTy::Int(_)) => {
249                                 let srcsz = ll_t_in.int_width();
250                                 let dstsz = ll_t_out.int_width();
251                                 if srcsz == dstsz {
252                                     bcx.bitcast(llval, ll_t_out)
253                                 } else if srcsz > dstsz {
254                                     bcx.trunc(llval, ll_t_out)
255                                 } else if signed {
256                                     bcx.sext(llval, ll_t_out)
257                                 } else {
258                                     bcx.zext(llval, ll_t_out)
259                                 }
260                             }
261                             (CastTy::Float, CastTy::Float) => {
262                                 let srcsz = ll_t_in.float_width();
263                                 let dstsz = ll_t_out.float_width();
264                                 if dstsz > srcsz {
265                                     bcx.fpext(llval, ll_t_out)
266                                 } else if srcsz > dstsz {
267                                     bcx.fptrunc(llval, ll_t_out)
268                                 } else {
269                                     llval
270                                 }
271                             }
272                             (CastTy::Ptr(_), CastTy::Ptr(_)) |
273                             (CastTy::FnPtr, CastTy::Ptr(_)) |
274                             (CastTy::RPtr(_), CastTy::Ptr(_)) =>
275                                 bcx.pointercast(llval, ll_t_out),
276                             (CastTy::Ptr(_), CastTy::Int(_)) |
277                             (CastTy::FnPtr, CastTy::Int(_)) =>
278                                 bcx.ptrtoint(llval, ll_t_out),
279                             (CastTy::Int(_), CastTy::Ptr(_)) =>
280                                 bcx.inttoptr(llval, ll_t_out),
281                             (CastTy::Int(_), CastTy::Float) if signed =>
282                                 bcx.sitofp(llval, ll_t_out),
283                             (CastTy::Int(_), CastTy::Float) =>
284                                 bcx.uitofp(llval, ll_t_out),
285                             (CastTy::Float, CastTy::Int(IntTy::I)) =>
286                                 bcx.fptosi(llval, ll_t_out),
287                             (CastTy::Float, CastTy::Int(_)) =>
288                                 bcx.fptoui(llval, ll_t_out),
289                             _ => bcx.ccx().sess().bug(
290                                 &format!("unsupported cast: {:?} to {:?}", operand.ty, cast_ty)
291                             )
292                         };
293                         OperandValue::Immediate(newval)
294                     }
295                     mir::CastKind::Misc => { // Casts from a fat-ptr.
296                         let ll_cast_ty = type_of::arg_type_of(bcx.ccx(), cast_ty);
297                         let ll_from_ty = type_of::arg_type_of(bcx.ccx(), operand.ty);
298                         if let OperandValue::FatPtr(data_ptr, meta_ptr) = operand.val {
299                             if common::type_is_fat_ptr(bcx.tcx(), cast_ty) {
300                                 let ll_cft = ll_cast_ty.field_types();
301                                 let ll_fft = ll_from_ty.field_types();
302                                 let data_cast = bcx.pointercast(data_ptr, ll_cft[0]);
303                                 assert_eq!(ll_cft[1].kind(), ll_fft[1].kind());
304                                 OperandValue::FatPtr(data_cast, meta_ptr)
305                             } else { // cast to thin-ptr
306                                 // Cast of fat-ptr to thin-ptr is an extraction of data-ptr and
307                                 // pointer-cast of that pointer to desired pointer type.
308                                 let llval = bcx.pointercast(data_ptr, ll_cast_ty);
309                                 OperandValue::Immediate(llval)
310                             }
311                         } else {
312                             panic!("Unexpected non-FatPtr operand")
313                         }
314                     }
315                 };
316                 let operand = OperandRef {
317                     val: val,
318                     ty: cast_ty
319                 };
320                 (bcx, operand)
321             }
322
323             mir::Rvalue::Ref(_, bk, ref lvalue) => {
324                 let tr_lvalue = self.trans_lvalue(&bcx, lvalue);
325
326                 let ty = tr_lvalue.ty.to_ty(bcx.tcx());
327                 let ref_ty = bcx.tcx().mk_ref(
328                     bcx.tcx().mk_region(ty::ReStatic),
329                     ty::TypeAndMut { ty: ty, mutbl: bk.to_mutbl_lossy() }
330                 );
331
332                 // Note: lvalues are indirect, so storing the `llval` into the
333                 // destination effectively creates a reference.
334                 let operand = if common::type_is_sized(bcx.tcx(), ty) {
335                     OperandRef {
336                         val: OperandValue::Immediate(tr_lvalue.llval),
337                         ty: ref_ty,
338                     }
339                 } else {
340                     OperandRef {
341                         val: OperandValue::FatPtr(tr_lvalue.llval,
342                                                   tr_lvalue.llextra),
343                         ty: ref_ty,
344                     }
345                 };
346                 (bcx, operand)
347             }
348
349             mir::Rvalue::Len(ref lvalue) => {
350                 let tr_lvalue = self.trans_lvalue(&bcx, lvalue);
351                 let operand = OperandRef {
352                     val: OperandValue::Immediate(self.lvalue_len(&bcx, tr_lvalue)),
353                     ty: bcx.tcx().types.usize,
354                 };
355                 (bcx, operand)
356             }
357
358             mir::Rvalue::BinaryOp(op, ref lhs, ref rhs) => {
359                 let lhs = self.trans_operand(&bcx, lhs);
360                 let rhs = self.trans_operand(&bcx, rhs);
361                 let llresult = if common::type_is_fat_ptr(bcx.tcx(), lhs.ty) {
362                     match (lhs.val, rhs.val) {
363                         (OperandValue::FatPtr(lhs_addr, lhs_extra),
364                          OperandValue::FatPtr(rhs_addr, rhs_extra)) => {
365                             bcx.with_block(|bcx| {
366                                 base::compare_fat_ptrs(bcx,
367                                                        lhs_addr, lhs_extra,
368                                                        rhs_addr, rhs_extra,
369                                                        lhs.ty, op.to_hir_binop(),
370                                                        DebugLoc::None)
371                             })
372                         }
373                         _ => unreachable!()
374                     }
375
376                 } else {
377                     self.trans_scalar_binop(&bcx, op,
378                                             lhs.immediate(), rhs.immediate(),
379                                             lhs.ty)
380                 };
381                 let operand = OperandRef {
382                     val: OperandValue::Immediate(llresult),
383                     ty: self.mir.binop_ty(bcx.tcx(), op, lhs.ty, rhs.ty),
384                 };
385                 (bcx, operand)
386             }
387
388             mir::Rvalue::UnaryOp(op, ref operand) => {
389                 let operand = self.trans_operand(&bcx, operand);
390                 let lloperand = operand.immediate();
391                 let is_float = operand.ty.is_fp();
392                 let llval = match op {
393                     mir::UnOp::Not => bcx.not(lloperand),
394                     mir::UnOp::Neg => if is_float {
395                         bcx.fneg(lloperand)
396                     } else {
397                         bcx.neg(lloperand)
398                     }
399                 };
400                 (bcx, OperandRef {
401                     val: OperandValue::Immediate(llval),
402                     ty: operand.ty,
403                 })
404             }
405
406             mir::Rvalue::Box(content_ty) => {
407                 let content_ty: Ty<'tcx> = bcx.monomorphize(&content_ty);
408                 let llty = type_of::type_of(bcx.ccx(), content_ty);
409                 let llsize = machine::llsize_of(bcx.ccx(), llty);
410                 let align = type_of::align_of(bcx.ccx(), content_ty);
411                 let llalign = common::C_uint(bcx.ccx(), align);
412                 let llty_ptr = llty.ptr_to();
413                 let box_ty = bcx.tcx().mk_box(content_ty);
414                 let mut llval = None;
415                 let bcx = bcx.map_block(|bcx| {
416                     let Result { bcx, val } = base::malloc_raw_dyn(bcx,
417                                                                    llty_ptr,
418                                                                    box_ty,
419                                                                    llsize,
420                                                                    llalign,
421                                                                    DebugLoc::None);
422                     llval = Some(val);
423                     bcx
424                 });
425                 let operand = OperandRef {
426                     val: OperandValue::Immediate(llval.unwrap()),
427                     ty: box_ty,
428                 };
429                 (bcx, operand)
430             }
431
432             mir::Rvalue::Use(..) |
433             mir::Rvalue::Repeat(..) |
434             mir::Rvalue::Aggregate(..) |
435             mir::Rvalue::Slice { .. } |
436             mir::Rvalue::InlineAsm(..) => {
437                 bcx.tcx().sess.bug(&format!("cannot generate operand from rvalue {:?}", rvalue));
438             }
439         }
440     }
441
442     pub fn trans_scalar_binop(&mut self,
443                               bcx: &BlockAndBuilder<'bcx, 'tcx>,
444                               op: mir::BinOp,
445                               lhs: ValueRef,
446                               rhs: ValueRef,
447                               input_ty: Ty<'tcx>) -> ValueRef {
448         let is_float = input_ty.is_fp();
449         let is_signed = input_ty.is_signed();
450         match op {
451             mir::BinOp::Add => if is_float {
452                 bcx.fadd(lhs, rhs)
453             } else {
454                 bcx.add(lhs, rhs)
455             },
456             mir::BinOp::Sub => if is_float {
457                 bcx.fsub(lhs, rhs)
458             } else {
459                 bcx.sub(lhs, rhs)
460             },
461             mir::BinOp::Mul => if is_float {
462                 bcx.fmul(lhs, rhs)
463             } else {
464                 bcx.mul(lhs, rhs)
465             },
466             mir::BinOp::Div => if is_float {
467                 bcx.fdiv(lhs, rhs)
468             } else if is_signed {
469                 bcx.sdiv(lhs, rhs)
470             } else {
471                 bcx.udiv(lhs, rhs)
472             },
473             mir::BinOp::Rem => if is_float {
474                 // LLVM currently always lowers the `frem` instructions appropriate
475                 // library calls typically found in libm. Notably f64 gets wired up
476                 // to `fmod` and f32 gets wired up to `fmodf`. Inconveniently for
477                 // us, 32-bit MSVC does not actually have a `fmodf` symbol, it's
478                 // instead just an inline function in a header that goes up to a
479                 // f64, uses `fmod`, and then comes back down to a f32.
480                 //
481                 // Although LLVM knows that `fmodf` doesn't exist on MSVC, it will
482                 // still unconditionally lower frem instructions over 32-bit floats
483                 // to a call to `fmodf`. To work around this we special case MSVC
484                 // 32-bit float rem instructions and instead do the call out to
485                 // `fmod` ourselves.
486                 //
487                 // Note that this is currently duplicated with src/libcore/ops.rs
488                 // which does the same thing, and it would be nice to perhaps unify
489                 // these two implementations one day! Also note that we call `fmod`
490                 // for both 32 and 64-bit floats because if we emit any FRem
491                 // instruction at all then LLVM is capable of optimizing it into a
492                 // 32-bit FRem (which we're trying to avoid).
493                 let tcx = bcx.tcx();
494                 let use_fmod = tcx.sess.target.target.options.is_like_msvc &&
495                     tcx.sess.target.target.arch == "x86";
496                 if use_fmod {
497                     let f64t = Type::f64(bcx.ccx());
498                     let fty = Type::func(&[f64t, f64t], &f64t);
499                     let llfn = declare::declare_cfn(bcx.ccx(), "fmod", fty,
500                                                     tcx.types.f64);
501                     if input_ty == tcx.types.f32 {
502                         let lllhs = bcx.fpext(lhs, f64t);
503                         let llrhs = bcx.fpext(rhs, f64t);
504                         let llres = bcx.call(llfn, &[lllhs, llrhs], None, None);
505                         bcx.fptrunc(llres, Type::f32(bcx.ccx()))
506                     } else {
507                         bcx.call(llfn, &[lhs, rhs], None, None)
508                     }
509                 } else {
510                     bcx.frem(lhs, rhs)
511                 }
512             } else if is_signed {
513                 bcx.srem(lhs, rhs)
514             } else {
515                 bcx.urem(lhs, rhs)
516             },
517             mir::BinOp::BitOr => bcx.or(lhs, rhs),
518             mir::BinOp::BitAnd => bcx.and(lhs, rhs),
519             mir::BinOp::BitXor => bcx.xor(lhs, rhs),
520             mir::BinOp::Shl => {
521                 bcx.with_block(|bcx| {
522                     common::build_unchecked_lshift(bcx,
523                                                    lhs,
524                                                    rhs,
525                                                    DebugLoc::None)
526                 })
527             }
528             mir::BinOp::Shr => {
529                 bcx.with_block(|bcx| {
530                     common::build_unchecked_rshift(bcx,
531                                                    input_ty,
532                                                    lhs,
533                                                    rhs,
534                                                    DebugLoc::None)
535                 })
536             }
537             mir::BinOp::Eq | mir::BinOp::Lt | mir::BinOp::Gt |
538             mir::BinOp::Ne | mir::BinOp::Le | mir::BinOp::Ge => {
539                 bcx.with_block(|bcx| {
540                     base::compare_scalar_types(bcx, lhs, rhs, input_ty,
541                                                op.to_hir_binop(), DebugLoc::None)
542                 })
543             }
544         }
545     }
546 }
547
548 pub fn rvalue_creates_operand<'tcx>(rvalue: &mir::Rvalue<'tcx>) -> bool {
549     match *rvalue {
550         mir::Rvalue::Ref(..) |
551         mir::Rvalue::Len(..) |
552         mir::Rvalue::Cast(..) | // (*)
553         mir::Rvalue::BinaryOp(..) |
554         mir::Rvalue::UnaryOp(..) |
555         mir::Rvalue::Box(..) =>
556             true,
557         mir::Rvalue::Use(..) | // (**)
558         mir::Rvalue::Repeat(..) |
559         mir::Rvalue::Aggregate(..) |
560         mir::Rvalue::Slice { .. } |
561         mir::Rvalue::InlineAsm(..) =>
562             false,
563     }
564
565     // (*) this is only true if the type is suitable
566     // (**) we need to zero-out the source operand after moving, so we are restricted to either
567     // ensuring all users of `Use` zero it out themselves or not allowing to “create” operand for
568     // it.
569 }