Rustup to rustc 1.38.0-nightly (dfd52ba6a 2019-07-06)

This commit is contained in:
bjorn3 2019-07-07 11:59:11 +02:00
parent 69591844bb
commit b82472184d
6 changed files with 35 additions and 33 deletions

View File

@ -23,7 +23,6 @@
feature(integer_atomics, stdsimd) feature(integer_atomics, stdsimd)
)] )]
#![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))] #![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))]
#![rustc_alloc_kind = "lib"]
// The minimum alignment guaranteed by the architecture. This value is used to // The minimum alignment guaranteed by the architecture. This value is used to
// add fast paths for low alignment values. // add fast paths for low alignment values.
#[cfg(all(any(target_arch = "x86", #[cfg(all(any(target_arch = "x86",

View File

@ -137,10 +137,6 @@ unsafe fn transmute(c: char) -> u32 {
intrinsics::transmute(c) intrinsics::transmute(c)
} }
unsafe fn call_uninit() -> u8 {
intrinsics::uninit()
}
unsafe fn deref_str_ptr(s: *const str) -> &'static str { unsafe fn deref_str_ptr(s: *const str) -> &'static str {
&*s &*s
} }

View File

@ -1,4 +1,4 @@
#![feature(no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types)] #![feature(no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types, untagged_unions)]
#![no_core] #![no_core]
#![allow(dead_code)] #![allow(dead_code)]
@ -371,6 +371,11 @@ pub trait Drop {
fn drop(&mut self); fn drop(&mut self);
} }
pub union MaybeUninit<T> {
pub uninit: (),
pub value: T,
}
pub mod intrinsics { pub mod intrinsics {
extern "rust-intrinsic" { extern "rust-intrinsic" {
pub fn abort() -> !; pub fn abort() -> !;
@ -380,7 +385,6 @@ pub mod intrinsics {
pub fn min_align_of_val<T: ?::Sized>(val: &T) -> usize; pub fn min_align_of_val<T: ?::Sized>(val: &T) -> usize;
pub fn copy<T>(src: *const T, dst: *mut T, count: usize); pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
pub fn transmute<T, U>(e: T) -> U; pub fn transmute<T, U>(e: T) -> U;
pub fn uninit<T>() -> T;
pub fn init<T>() -> T; pub fn init<T>() -> T;
pub fn ctlz_nonzero<T>(x: T) -> T; pub fn ctlz_nonzero<T>(x: T) -> T;
pub fn needs_drop<T>() -> bool; pub fn needs_drop<T>() -> bool;

View File

@ -181,15 +181,15 @@ fn main() {
} }
unsafe fn uninitialized<T>() -> T { unsafe fn uninitialized<T>() -> T {
intrinsics::uninit::<T>() MaybeUninit { uninit: () }.value
} }
zeroed::<(u8, u8)>();
#[allow(unreachable_code)] #[allow(unreachable_code)]
{ {
if false { if false {
zeroed::<!>(); zeroed::<!>();
zeroed::<Foo>(); zeroed::<Foo>();
zeroed::<(u8, u8)>();
uninitialized::<Foo>(); uninitialized::<Foo>();
} }
} }

View File

@ -5,7 +5,7 @@ use rustc::mir::interpret::{
}; };
use rustc::ty::Const; use rustc::ty::Const;
use rustc_mir::interpret::{ use rustc_mir::interpret::{
InterpretCx, ImmTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, InterpCx, ImmTy, Machine, Memory, MemoryKind, OpTy, PlaceTy,
StackPopCleanup, StackPopCleanup,
}; };
@ -141,10 +141,11 @@ fn trans_const_place<'a, 'tcx: 'a>(
) -> CPlace<'tcx> { ) -> CPlace<'tcx> {
// Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551 // Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551
let result = || -> InterpResult<'tcx, &'tcx Allocation> { let result = || -> InterpResult<'tcx, &'tcx Allocation> {
let mut ecx = InterpretCx::new( let mut ecx = InterpCx::new(
fx.tcx.at(DUMMY_SP), fx.tcx.at(DUMMY_SP),
ty::ParamEnv::reveal_all(), ty::ParamEnv::reveal_all(),
TransPlaceInterpreter, TransPlaceInterpreter,
(),
); );
ecx.push_stack_frame( ecx.push_stack_frame(
fx.instance, fx.instance,
@ -242,7 +243,7 @@ fn define_all_allocs(
module: &mut Module<impl Backend>, module: &mut Module<impl Backend>,
cx: &mut ConstantCx, cx: &mut ConstantCx,
) { ) {
let memory = Memory::<TransPlaceInterpreter>::new(tcx.at(DUMMY_SP)); let memory = Memory::<TransPlaceInterpreter>::new(tcx.at(DUMMY_SP), ());
while let Some(todo_item) = pop_set(&mut cx.todo) { while let Some(todo_item) = pop_set(&mut cx.todo) {
let (data_id, alloc) = match todo_item { let (data_id, alloc) = match todo_item {
@ -338,23 +339,25 @@ struct TransPlaceInterpreter;
impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter {
type MemoryKinds = !; type MemoryKinds = !;
type ExtraFnVal = !;
type PointerTag = (); type PointerTag = ();
type AllocExtra = (); type AllocExtra = ();
type MemoryExtra = (); type MemoryExtra = ();
type FrameExtra = (); type FrameExtra = ();
type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation<()>)>; type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation<()>)>;
const STATIC_KIND: Option<!> = None; const STATIC_KIND: Option<!> = None;
fn enforce_validity(_: &InterpretCx<'mir, 'tcx, Self>) -> bool { fn enforce_validity(_: &InterpCx<'mir, 'tcx, Self>) -> bool {
false false
} }
fn before_terminator(_: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { fn before_terminator(_: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
panic!(); panic!();
} }
fn find_fn( fn find_fn(
_: &mut InterpretCx<'mir, 'tcx, Self>, _: &mut InterpCx<'mir, 'tcx, Self>,
_: Instance<'tcx>, _: Instance<'tcx>,
_: &[OpTy<'tcx>], _: &[OpTy<'tcx>],
_: Option<PlaceTy<'tcx>>, _: Option<PlaceTy<'tcx>>,
@ -364,7 +367,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter {
} }
fn call_intrinsic( fn call_intrinsic(
_: &mut InterpretCx<'mir, 'tcx, Self>, _: &mut InterpCx<'mir, 'tcx, Self>,
_: Instance<'tcx>, _: Instance<'tcx>,
_: &[OpTy<'tcx>], _: &[OpTy<'tcx>],
_: PlaceTy<'tcx>, _: PlaceTy<'tcx>,
@ -373,14 +376,14 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter {
} }
fn find_foreign_static( fn find_foreign_static(
_: TyCtxt<'tcx>,
_: DefId, _: DefId,
_: ::rustc::ty::query::TyCtxtAt<'tcx>,
) -> InterpResult<'tcx, Cow<'tcx, Allocation>> { ) -> InterpResult<'tcx, Cow<'tcx, Allocation>> {
panic!(); panic!();
} }
fn ptr_op( fn ptr_op(
_: &InterpretCx<'mir, 'tcx, Self>, _: &InterpCx<'mir, 'tcx, Self>,
_: mir::BinOp, _: mir::BinOp,
_: ImmTy<'tcx>, _: ImmTy<'tcx>,
_: ImmTy<'tcx>, _: ImmTy<'tcx>,
@ -388,28 +391,38 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter {
panic!(); panic!();
} }
fn box_alloc(_: &mut InterpretCx<'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> InterpResult<'tcx> { fn box_alloc(_: &mut InterpCx<'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> InterpResult<'tcx> {
panic!(); panic!();
} }
fn tag_allocation<'b>( fn tag_allocation<'b>(
_: &(),
_: AllocId, _: AllocId,
alloc: Cow<'b, Allocation>, alloc: Cow<'b, Allocation>,
_: Option<MemoryKind<!>>, _: Option<MemoryKind<!>>,
_: &Memory<'mir, 'tcx, Self>,
) -> (Cow<'b, Allocation<(), ()>>, ()) { ) -> (Cow<'b, Allocation<(), ()>>, ()) {
(alloc, ()) (alloc, ())
} }
fn tag_static_base_pointer(_: AllocId, _: &Memory<'mir, 'tcx, Self>) -> Self::PointerTag { fn tag_static_base_pointer(_: &(), _: AllocId) -> Self::PointerTag {
() ()
} }
fn stack_push(_: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { fn call_extra_fn(
_: &mut InterpCx<'mir, 'tcx, Self>,
_: !,
_: &[OpTy<'tcx, ()>],
_: Option<PlaceTy<'tcx, ()>>,
_: Option<BasicBlock>,
) -> InterpResult<'tcx> {
unreachable!();
}
fn stack_push(_: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
Ok(()) Ok(())
} }
fn stack_pop(_: &mut InterpretCx<'mir, 'tcx, Self>, _: ()) -> InterpResult<'tcx> { fn stack_pop(_: &mut InterpCx<'mir, 'tcx, Self>, _: ()) -> InterpResult<'tcx> {
Ok(()) Ok(())
} }
} }

View File

@ -389,16 +389,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>(
let dst_ptr = dst.load_scalar(fx); let dst_ptr = dst.load_scalar(fx);
fx.bcx.call_memset(fx.module.target_config(), dst_ptr, val, count); fx.bcx.call_memset(fx.module.target_config(), dst_ptr, val, count);
}; };
uninit, <T> () {
if ret.layout().abi == Abi::Uninhabited {
crate::trap::trap_panic(fx, "[panic] Called intrinsic::uninit for uninhabited type.");
return;
}
let uninit_place = CPlace::new_stack_slot(fx, T);
let uninit_val = uninit_place.to_cvalue(fx);
ret.write_cvalue(fx, uninit_val);
};
ctlz | ctlz_nonzero, <T> (v arg) { ctlz | ctlz_nonzero, <T> (v arg) {
let res = CValue::by_val(fx.bcx.ins().clz(arg), fx.layout_of(T)); let res = CValue::by_val(fx.bcx.ins().clz(arg), fx.layout_of(T));
ret.write_cvalue(fx, res); ret.write_cvalue(fx, res);