-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add minicore
test auxiliary and support //@ use-minicore
directive in ui/assembly/codegen tests
#130693
base: master
Are you sure you want to change the base?
Add minicore
test auxiliary and support //@ use-minicore
directive in ui/assembly/codegen tests
#130693
Changes from all commits
b3081ee
084489e
25e8372
91a23be
c3bc433
334f846
a5542e8
f589de5
7c69a5f
383c00c
171d20b
90b6aae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//! `compiletest` self-test to check that `use-minicore` is incompatible with run pass modes. | ||
|
||
//@ use-minicore | ||
//@ run-pass | ||
//@ should-fail |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
//! Auxiliary `minicore` prelude which stubs out `core` items for `no_core` tests that need to work | ||
//! in cross-compilation scenarios where no `core` is available (that don't want nor need to | ||
//! `-Zbuild-std`). | ||
//! | ||
//! # Important notes | ||
//! | ||
//! - `minicore` is **only** intended for `core` items, and the stubs should match the actual `core` | ||
//! items. | ||
//! | ||
//! # References | ||
//! | ||
//! This is partially adapted from `rustc_codegen_cranelift`: | ||
//! <https://github.com/rust-lang/rust/blob/c0b5cc9003f6464c11ae1c0662c6a7e06f6f5cab/compiler/rustc_codegen_cranelift/example/mini_core.rs>. | ||
// ignore-tidy-linelength | ||
|
||
#![feature(no_core, lang_items, rustc_attrs)] | ||
#![allow(unused, improper_ctypes_definitions, internal_features)] | ||
#![no_std] | ||
#![no_core] | ||
|
||
#[lang = "sized"] | ||
pub trait Sized {} | ||
|
||
#[lang = "receiver"] | ||
pub trait Receiver {} | ||
impl<T: ?Sized> Receiver for &T {} | ||
impl<T: ?Sized> Receiver for &mut T {} | ||
|
||
#[lang = "copy"] | ||
pub trait Copy {} | ||
|
||
impl Copy for bool {} | ||
impl Copy for u8 {} | ||
impl Copy for u16 {} | ||
impl Copy for u32 {} | ||
impl Copy for u64 {} | ||
impl Copy for u128 {} | ||
impl Copy for usize {} | ||
impl Copy for i8 {} | ||
impl Copy for i16 {} | ||
impl Copy for i32 {} | ||
impl Copy for isize {} | ||
impl Copy for f32 {} | ||
impl Copy for f64 {} | ||
impl Copy for char {} | ||
impl<'a, T: ?Sized> Copy for &'a T {} | ||
impl<T: ?Sized> Copy for *const T {} | ||
impl<T: ?Sized> Copy for *mut T {} | ||
|
||
#[lang = "phantom_data"] | ||
pub struct PhantomData<T: ?Sized>; | ||
impl<T: ?Sized> Copy for PhantomData<T> {} | ||
|
||
pub enum Option<T> { | ||
None, | ||
Some(T), | ||
} | ||
impl<T: Copy> Copy for Option<T> {} | ||
|
||
pub enum Result<T, E> { | ||
Ok(T), | ||
Err(E), | ||
} | ||
impl<T: Copy, E: Copy> Copy for Result<T, E> {} | ||
|
||
#[lang = "manually_drop"] | ||
#[repr(transparent)] | ||
pub struct ManuallyDrop<T: ?Sized> { | ||
value: T, | ||
} | ||
impl<T: Copy + ?Sized> Copy for ManuallyDrop<T> {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can derive #[rustc_builtin_macro]
pub macro Copy($item:item) {
/* compiler built-in */
} and the same applies to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not make this change because I couldn't figure out how to make use of this, just kept manual |
||
|
||
#[lang = "unsafe_cell"] | ||
#[repr(transparent)] | ||
pub struct UnsafeCell<T: ?Sized> { | ||
value: T, | ||
} | ||
|
||
// Trait stub, no `type_id` method. | ||
pub trait Any: 'static {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: I don't like how convoluted the top-level runtest logic is, but intended for future compiletest cleanup PRs instead of this PR.