Skip to content

Commit

Permalink
handle cfg(bootstrap)
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini authored and cuviper committed Apr 28, 2023
1 parent d64f46a commit a7bb8c7
Show file tree
Hide file tree
Showing 22 changed files with 101 additions and 515 deletions.
11 changes: 0 additions & 11 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ impl<'a> Arguments<'a> {

/// When using the format_args!() macro, this function is used to generate the
/// Arguments structure.
#[cfg(not(bootstrap))]
#[inline]
pub fn new_v1(pieces: &'a [&'static str], args: &'a [rt::Argument<'a>]) -> Arguments<'a> {
if pieces.len() < args.len() || pieces.len() > args.len() + 1 {
Expand All @@ -312,16 +311,6 @@ impl<'a> Arguments<'a> {
Arguments { pieces, fmt: None, args }
}

#[cfg(bootstrap)]
#[inline]
#[rustc_const_unstable(feature = "const_fmt_arguments_new", issue = "none")]
pub const fn new_v1(pieces: &'a [&'static str], args: &'a [rt::Argument<'a>]) -> Arguments<'a> {
if pieces.len() < args.len() || pieces.len() > args.len() + 1 {
panic!("invalid args");
}
Arguments { pieces, fmt: None, args }
}

/// This function is used to specify nonstandard formatting parameters.
///
/// An `rt::UnsafeArg` is required because the following invariants must be held
Expand Down
1 change: 0 additions & 1 deletion library/core/src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ pub unsafe fn get_context<'a, 'b>(cx: ResumeTy) -> &'a mut Context<'b> {
#[doc(hidden)]
#[unstable(feature = "gen_future", issue = "50547")]
#[inline]
#[cfg_attr(bootstrap, lang = "identity_future")]
pub const fn identity_future<O, Fut: Future<Output = O>>(f: Fut) -> Fut {
f
}
4 changes: 0 additions & 4 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1823,14 +1823,12 @@ extern "rust-intrinsic" {
/// with an even least significant digit.
///
/// This intrinsic does not have a stable counterpart.
#[cfg(not(bootstrap))]
#[rustc_nounwind]
pub fn roundevenf32(x: f32) -> f32;
/// Returns the nearest integer to an `f64`. Rounds half-way cases to the number
/// with an even least significant digit.
///
/// This intrinsic does not have a stable counterpart.
#[cfg(not(bootstrap))]
#[rustc_nounwind]
pub fn roundevenf64(x: f64) -> f64;

Expand Down Expand Up @@ -2262,7 +2260,6 @@ extern "rust-intrinsic" {
/// This intrinsic can *only* be called where the argument is a local without
/// projections (`read_via_copy(p)`, not `read_via_copy(*p)`) so that it
/// trivially obeys runtime-MIR rules about derefs in operands.
#[cfg(not(bootstrap))]
#[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
#[rustc_nounwind]
pub fn read_via_copy<T>(p: *const T) -> T;
Expand Down Expand Up @@ -2470,7 +2467,6 @@ extern "rust-intrinsic" {
/// This method creates a pointer to any `Some` value. If the argument is
/// `None`, an invalid within-bounds pointer (that is still acceptable for
/// constructing an empty slice) is returned.
#[cfg(not(bootstrap))]
#[rustc_nounwind]
pub fn option_payload_ptr<T>(arg: *const Option<T>) -> *const T;
}
Expand Down
1 change: 0 additions & 1 deletion library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,6 @@ mod copy_impls {
reason = "internal trait for implementing various traits for all function pointers"
)]
#[lang = "fn_ptr_trait"]
#[cfg(not(bootstrap))]
#[rustc_deny_explicit_impl]
pub trait FnPtr: Copy + Clone {
/// Returns the address of the function pointer.
Expand Down
16 changes: 1 addition & 15 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ use crate::{
/// The `Option` type. See [the module level documentation](self) for more.
#[derive(Copy, PartialOrd, Eq, Ord, Debug, Hash)]
#[rustc_diagnostic_item = "Option"]
#[cfg_attr(not(bootstrap), lang = "Option")]
#[lang = "Option"]
#[stable(feature = "rust1", since = "1.0.0")]
pub enum Option<T> {
/// No value.
Expand Down Expand Up @@ -765,13 +765,6 @@ impl<T> Option<T> {
#[must_use]
#[unstable(feature = "option_as_slice", issue = "108545")]
pub fn as_slice(&self) -> &[T] {
#[cfg(bootstrap)]
match self {
Some(value) => slice::from_ref(value),
None => &[],
}

#[cfg(not(bootstrap))]
// SAFETY: When the `Option` is `Some`, we're using the actual pointer
// to the payload, with a length of 1, so this is equivalent to
// `slice::from_ref`, and thus is safe.
Expand Down Expand Up @@ -832,13 +825,6 @@ impl<T> Option<T> {
#[must_use]
#[unstable(feature = "option_as_slice", issue = "108545")]
pub fn as_mut_slice(&mut self) -> &mut [T] {
#[cfg(bootstrap)]
match self {
Some(value) => slice::from_mut(value),
None => &mut [],
}

#[cfg(not(bootstrap))]
// SAFETY: When the `Option` is `Some`, we're using the actual pointer
// to the payload, with a length of 1, so this is equivalent to
// `slice::from_mut`, and thus is safe.
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
#[cold]
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
#[track_caller]
#[cfg_attr(not(bootstrap), lang = "panic_misaligned_pointer_dereference")] // needed by codegen for panic on misaligned pointer deref
#[lang = "panic_misaligned_pointer_dereference"] // needed by codegen for panic on misaligned pointer deref
fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! {
if cfg!(feature = "panic_immediate_abort") {
super::intrinsics::abort()
Expand Down
75 changes: 25 additions & 50 deletions library/core/src/primitive_docs.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// `library/{std,core}/src/primitive_docs.rs` should have the same contents.
// These are different files so that relative links work properly without
// having to have `CARGO_PKG_NAME` set, but conceptually they should always be the same.
#[cfg_attr(bootstrap, doc(primitive = "bool"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "bool")]
#[rustc_doc_primitive = "bool"]
#[doc(alias = "true")]
#[doc(alias = "false")]
/// The boolean type.
Expand Down Expand Up @@ -64,8 +63,7 @@
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_bool {}

#[cfg_attr(bootstrap, doc(primitive = "never"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "never")]
#[rustc_doc_primitive = "never"]
#[doc(alias = "!")]
//
/// The `!` type, also called "never".
Expand Down Expand Up @@ -276,8 +274,7 @@ mod prim_bool {}
#[unstable(feature = "never_type", issue = "35121")]
mod prim_never {}

#[cfg_attr(bootstrap, doc(primitive = "char"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "char")]
#[rustc_doc_primitive = "char"]
#[allow(rustdoc::invalid_rust_codeblocks)]
/// A character type.
///
Expand Down Expand Up @@ -401,8 +398,7 @@ mod prim_never {}
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_char {}

#[cfg_attr(bootstrap, doc(primitive = "unit"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "unit")]
#[rustc_doc_primitive = "unit"]
#[doc(alias = "(")]
#[doc(alias = ")")]
#[doc(alias = "()")]
Expand Down Expand Up @@ -464,8 +460,7 @@ impl Copy for () {
// empty
}

#[cfg_attr(bootstrap, doc(primitive = "pointer"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "pointer")]
#[rustc_doc_primitive = "pointer"]
#[doc(alias = "ptr")]
#[doc(alias = "*")]
#[doc(alias = "*const")]
Expand Down Expand Up @@ -581,8 +576,7 @@ impl Copy for () {
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_pointer {}

#[cfg_attr(bootstrap, doc(primitive = "array"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "array")]
#[rustc_doc_primitive = "array"]
#[doc(alias = "[]")]
#[doc(alias = "[T;N]")] // unfortunately, rustdoc doesn't have fuzzy search for aliases
#[doc(alias = "[T; N]")]
Expand Down Expand Up @@ -783,8 +777,7 @@ mod prim_pointer {}
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_array {}

#[cfg_attr(bootstrap, doc(primitive = "slice"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "slice")]
#[rustc_doc_primitive = "slice"]
#[doc(alias = "[")]
#[doc(alias = "]")]
#[doc(alias = "[]")]
Expand Down Expand Up @@ -876,8 +869,7 @@ mod prim_array {}
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_slice {}

#[cfg_attr(bootstrap, doc(primitive = "str"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "str")]
#[rustc_doc_primitive = "str"]
/// String slices.
///
/// *[See also the `std::str` module](crate::str).*
Expand Down Expand Up @@ -944,8 +936,7 @@ mod prim_slice {}
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_str {}

#[cfg_attr(bootstrap, doc(primitive = "tuple"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "tuple")]
#[rustc_doc_primitive = "tuple"]
#[doc(alias = "(")]
#[doc(alias = ")")]
#[doc(alias = "()")]
Expand Down Expand Up @@ -1088,8 +1079,7 @@ impl<T: Copy> Copy for (T,) {
// empty
}

#[cfg_attr(bootstrap, doc(primitive = "f32"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "f32")]
#[rustc_doc_primitive = "f32"]
/// A 32-bit floating point type (specifically, the "binary32" type defined in IEEE 754-2008).
///
/// This type can represent a wide range of decimal numbers, like `3.5`, `27`,
Expand Down Expand Up @@ -1155,8 +1145,7 @@ impl<T: Copy> Copy for (T,) {
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_f32 {}

#[cfg_attr(bootstrap, doc(primitive = "f64"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "f64")]
#[rustc_doc_primitive = "f64"]
/// A 64-bit floating point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`f32`], but has increased
Expand All @@ -1171,78 +1160,67 @@ mod prim_f32 {}
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_f64 {}

#[cfg_attr(bootstrap, doc(primitive = "i8"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i8")]
#[rustc_doc_primitive = "i8"]
//
/// The 8-bit signed integer type.
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_i8 {}

#[cfg_attr(bootstrap, doc(primitive = "i16"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i16")]
#[rustc_doc_primitive = "i16"]
//
/// The 16-bit signed integer type.
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_i16 {}

#[cfg_attr(bootstrap, doc(primitive = "i32"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i32")]
#[rustc_doc_primitive = "i32"]
//
/// The 32-bit signed integer type.
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_i32 {}

#[cfg_attr(bootstrap, doc(primitive = "i64"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i64")]
#[rustc_doc_primitive = "i64"]
//
/// The 64-bit signed integer type.
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_i64 {}

#[cfg_attr(bootstrap, doc(primitive = "i128"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i128")]
#[rustc_doc_primitive = "i128"]
//
/// The 128-bit signed integer type.
#[stable(feature = "i128", since = "1.26.0")]
mod prim_i128 {}

#[cfg_attr(bootstrap, doc(primitive = "u8"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u8")]
#[rustc_doc_primitive = "u8"]
//
/// The 8-bit unsigned integer type.
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_u8 {}

#[cfg_attr(bootstrap, doc(primitive = "u16"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u16")]
#[rustc_doc_primitive = "u16"]
//
/// The 16-bit unsigned integer type.
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_u16 {}

#[cfg_attr(bootstrap, doc(primitive = "u32"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u32")]
#[rustc_doc_primitive = "u32"]
//
/// The 32-bit unsigned integer type.
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_u32 {}

#[cfg_attr(bootstrap, doc(primitive = "u64"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u64")]
#[rustc_doc_primitive = "u64"]
//
/// The 64-bit unsigned integer type.
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_u64 {}

#[cfg_attr(bootstrap, doc(primitive = "u128"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u128")]
#[rustc_doc_primitive = "u128"]
//
/// The 128-bit unsigned integer type.
#[stable(feature = "i128", since = "1.26.0")]
mod prim_u128 {}

#[cfg_attr(bootstrap, doc(primitive = "isize"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "isize")]
#[rustc_doc_primitive = "isize"]
//
/// The pointer-sized signed integer type.
///
Expand All @@ -1252,8 +1230,7 @@ mod prim_u128 {}
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_isize {}

#[cfg_attr(bootstrap, doc(primitive = "usize"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "usize")]
#[rustc_doc_primitive = "usize"]
//
/// The pointer-sized unsigned integer type.
///
Expand All @@ -1263,8 +1240,7 @@ mod prim_isize {}
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_usize {}

#[cfg_attr(bootstrap, doc(primitive = "reference"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "reference")]
#[rustc_doc_primitive = "reference"]
#[doc(alias = "&")]
#[doc(alias = "&mut")]
//
Expand Down Expand Up @@ -1396,8 +1372,7 @@ mod prim_usize {}
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_ref {}

#[cfg_attr(bootstrap, doc(primitive = "fn"))]
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "fn")]
#[rustc_doc_primitive = "fn"]
//
/// Function pointers, like `fn(usize) -> bool`.
///
Expand Down
Loading

0 comments on commit a7bb8c7

Please sign in to comment.