use rustc::middle::lang_items;
-use rustc::ty::{self, Ty, TypeFoldable};
+use rustc::ty::{self, Ty, TypeFoldable, Instance};
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, FnTypeExt};
use rustc::mir::{self, Place, PlaceBase, Static, StaticKind};
use rustc::mir::interpret::InterpError;
use rustc_target::abi::call::{ArgType, FnType, PassMode, IgnoreMode};
use rustc_target::spec::abi::Abi;
-use rustc_mir::monomorphize;
use crate::base;
use crate::MemFlags;
use crate::common::{self, IntPredicate};
}
}
- fn codegen_return_terminator<'b>(
- &mut self,
- mut bx: Bx,
- ) {
+ fn codegen_return_terminator(&mut self, mut bx: Bx) {
if self.fn_ty.c_variadic {
match self.va_list_ref {
Some(va_list) => {
) {
let ty = location.ty(self.mir, bx.tcx()).ty;
let ty = self.monomorphize(&ty);
- let drop_fn = monomorphize::resolve_drop_in_place(bx.tcx(), ty);
+ let drop_fn = Instance::resolve_drop_in_place(bx.tcx(), ty);
if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def {
// we don't actually need to drop anything.
bx.range_metadata(llval, 0..2);
}
}
- // We store bools as i8 so we need to truncate to i1.
+ // We store bools as `i8` so we need to truncate to `i1`.
llval = base::to_immediate(bx, llval, arg.layout);
}
}
fn_ret: &ArgType<'tcx, Ty<'tcx>>,
llargs: &mut Vec<Bx::Value>, is_intrinsic: bool
) -> ReturnDest<'tcx, Bx::Value> {
- // If the return is ignored, we can just return a do-nothing ReturnDest
+ // If the return is ignored, we can just return a do-nothing `ReturnDest`.
if fn_ret.is_ignore() {
return ReturnDest::Nothing;
}
LocalRef::Place(dest) => dest,
LocalRef::UnsizedPlace(_) => bug!("return type must be sized"),
LocalRef::Operand(None) => {
- // Handle temporary places, specifically Operand ones, as
- // they don't have allocas
+ // Handle temporary places, specifically `Operand` ones, as
+ // they don't have `alloca`s.
return if fn_ret.is_indirect() {
// Odd, but possible, case, we have an operand temporary,
// but the calling convention has an indirect return.
ReturnDest::IndirectOperand(tmp, index)
} else if is_intrinsic {
// Currently, intrinsics always need a location to store
- // the result. so we create a temporary alloca for the
- // result
+ // the result, so we create a temporary `alloca` for the
+ // result.
let tmp = PlaceRef::alloca(bx, fn_ret.layout, "tmp_ret");
tmp.storage_live(bx);
ReturnDest::IndirectOperand(tmp, index)
if dest.align < dest.layout.align.abi {
// Currently, MIR code generation does not create calls
// that store directly to fields of packed structs (in
- // fact, the calls it creates write only to temps),
+ // fact, the calls it creates write only to temps).
//
// If someone changes that, please update this code path
// to create a temporary.
}
enum ReturnDest<'tcx, V> {
- // Do nothing, the return value is indirect or ignored
+ // Do nothing; the return value is indirect or ignored.
Nothing,
- // Store the return value to the pointer
+ // Store the return value to the pointer.
Store(PlaceRef<'tcx, V>),
- // Stores an indirect return value to an operand local place
+ // Store an indirect return value to an operand local place.
IndirectOperand(PlaceRef<'tcx, V>, mir::Local),
- // Stores a direct return value to an operand local place
+ // Store a direct return value to an operand local place.
DirectOperand(mir::Local)
}