Eagerly convert some ctors to use their specialized ctors
This commit is contained in:
parent
24db8eaefd
commit
81e7e80990
12 changed files with 31 additions and 86 deletions
|
@ -5,7 +5,7 @@ use rustc_middle::mir::{
|
|||
interpret::Scalar,
|
||||
visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor},
|
||||
};
|
||||
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, TypeAndMut};
|
||||
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt};
|
||||
use rustc_session::Session;
|
||||
|
||||
pub struct CheckAlignment;
|
||||
|
@ -157,7 +157,7 @@ fn insert_alignment_check<'tcx>(
|
|||
new_block: BasicBlock,
|
||||
) {
|
||||
// Cast the pointer to a *const ()
|
||||
let const_raw_ptr = Ty::new_ptr(tcx, TypeAndMut { ty: tcx.types.unit, mutbl: Mutability::Not });
|
||||
let const_raw_ptr = Ty::new_imm_ptr(tcx, tcx.types.unit);
|
||||
let rvalue = Rvalue::Cast(CastKind::PtrToPtr, Operand::Copy(pointer), const_raw_ptr);
|
||||
let thin_ptr = local_decls.push(LocalDecl::with_source_info(const_raw_ptr, source_info)).into();
|
||||
block_data
|
||||
|
|
|
@ -570,11 +570,7 @@ impl<'tcx> MutVisitor<'tcx> for TransformVisitor<'tcx> {
|
|||
fn make_coroutine_state_argument_indirect<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
let coroutine_ty = body.local_decls.raw[1].ty;
|
||||
|
||||
let ref_coroutine_ty = Ty::new_ref(
|
||||
tcx,
|
||||
tcx.lifetimes.re_erased,
|
||||
ty::TypeAndMut { ty: coroutine_ty, mutbl: Mutability::Mut },
|
||||
);
|
||||
let ref_coroutine_ty = Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, coroutine_ty);
|
||||
|
||||
// Replace the by value coroutine argument
|
||||
body.local_decls.raw[1].ty = ref_coroutine_ty;
|
||||
|
@ -1265,10 +1261,8 @@ fn create_coroutine_drop_shim<'tcx>(
|
|||
make_coroutine_state_argument_indirect(tcx, &mut body);
|
||||
|
||||
// Change the coroutine argument from &mut to *mut
|
||||
body.local_decls[SELF_ARG] = LocalDecl::with_source_info(
|
||||
Ty::new_ptr(tcx, ty::TypeAndMut { ty: coroutine_ty, mutbl: hir::Mutability::Mut }),
|
||||
source_info,
|
||||
);
|
||||
body.local_decls[SELF_ARG] =
|
||||
LocalDecl::with_source_info(Ty::new_mut_ptr(tcx, coroutine_ty), source_info);
|
||||
|
||||
// Make sure we remove dead blocks to remove
|
||||
// unrelated code from the resume part of the function
|
||||
|
|
|
@ -539,14 +539,8 @@ impl<'tcx> CloneShimBuilder<'tcx> {
|
|||
const_: Const::zero_sized(func_ty),
|
||||
}));
|
||||
|
||||
let ref_loc = self.make_place(
|
||||
Mutability::Not,
|
||||
Ty::new_ref(
|
||||
tcx,
|
||||
tcx.lifetimes.re_erased,
|
||||
ty::TypeAndMut { ty, mutbl: hir::Mutability::Not },
|
||||
),
|
||||
);
|
||||
let ref_loc =
|
||||
self.make_place(Mutability::Not, Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, ty));
|
||||
|
||||
// `let ref_loc: &ty = &src;`
|
||||
let statement = self.make_statement(StatementKind::Assign(Box::new((
|
||||
|
@ -771,11 +765,7 @@ fn build_call_shim<'tcx>(
|
|||
// let rcvr = &mut rcvr;
|
||||
let ref_rcvr = local_decls.push(
|
||||
LocalDecl::new(
|
||||
Ty::new_ref(
|
||||
tcx,
|
||||
tcx.lifetimes.re_erased,
|
||||
ty::TypeAndMut { ty: sig.inputs()[0], mutbl: hir::Mutability::Mut },
|
||||
),
|
||||
Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, sig.inputs()[0]),
|
||||
span,
|
||||
)
|
||||
.immutable(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue