Sync from rust 993deaa0bf
This commit is contained in:
commit
2922d41fa5
@ -670,7 +670,8 @@ pub(crate) fn codegen_drop<'tcx>(
|
||||
|
||||
let arg_value = drop_place.place_ref(
|
||||
fx,
|
||||
fx.layout_of(fx.tcx.mk_ref(
|
||||
fx.layout_of(Ty::new_ref(
|
||||
fx.tcx,
|
||||
fx.tcx.lifetimes.re_erased,
|
||||
TypeAndMut { ty, mutbl: crate::rustc_hir::Mutability::Mut },
|
||||
)),
|
||||
|
23
src/base.rs
23
src/base.rs
@ -2,7 +2,7 @@
|
||||
|
||||
use rustc_ast::InlineAsmOptions;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::adjustment::PointerCoercion;
|
||||
use rustc_middle::ty::layout::FnAbiOf;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
|
||||
@ -592,7 +592,7 @@ fn codegen_stmt<'tcx>(
|
||||
lval.write_cvalue(fx, res);
|
||||
}
|
||||
Rvalue::Cast(
|
||||
CastKind::Pointer(PointerCast::ReifyFnPointer),
|
||||
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer),
|
||||
ref operand,
|
||||
to_ty,
|
||||
) => {
|
||||
@ -617,17 +617,17 @@ fn codegen_stmt<'tcx>(
|
||||
}
|
||||
}
|
||||
Rvalue::Cast(
|
||||
CastKind::Pointer(PointerCast::UnsafeFnPointer),
|
||||
CastKind::PointerCoercion(PointerCoercion::UnsafeFnPointer),
|
||||
ref operand,
|
||||
to_ty,
|
||||
)
|
||||
| Rvalue::Cast(
|
||||
CastKind::Pointer(PointerCast::MutToConstPointer),
|
||||
CastKind::PointerCoercion(PointerCoercion::MutToConstPointer),
|
||||
ref operand,
|
||||
to_ty,
|
||||
)
|
||||
| Rvalue::Cast(
|
||||
CastKind::Pointer(PointerCast::ArrayToPointer),
|
||||
CastKind::PointerCoercion(PointerCoercion::ArrayToPointer),
|
||||
ref operand,
|
||||
to_ty,
|
||||
) => {
|
||||
@ -683,7 +683,7 @@ fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
}
|
||||
}
|
||||
Rvalue::Cast(
|
||||
CastKind::Pointer(PointerCast::ClosureFnPointer(_)),
|
||||
CastKind::PointerCoercion(PointerCoercion::ClosureFnPointer(_)),
|
||||
ref operand,
|
||||
_to_ty,
|
||||
) => {
|
||||
@ -705,7 +705,11 @@ fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
_ => bug!("{} cannot be cast to a fn ptr", operand.layout().ty),
|
||||
}
|
||||
}
|
||||
Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), ref operand, _to_ty) => {
|
||||
Rvalue::Cast(
|
||||
CastKind::PointerCoercion(PointerCoercion::Unsize),
|
||||
ref operand,
|
||||
_to_ty,
|
||||
) => {
|
||||
let operand = codegen_operand(fx, operand);
|
||||
crate::unsize::coerce_unsized_into(fx, operand, lval);
|
||||
}
|
||||
@ -727,7 +731,6 @@ fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
let times = fx
|
||||
.monomorphize(times)
|
||||
.eval(fx.tcx, ParamEnv::reveal_all())
|
||||
.kind()
|
||||
.try_to_bits(fx.tcx.data_layout.pointer_size)
|
||||
.unwrap();
|
||||
if operand.layout().size.bytes() == 0 {
|
||||
@ -768,7 +771,7 @@ fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
}
|
||||
Rvalue::ShallowInitBox(ref operand, content_ty) => {
|
||||
let content_ty = fx.monomorphize(content_ty);
|
||||
let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty));
|
||||
let box_layout = fx.layout_of(Ty::new_box(fx.tcx, content_ty));
|
||||
let operand = codegen_operand(fx, operand);
|
||||
let operand = operand.load_scalar(fx);
|
||||
lval.write_cvalue(fx, CValue::by_val(operand, box_layout));
|
||||
@ -909,7 +912,7 @@ pub(crate) fn codegen_place<'tcx>(
|
||||
let ptr = cplace.to_ptr();
|
||||
cplace = CPlace::for_ptr(
|
||||
ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)),
|
||||
fx.layout_of(fx.tcx.mk_array(*elem_ty, to - from)),
|
||||
fx.layout_of(Ty::new_array(fx.tcx, *elem_ty, to - from)),
|
||||
);
|
||||
}
|
||||
ty::Slice(elem_ty) => {
|
||||
|
@ -92,7 +92,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
|
||||
match bin_op {
|
||||
BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => unreachable!(),
|
||||
BinOp::Mul if is_signed => {
|
||||
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
|
||||
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
|
||||
let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
|
||||
let lhs = lhs.load_scalar(fx);
|
||||
let rhs = rhs.load_scalar(fx);
|
||||
@ -112,7 +112,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
|
||||
Some(CValue::by_val_pair(res, oflow, fx.layout_of(out_ty)))
|
||||
}
|
||||
BinOp::Add | BinOp::Sub | BinOp::Mul => {
|
||||
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
|
||||
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
|
||||
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
|
||||
let param_types = vec![
|
||||
AbiParam::special(fx.pointer_type, ArgumentPurpose::StructReturn),
|
||||
|
@ -99,7 +99,7 @@ fn clif_pair_type_from_ty<'tcx>(
|
||||
|
||||
/// Is a pointer to this type a fat ptr?
|
||||
pub(crate) fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc_hir::Mutability::Not });
|
||||
let ptr_ty = Ty::new_ptr(tcx, TypeAndMut { ty, mutbl: rustc_hir::Mutability::Not });
|
||||
match &tcx.layout_of(ParamEnv::reveal_all().and(ptr_ty)).unwrap().abi {
|
||||
Abi::Scalar(_) => false,
|
||||
Abi::ScalarPair(_, _) => true,
|
||||
|
@ -81,7 +81,7 @@ pub(crate) fn get_span_loc(
|
||||
|
||||
match tcx.sess.source_map().lookup_line(span.lo()) {
|
||||
Ok(SourceFileAndLine { sf: file, line }) => {
|
||||
let line_pos = file.line_begin_pos(span.lo());
|
||||
let line_pos = file.lines(|lines| lines[line]);
|
||||
|
||||
(
|
||||
file,
|
||||
|
@ -270,7 +270,7 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
|
||||
_ => bug!("binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", bin_op, in_lhs, in_rhs),
|
||||
};
|
||||
|
||||
let out_layout = fx.layout_of(fx.tcx.mk_tup(&[in_lhs.layout().ty, fx.tcx.types.bool]));
|
||||
let out_layout = fx.layout_of(Ty::new_tup(fx.tcx, &[in_lhs.layout().ty, fx.tcx.types.bool]));
|
||||
CValue::by_val_pair(res, has_overflow, out_layout)
|
||||
}
|
||||
|
||||
|
@ -225,10 +225,10 @@ pub(crate) fn write_ir_file(
|
||||
let res = std::fs::File::create(clif_file_name).and_then(|mut file| write(&mut file));
|
||||
if let Err(err) = res {
|
||||
// Using early_warn as no Session is available here
|
||||
rustc_session::early_warn(
|
||||
let handler = rustc_session::EarlyErrorHandler::new(
|
||||
rustc_session::config::ErrorOutputType::default(),
|
||||
format!("error writing ir file: {}", err),
|
||||
);
|
||||
handler.early_warn(format!("error writing ir file: {}", err));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Codegen of the [`PointerCast::Unsize`] operation.
|
||||
//! Codegen of the [`PointerCoercion::Unsize`] operation.
|
||||
//!
|
||||
//! [`PointerCast::Unsize`]: `rustc_middle::ty::adjustment::PointerCast::Unsize`
|
||||
//! [`PointerCoercion::Unsize`]: `rustc_middle::ty::adjustment::PointerCoercion::Unsize`
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user