Skip to content

Commit

Permalink
Merge pull request rust-lang#209 from rust-lang/2022-08-26_sync_from_…
Browse files Browse the repository at this point in the history
…rust

2022/08/26 sync from rust
  • Loading branch information
antoyo authored Aug 27, 2022
2 parents b4eb2c3 + 61a7b96 commit b4626b3
Show file tree
Hide file tree
Showing 30 changed files with 192 additions and 149 deletions.
2 changes: 1 addition & 1 deletion example/alloc_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ mod platform {
struct Header(*mut u8);
const HEAP_ZERO_MEMORY: DWORD = 0x00000008;
unsafe fn get_header<'a>(ptr: *mut u8) -> &'a mut Header {
&mut *(ptr as *mut Header).offset(-1)
&mut *(ptr as *mut Header).sub(1)
}
unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 {
let aligned = ptr.add(align - (ptr as usize & (align - 1)));
Expand Down
55 changes: 40 additions & 15 deletions example/mini_core.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(
no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
untagged_unions, decl_macro, rustc_attrs, transparent_unions, auto_traits,
decl_macro, rustc_attrs, transparent_unions, auto_traits,
thread_local
)]
#![no_core]
Expand Down Expand Up @@ -39,14 +39,14 @@ impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut
impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
// *mut T -> *mut U
impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}

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

impl<T: ?Sized> Receiver for &T {}
impl<T: ?Sized> Receiver for &mut T {}
impl<T: ?Sized> Receiver for Box<T> {}
impl<T: ?Sized, A: Allocator> Receiver for Box<T, A> {}

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

#[lang = "panic"]
#[track_caller]
pub fn panic(_msg: &str) -> ! {
pub fn panic(_msg: &'static str) -> ! {
unsafe {
libc::puts("Panicking\n\0" as *const str as *const u8);
intrinsics::abort();
}
}

#[lang = "panic_no_unwind"]
fn panic_no_unwind() -> ! {
unsafe {
libc::puts("Panicking\n\0" as *const str as *const u8);
intrinsics::abort();
Expand Down Expand Up @@ -450,25 +458,40 @@ pub trait Deref {
pub trait Allocator {
}

impl Allocator for () {}

pub struct Global;

impl Allocator for Global {}

#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)]
#[rustc_nonnull_optimization_guaranteed]
pub struct NonNull<T: ?Sized>(pub *const T);

impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}

pub struct Unique<T: ?Sized> {
pub pointer: NonNull<T>,
pub _marker: PhantomData<T>,
}

impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}

#[lang = "owned_box"]
pub struct Box<
T: ?Sized,
A: Allocator = Global,
>(*mut T, A);
pub struct Box<T: ?Sized, A: Allocator = Global>(Unique<T>, A);

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

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

impl<T> Deref for Box<T> {
impl<T: ?Sized, A: Allocator> Deref for Box<T, A> {
type Target = T;

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

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

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

pub mod intrinsics {
use crate::Sized;

extern "rust-intrinsic" {
pub fn abort() -> !;
pub fn size_of<T>() -> usize;
pub fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
pub fn size_of_val<T: ?Sized>(val: *const T) -> usize;
pub fn min_align_of<T>() -> usize;
pub fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
pub fn min_align_of_val<T: ?Sized>(val: *const T) -> usize;
pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
pub fn transmute<T, U>(e: T) -> U;
pub fn ctlz_nonzero<T>(x: T) -> T;
pub fn needs_drop<T>() -> bool;
pub fn needs_drop<T: ?Sized>() -> bool;
pub fn bitreverse<T>(x: T) -> T;
pub fn bswap<T>(x: T) -> T;
pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
Expand Down
7 changes: 7 additions & 0 deletions example/mini_core_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ struct NoisyDrop {
inner: NoisyDropInner,
}

struct NoisyDropUnsized {
inner: NoisyDropInner,
text: str,
}

struct NoisyDropInner;

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

assert!(!intrinsics::needs_drop::<u8>());
assert!(!intrinsics::needs_drop::<[u8]>());
assert!(intrinsics::needs_drop::<NoisyDrop>());
assert!(intrinsics::needs_drop::<NoisyDropUnsized>());

Unique {
pointer: 0 as *const &str,
Expand Down
10 changes: 5 additions & 5 deletions failing-ui-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ src/test/ui/allocator/xcrate-use.rs
src/test/ui/allocator/xcrate-use2.rs
src/test/ui/asm/may_unwind.rs
src/test/ui/asm/x86_64/const.rs
src/test/ui/asm/x86_64/issue-96797.rs
src/test/ui/asm/x86_64/multiple-clobber-abi.rs
src/test/ui/async-await/async-fn-size-moved-locals.rs
src/test/ui/async-await/async-fn-size-uninit-locals.rs
src/test/ui/backtrace.rs
src/test/ui/cfg/cfg-panic.rs
src/test/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs
src/test/ui/functions-closures/parallel-codegen-closures.rs
src/test/ui/generator/size-moved-locals.rs
src/test/ui/issues/issue-32518.rs
src/test/ui/issues/issue-40883.rs
src/test/ui/issues/issue-47364.rs
src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs
src/test/ui/linkage-attr/linkage1.rs
src/test/ui/lto/dylib-works.rs
src/test/ui/mir/mir_heavy_promoted.rs
src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs
src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs
src/test/ui/numbers-arithmetic/saturating-float-casts.rs
src/test/ui/polymorphization/promoted-function.rs
src/test/ui/process/nofile-limit.rs
src/test/ui/runtime/rt-explody-panic-payloads.rs
src/test/ui/sepcomp/sepcomp-cci.rs
src/test/ui/sepcomp/sepcomp-extern.rs
src/test/ui/sepcomp/sepcomp-fns-backwards.rs
src/test/ui/sepcomp/sepcomp-fns.rs
src/test/ui/sepcomp/sepcomp-lib.rs
src/test/ui/sepcomp/sepcomp-statics.rs
src/test/ui/simd/generics.rs
src/test/ui/simd/intrinsic/float-math-pass.rs
Expand Down
23 changes: 13 additions & 10 deletions patches/0024-core-Disable-portable-simd-test.patch
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
From b1ae000f6da1abd3b8e9b80c40bc11c89b8ae93c Mon Sep 17 00:00:00 2001
From: bjorn3 <bjorn3@users.noreply.github.com>
Date: Thu, 30 Dec 2021 16:54:40 +0100
Subject: [PATCH] [core] Disable portable-simd test
From f845df4056f5ba16b9f5bd703460c4ac40ea03b9 Mon Sep 17 00:00:00 2001
From: Antoni Boucher <bouanto@zoho.com>
Date: Fri, 26 Aug 2022 20:38:58 -0400
Subject: [PATCH] Edit

---
library/core/tests/lib.rs | 1 -
1 file changed, 1 deletion(-)
library/core/tests/lib.rs | 2 --
1 file changed, 2 deletions(-)

diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index 06c7be0..359e2e7 100644
index 59510d3..179bf26 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -75,7 +75,6 @@
#![feature(never_type)]
@@ -77,7 +77,6 @@
#![feature(unwrap_infallible)]
#![feature(result_into_ok_or_err)]
#![feature(pointer_byte_offsets)]
-#![feature(portable_simd)]
#![feature(ptr_metadata)]
#![feature(once_cell)]
#![feature(option_result_contains)]
@@ -127,7 +126,6 @@ mod pin;
@@ -135,7 +134,6 @@ mod pin;
mod pin_macro;
mod ptr;
mod result;
-mod simd;
mod slice;
mod str;
mod str_lossy;
--
2.26.2.7.g19db9cfb68.dirty

2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2022-06-06"
channel = "nightly-2022-08-26"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
2 changes: 1 addition & 1 deletion src/abi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gccjit::{ToLValue, ToRValue, Type};
use rustc_codegen_ssa::traits::{AbiBuilderMethods, BaseTypeMethods};
use rustc_data_structures::stable_set::FxHashSet;
use rustc_data_structures::fx::FxHashSet;
use rustc_middle::bug;
use rustc_middle::ty::Ty;
use rustc_target::abi::call::{CastTarget, FnAbi, PassMode, Reg, RegKind};
Expand Down
2 changes: 1 addition & 1 deletion src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam

let name = OomStrategy::SYMBOL.to_string();
let global = context.new_global(None, GlobalKind::Exported, i8, name);
let value = tcx.sess.opts.debugging_opts.oom.should_panic();
let value = tcx.sess.opts.unstable_opts.oom.should_panic();
let value = context.new_rvalue_from_int(i8, value as i32);
global.global_set_initializer_rvalue(value);
}
Loading

0 comments on commit b4626b3

Please sign in to comment.