Skip to content

Commit f2cdd4a

Browse files
committed
Rustup to rustc 1.62.0-nightly (879aff3 2022-04-20)
1 parent acb32e6 commit f2cdd4a

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

build_sysroot/Cargo.lock

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/mini_core.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,20 @@ pub trait Deref {
494494
fn deref(&self) -> &Self::Target;
495495
}
496496

497+
#[repr(transparent)]
498+
#[rustc_layout_scalar_valid_range_start(1)]
499+
#[rustc_nonnull_optimization_guaranteed]
500+
pub struct NonNull<T: ?Sized>(pub *mut T);
501+
502+
impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
503+
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
504+
497505
pub struct Unique<T: ?Sized> {
498-
pub pointer: *const T,
506+
pub pointer: NonNull<T>,
499507
pub _marker: PhantomData<T>,
500508
}
501509

502510
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
503-
504511
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
505512

506513
#[lang = "owned_box"]
@@ -529,7 +536,7 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
529536

530537
#[lang = "box_free"]
531538
unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, alloc: ()) {
532-
libc::free(ptr.pointer as *mut u8);
539+
libc::free(ptr.pointer.0 as *mut u8);
533540
}
534541

535542
#[lang = "drop"]

example/mini_core_hello_world.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn call_return_u128_pair() {
122122
#[allow(unreachable_code)] // FIXME false positive
123123
fn main() {
124124
take_unique(Unique {
125-
pointer: 0 as *const (),
125+
pointer: unsafe { NonNull(1 as *mut ()) },
126126
_marker: PhantomData,
127127
});
128128
take_f32(0.1);
@@ -173,7 +173,7 @@ fn main() {
173173
assert!(intrinsics::needs_drop::<NoisyDrop>());
174174

175175
Unique {
176-
pointer: 0 as *const &str,
176+
pointer: NonNull(1 as *mut &str),
177177
_marker: PhantomData,
178178
} as Unique<dyn SomeTrait>;
179179

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2022-04-05"
2+
channel = "nightly-2022-04-21"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

src/base.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,8 @@ pub(crate) fn codegen_place<'tcx>(
821821
if cplace.layout().ty.is_box() {
822822
cplace = cplace
823823
.place_field(fx, Field::new(0)) // Box<T> -> Unique<T>
824-
.place_field(fx, Field::new(0)) // Unique<T> -> *const T
824+
.place_field(fx, Field::new(0)) // Unique<T> -> NonNull<T>
825+
.place_field(fx, Field::new(0)) // NonNull<T> -> *mut T
825826
.place_deref(fx);
826827
} else {
827828
cplace = cplace.place_deref(fx);

src/discriminant.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,16 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
128128
let relative_discr = if niche_start == 0 {
129129
tag
130130
} else {
131-
// FIXME handle niche_start > i64::MAX
132-
fx.bcx.ins().iadd_imm(tag, -i64::try_from(niche_start).unwrap())
131+
let niche_start = match fx.bcx.func.dfg.value_type(tag) {
132+
types::I128 => {
133+
let lsb = fx.bcx.ins().iconst(types::I64, niche_start as u64 as i64);
134+
let msb =
135+
fx.bcx.ins().iconst(types::I64, (niche_start >> 64) as u64 as i64);
136+
fx.bcx.ins().iconcat(lsb, msb)
137+
}
138+
ty => fx.bcx.ins().iconst(ty, niche_start as i64),
139+
};
140+
fx.bcx.ins().isub(tag, niche_start)
133141
};
134142
let relative_max = niche_variants.end().as_u32() - niche_variants.start().as_u32();
135143
let is_niche = {

0 commit comments

Comments
 (0)