Skip to content

Commit

Permalink
stage-step cfgs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Jan 30, 2023
1 parent 17887f7 commit 5b08c9f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 50 deletions.
40 changes: 3 additions & 37 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,16 +798,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
Self: Sized,
Self: ~const Destruct,
{
#[cfg(not(bootstrap))]
{
max_by(self, other, Ord::cmp)
}

#[cfg(bootstrap)]
match self.cmp(&other) {
Ordering::Less | Ordering::Equal => other,
Ordering::Greater => self,
}
max_by(self, other, Ord::cmp)
}

/// Compares and returns the minimum of two values.
Expand All @@ -828,16 +819,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
Self: Sized,
Self: ~const Destruct,
{
#[cfg(not(bootstrap))]
{
min_by(self, other, Ord::cmp)
}

#[cfg(bootstrap)]
match self.cmp(&other) {
Ordering::Less | Ordering::Equal => self,
Ordering::Greater => other,
}
min_by(self, other, Ord::cmp)
}

/// Restrict a value to a certain interval.
Expand Down Expand Up @@ -1234,23 +1216,7 @@ where
F: ~const Destruct,
K: ~const Destruct,
{
cfg_if! {
if #[cfg(bootstrap)] {
const fn imp<T, F: ~const FnMut(&T) -> K, K: ~const Ord>(
f: &mut F,
(v1, v2): (&T, &T),
) -> Ordering
where
T: ~const Destruct,
K: ~const Destruct,
{
f(v1).cmp(&f(v2))
}
min_by(v1, v2, ConstFnMutClosure::new(&mut f, imp))
} else {
min_by(v1, v2, const |v1, v2| f(v1).cmp(&f(v2)))
}
}
min_by(v1, v2, const |v1, v2| f(v1).cmp(&f(v2)))
}

/// Compares and returns the maximum of two values.
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ use crate::marker::DiscriminantKind;
use crate::marker::Tuple;
use crate::mem;

#[cfg(not(bootstrap))]
pub mod mir;

// These imports are used for simplifying intra-doc links
Expand Down Expand Up @@ -963,7 +962,6 @@ extern "rust-intrinsic" {
/// This intrinsic does not have a stable counterpart.
#[rustc_const_unstable(feature = "const_assert_type2", issue = "none")]
#[rustc_safe_intrinsic]
#[cfg(not(bootstrap))]
pub fn assert_mem_uninitialized_valid<T>();

/// Gets a reference to a static `Location` indicating where it was called.
Expand Down
6 changes: 2 additions & 4 deletions library/core/src/intrinsics/mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
//!
//! # Examples
//!
#![cfg_attr(bootstrap, doc = "```rust,compile_fail")]
#![cfg_attr(not(bootstrap), doc = "```rust")]
//! ```rust
//! #![feature(core_intrinsics, custom_mir)]
//!
//! extern crate core;
Expand Down Expand Up @@ -294,8 +293,7 @@ define!(
///
/// # Examples
///
#[cfg_attr(bootstrap, doc = "```rust,compile_fail")]
#[cfg_attr(not(bootstrap), doc = "```rust")]
/// ```rust
/// #![feature(custom_mir, core_intrinsics)]
///
/// extern crate core;
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
#![feature(cfg_sanitize)]
#![feature(cfg_target_has_atomic)]
#![feature(cfg_target_has_atomic_equal_alignment)]
#![cfg_attr(not(bootstrap), feature(const_closures))]
#![feature(const_closures)]
#![feature(const_fn_floating_point_arithmetic)]
#![feature(const_mut_refs)]
#![feature(const_precise_live_drops)]
Expand Down Expand Up @@ -248,7 +248,6 @@
#![feature(sse4a_target_feature)]
#![feature(tbm_target_feature)]
#![feature(wasm_target_feature)]
#![cfg_attr(bootstrap, feature(f16c_target_feature))]

// allow using `core::` in intra-doc links
#[allow(unused_extern_crates)]
Expand Down
1 change: 0 additions & 1 deletion library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,6 @@ pub unsafe fn zeroed<T>() -> T {
pub unsafe fn uninitialized<T>() -> T {
// SAFETY: the caller must guarantee that an uninitialized value is valid for `T`.
unsafe {
#[cfg(not(bootstrap))] // If the compiler hits this itself then it deserves the UB.
intrinsics::assert_mem_uninitialized_valid::<T>();
let mut val = MaybeUninit::<T>::uninit();

Expand Down
5 changes: 2 additions & 3 deletions library/core/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub const fn panic(expr: &'static str) -> ! {
/// Like `panic`, but without unwinding and track_caller to reduce the impact on codesize.
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)]
#[cfg_attr(feature = "panic_immediate_abort", inline)]
#[cfg_attr(not(bootstrap), lang = "panic_nounwind")] // needed by codegen for non-unwinding panics
#[lang = "panic_nounwind"] // needed by codegen for non-unwinding panics
#[rustc_nounwind]
pub fn panic_nounwind(expr: &'static str) -> ! {
panic_nounwind_fmt(fmt::Arguments::new_v1(&[expr], &[]));
Expand Down Expand Up @@ -165,8 +165,7 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
/// any extra arguments (including those synthesized by track_caller).
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)]
#[cfg_attr(feature = "panic_immediate_abort", inline)]
#[cfg_attr(bootstrap, lang = "panic_no_unwind")] // needed by codegen for panic in nounwind function
#[cfg_attr(not(bootstrap), lang = "panic_cannot_unwind")] // needed by codegen for panic in nounwind function
#[lang = "panic_cannot_unwind"] // needed by codegen for panic in nounwind function
#[rustc_nounwind]
fn panic_cannot_unwind() -> ! {
panic_nounwind("panic in a function that cannot unwind")
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/task/wake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl RawWakerVTable {
/// Currently, `Context` only serves to provide access to a [`&Waker`](Waker)
/// which can be used to wake the current task.
#[stable(feature = "futures_api", since = "1.36.0")]
#[cfg_attr(not(bootstrap), lang = "Context")]
#[lang = "Context"]
pub struct Context<'a> {
waker: &'a Waker,
// Ensure we future-proof against variance changes by forcing
Expand Down

0 comments on commit 5b08c9f

Please sign in to comment.