Skip to content

Commit b4626b3

Browse files
authored
Merge pull request rust-lang#209 from rust-lang/2022-08-26_sync_from_rust
2022/08/26 sync from rust
2 parents b4eb2c3 + 61a7b96 commit b4626b3

30 files changed

+192
-149
lines changed

example/alloc_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ mod platform {
156156
struct Header(*mut u8);
157157
const HEAP_ZERO_MEMORY: DWORD = 0x00000008;
158158
unsafe fn get_header<'a>(ptr: *mut u8) -> &'a mut Header {
159-
&mut *(ptr as *mut Header).offset(-1)
159+
&mut *(ptr as *mut Header).sub(1)
160160
}
161161
unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 {
162162
let aligned = ptr.add(align - (ptr as usize & (align - 1)));

example/mini_core.rs

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(
22
no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
3-
untagged_unions, decl_macro, rustc_attrs, transparent_unions, auto_traits,
3+
decl_macro, rustc_attrs, transparent_unions, auto_traits,
44
thread_local
55
)]
66
#![no_core]
@@ -39,14 +39,14 @@ impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut
3939
impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
4040
// *mut T -> *mut U
4141
impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
42-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
42+
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}
4343

4444
#[lang = "receiver"]
4545
pub trait Receiver {}
4646

4747
impl<T: ?Sized> Receiver for &T {}
4848
impl<T: ?Sized> Receiver for &mut T {}
49-
impl<T: ?Sized> Receiver for Box<T> {}
49+
impl<T: ?Sized, A: Allocator> Receiver for Box<T, A> {}
5050

5151
#[lang = "copy"]
5252
pub unsafe trait Copy {}
@@ -411,7 +411,15 @@ pub trait FnMut<Args>: FnOnce<Args> {
411411

412412
#[lang = "panic"]
413413
#[track_caller]
414-
pub fn panic(_msg: &str) -> ! {
414+
pub fn panic(_msg: &'static str) -> ! {
415+
unsafe {
416+
libc::puts("Panicking\n\0" as *const str as *const u8);
417+
intrinsics::abort();
418+
}
419+
}
420+
421+
#[lang = "panic_no_unwind"]
422+
fn panic_no_unwind() -> ! {
415423
unsafe {
416424
libc::puts("Panicking\n\0" as *const str as *const u8);
417425
intrinsics::abort();
@@ -450,25 +458,40 @@ pub trait Deref {
450458
pub trait Allocator {
451459
}
452460

461+
impl Allocator for () {}
462+
453463
pub struct Global;
454464

455465
impl Allocator for Global {}
456466

467+
#[repr(transparent)]
468+
#[rustc_layout_scalar_valid_range_start(1)]
469+
#[rustc_nonnull_optimization_guaranteed]
470+
pub struct NonNull<T: ?Sized>(pub *const T);
471+
472+
impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
473+
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
474+
475+
pub struct Unique<T: ?Sized> {
476+
pub pointer: NonNull<T>,
477+
pub _marker: PhantomData<T>,
478+
}
479+
480+
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
481+
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
482+
457483
#[lang = "owned_box"]
458-
pub struct Box<
459-
T: ?Sized,
460-
A: Allocator = Global,
461-
>(*mut T, A);
484+
pub struct Box<T: ?Sized, A: Allocator = Global>(Unique<T>, A);
462485

463-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
486+
impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> for Box<T, A> {}
464487

465488
impl<T: ?Sized, A: Allocator> Drop for Box<T, A> {
466489
fn drop(&mut self) {
467490
// drop is currently performed by compiler.
468491
}
469492
}
470493

471-
impl<T> Deref for Box<T> {
494+
impl<T: ?Sized, A: Allocator> Deref for Box<T, A> {
472495
type Target = T;
473496

474497
fn deref(&self) -> &Self::Target {
@@ -482,8 +505,8 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
482505
}
483506

484507
#[lang = "box_free"]
485-
unsafe fn box_free<T: ?Sized, A: Allocator>(ptr: *mut T, alloc: A) {
486-
libc::free(ptr as *mut u8);
508+
unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, _alloc: ()) {
509+
libc::free(ptr.pointer.0 as *mut u8);
487510
}
488511

489512
#[lang = "drop"]
@@ -505,16 +528,18 @@ pub union MaybeUninit<T> {
505528
}
506529

507530
pub mod intrinsics {
531+
use crate::Sized;
532+
508533
extern "rust-intrinsic" {
509534
pub fn abort() -> !;
510535
pub fn size_of<T>() -> usize;
511-
pub fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
536+
pub fn size_of_val<T: ?Sized>(val: *const T) -> usize;
512537
pub fn min_align_of<T>() -> usize;
513-
pub fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
538+
pub fn min_align_of_val<T: ?Sized>(val: *const T) -> usize;
514539
pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
515540
pub fn transmute<T, U>(e: T) -> U;
516541
pub fn ctlz_nonzero<T>(x: T) -> T;
517-
pub fn needs_drop<T>() -> bool;
542+
pub fn needs_drop<T: ?Sized>() -> bool;
518543
pub fn bitreverse<T>(x: T) -> T;
519544
pub fn bswap<T>(x: T) -> T;
520545
pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);

example/mini_core_hello_world.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ struct NoisyDrop {
4747
inner: NoisyDropInner,
4848
}
4949

50+
struct NoisyDropUnsized {
51+
inner: NoisyDropInner,
52+
text: str,
53+
}
54+
5055
struct NoisyDropInner;
5156

5257
impl Drop for NoisyDrop {
@@ -184,7 +189,9 @@ fn main() {
184189
assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8);
185190

186191
assert!(!intrinsics::needs_drop::<u8>());
192+
assert!(!intrinsics::needs_drop::<[u8]>());
187193
assert!(intrinsics::needs_drop::<NoisyDrop>());
194+
assert!(intrinsics::needs_drop::<NoisyDropUnsized>());
188195

189196
Unique {
190197
pointer: 0 as *const &str,

failing-ui-tests.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@ src/test/ui/allocator/xcrate-use.rs
99
src/test/ui/allocator/xcrate-use2.rs
1010
src/test/ui/asm/may_unwind.rs
1111
src/test/ui/asm/x86_64/const.rs
12+
src/test/ui/asm/x86_64/issue-96797.rs
1213
src/test/ui/asm/x86_64/multiple-clobber-abi.rs
1314
src/test/ui/async-await/async-fn-size-moved-locals.rs
1415
src/test/ui/async-await/async-fn-size-uninit-locals.rs
15-
src/test/ui/backtrace.rs
1616
src/test/ui/cfg/cfg-panic.rs
1717
src/test/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs
1818
src/test/ui/functions-closures/parallel-codegen-closures.rs
1919
src/test/ui/generator/size-moved-locals.rs
20-
src/test/ui/issues/issue-32518.rs
20+
src/test/ui/issues/issue-40883.rs
2121
src/test/ui/issues/issue-47364.rs
22-
src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs
2322
src/test/ui/linkage-attr/linkage1.rs
2423
src/test/ui/lto/dylib-works.rs
25-
src/test/ui/mir/mir_heavy_promoted.rs
24+
src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs
25+
src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs
2626
src/test/ui/numbers-arithmetic/saturating-float-casts.rs
2727
src/test/ui/polymorphization/promoted-function.rs
28+
src/test/ui/process/nofile-limit.rs
2829
src/test/ui/runtime/rt-explody-panic-payloads.rs
2930
src/test/ui/sepcomp/sepcomp-cci.rs
3031
src/test/ui/sepcomp/sepcomp-extern.rs
3132
src/test/ui/sepcomp/sepcomp-fns-backwards.rs
3233
src/test/ui/sepcomp/sepcomp-fns.rs
33-
src/test/ui/sepcomp/sepcomp-lib.rs
3434
src/test/ui/sepcomp/sepcomp-statics.rs
3535
src/test/ui/simd/generics.rs
3636
src/test/ui/simd/intrinsic/float-math-pass.rs
Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
1-
From b1ae000f6da1abd3b8e9b80c40bc11c89b8ae93c Mon Sep 17 00:00:00 2001
2-
From: bjorn3 <bjorn3@users.noreply.github.com>
3-
Date: Thu, 30 Dec 2021 16:54:40 +0100
4-
Subject: [PATCH] [core] Disable portable-simd test
1+
From f845df4056f5ba16b9f5bd703460c4ac40ea03b9 Mon Sep 17 00:00:00 2001
2+
From: Antoni Boucher <bouanto@zoho.com>
3+
Date: Fri, 26 Aug 2022 20:38:58 -0400
4+
Subject: [PATCH] Edit
55

66
---
7-
library/core/tests/lib.rs | 1 -
8-
1 file changed, 1 deletion(-)
7+
library/core/tests/lib.rs | 2 --
8+
1 file changed, 2 deletions(-)
99

1010
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
11-
index 06c7be0..359e2e7 100644
11+
index 59510d3..179bf26 100644
1212
--- a/library/core/tests/lib.rs
1313
+++ b/library/core/tests/lib.rs
14-
@@ -75,7 +75,6 @@
15-
#![feature(never_type)]
14+
@@ -77,7 +77,6 @@
1615
#![feature(unwrap_infallible)]
1716
#![feature(result_into_ok_or_err)]
17+
#![feature(pointer_byte_offsets)]
1818
-#![feature(portable_simd)]
1919
#![feature(ptr_metadata)]
2020
#![feature(once_cell)]
2121
#![feature(option_result_contains)]
22-
@@ -127,7 +126,6 @@ mod pin;
22+
@@ -135,7 +134,6 @@ mod pin;
2323
mod pin_macro;
2424
mod ptr;
2525
mod result;
2626
-mod simd;
2727
mod slice;
2828
mod str;
2929
mod str_lossy;
30+
--
31+
2.26.2.7.g19db9cfb68.dirty
32+

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2022-06-06"
2+
channel = "nightly-2022-08-26"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

src/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use gccjit::{ToLValue, ToRValue, Type};
22
use rustc_codegen_ssa::traits::{AbiBuilderMethods, BaseTypeMethods};
3-
use rustc_data_structures::stable_set::FxHashSet;
3+
use rustc_data_structures::fx::FxHashSet;
44
use rustc_middle::bug;
55
use rustc_middle::ty::Ty;
66
use rustc_target::abi::call::{CastTarget, FnAbi, PassMode, Reg, RegKind};

src/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam
127127

128128
let name = OomStrategy::SYMBOL.to_string();
129129
let global = context.new_global(None, GlobalKind::Exported, i8, name);
130-
let value = tcx.sess.opts.debugging_opts.oom.should_panic();
130+
let value = tcx.sess.opts.unstable_opts.oom.should_panic();
131131
let value = context.new_rvalue_from_int(i8, value as i32);
132132
global.global_set_initializer_rvalue(value);
133133
}

0 commit comments

Comments
 (0)