Skip to content

Commit

Permalink
Handle cfg(bootstrap) throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Aug 14, 2019
1 parent e9b3a01 commit 2601c86
Show file tree
Hide file tree
Showing 36 changed files with 64 additions and 179 deletions.
5 changes: 1 addition & 4 deletions src/bootstrap/bin/rustc.rs
Expand Up @@ -132,10 +132,7 @@ fn main() {
cmd.arg("-Dwarnings");
cmd.arg("-Drust_2018_idioms");
cmd.arg("-Dunused_lifetimes");
// cfg(not(bootstrap)): Remove this during the next stage 0 compiler update.
// `-Drustc::internal` is a new feature and `rustc_version` mis-reports the `stage`.
let cfg_not_bootstrap = stage != "0" && crate_name != Some("rustc_version");
if cfg_not_bootstrap && use_internal_lints(crate_name) {
if use_internal_lints(crate_name) {
cmd.arg("-Zunstable-options");
cmd.arg("-Drustc::internal");
}
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/builder.rs
Expand Up @@ -145,7 +145,7 @@ impl StepDescription {
only_hosts: S::ONLY_HOSTS,
should_run: S::should_run,
make_run: S::make_run,
name: unsafe { ::std::intrinsics::type_name::<S>() },
name: std::any::type_name::<S>(),
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/collections/btree/node.rs
Expand Up @@ -106,8 +106,8 @@ impl<K, V> LeafNode<K, V> {
LeafNode {
// As a general policy, we leave fields uninitialized if they can be, as this should
// be both slightly faster and easier to track in Valgrind.
keys: uninit_array![_; CAPACITY],
vals: uninit_array![_; CAPACITY],
keys: [MaybeUninit::UNINIT; CAPACITY],
vals: [MaybeUninit::UNINIT; CAPACITY],
parent: ptr::null(),
parent_idx: MaybeUninit::uninit(),
len: 0
Expand Down Expand Up @@ -159,7 +159,7 @@ impl<K, V> InternalNode<K, V> {
unsafe fn new() -> Self {
InternalNode {
data: LeafNode::new(),
edges: uninit_array![_; 2*B],
edges: [MaybeUninit::UNINIT; 2*B]
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/lib.rs
Expand Up @@ -69,7 +69,7 @@
#![warn(missing_debug_implementations)]
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
#![allow(explicit_outlives_requirements)]
#![cfg_attr(not(bootstrap), allow(incomplete_features))]
#![allow(incomplete_features)]

#![cfg_attr(not(test), feature(generator_trait))]
#![cfg_attr(test, feature(test))]
Expand All @@ -84,7 +84,7 @@
#![feature(coerce_unsized)]
#![feature(const_generic_impls_guard)]
#![feature(const_generics)]
#![cfg_attr(not(bootstrap), feature(const_in_array_repeat_expressions))]
#![feature(const_in_array_repeat_expressions)]
#![feature(dispatch_from_dyn)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
Expand Down Expand Up @@ -118,7 +118,7 @@
#![feature(rustc_const_unstable)]
#![feature(const_vec_new)]
#![feature(slice_partition_dedup)]
#![feature(maybe_uninit_extra, maybe_uninit_slice, maybe_uninit_array)]
#![feature(maybe_uninit_extra, maybe_uninit_slice)]
#![feature(alloc_layout_extra)]
#![feature(try_trait)]
#![feature(mem_take)]
Expand Down
5 changes: 0 additions & 5 deletions src/libcore/any.rs
Expand Up @@ -470,10 +470,5 @@ impl TypeId {
#[stable(feature = "type_name", since = "1.38.0")]
#[rustc_const_unstable(feature = "const_type_name")]
pub const fn type_name<T: ?Sized>() -> &'static str {
#[cfg(bootstrap)]
unsafe {
intrinsics::type_name::<T>()
}
#[cfg(not(bootstrap))]
intrinsics::type_name::<T>()
}
14 changes: 2 additions & 12 deletions src/libcore/char/methods.rs
Expand Up @@ -553,12 +553,7 @@ impl char {
/// `XID_Start` is a Unicode Derived Property specified in
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
/// mostly similar to `ID_Start` but modified for closure under `NFKx`.
#[cfg_attr(bootstrap,
unstable(feature = "rustc_private",
reason = "mainly needed for compiler internals",
issue = "27812"))]
#[cfg_attr(not(bootstrap),
unstable(feature = "unicode_internals", issue = "0"))]
#[unstable(feature = "unicode_internals", issue = "0")]
pub fn is_xid_start(self) -> bool {
derived_property::XID_Start(self)
}
Expand All @@ -569,12 +564,7 @@ impl char {
/// `XID_Continue` is a Unicode Derived Property specified in
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
/// mostly similar to `ID_Continue` but modified for closure under NFKx.
#[cfg_attr(bootstrap,
unstable(feature = "rustc_private",
reason = "mainly needed for compiler internals",
issue = "27812"))]
#[cfg_attr(not(bootstrap),
unstable(feature = "unicode_internals", issue = "0"))]
#[unstable(feature = "unicode_internals", issue = "0")]
#[inline]
pub fn is_xid_continue(self) -> bool {
derived_property::XID_Continue(self)
Expand Down
1 change: 0 additions & 1 deletion src/libcore/clone.rs
Expand Up @@ -134,7 +134,6 @@ pub trait Clone : Sized {
}

/// Derive macro generating an impl of the trait `Clone`.
#[cfg(not(bootstrap))]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
Expand Down
4 changes: 0 additions & 4 deletions src/libcore/cmp.rs
Expand Up @@ -201,7 +201,6 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
}

/// Derive macro generating an impl of the trait `PartialEq`.
#[cfg(not(bootstrap))]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
Expand Down Expand Up @@ -265,7 +264,6 @@ pub trait Eq: PartialEq<Self> {
}

/// Derive macro generating an impl of the trait `Eq`.
#[cfg(not(bootstrap))]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
Expand Down Expand Up @@ -617,7 +615,6 @@ pub trait Ord: Eq + PartialOrd<Self> {
}

/// Derive macro generating an impl of the trait `Ord`.
#[cfg(not(bootstrap))]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
Expand Down Expand Up @@ -867,7 +864,6 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
}

/// Derive macro generating an impl of the trait `PartialOrd`.
#[cfg(not(bootstrap))]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
Expand Down
1 change: 0 additions & 1 deletion src/libcore/default.rs
Expand Up @@ -116,7 +116,6 @@ pub trait Default: Sized {
}

/// Derive macro generating an impl of the trait `Default`.
#[cfg(not(bootstrap))]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
Expand Down
2 changes: 0 additions & 2 deletions src/libcore/fmt/mod.rs
Expand Up @@ -546,7 +546,6 @@ pub trait Debug {
}

// Separate module to reexport the macro `Debug` from prelude without the trait `Debug`.
#[cfg(not(bootstrap))]
pub(crate) mod macros {
/// Derive macro generating an impl of the trait `Debug`.
#[rustc_builtin_macro]
Expand All @@ -555,7 +554,6 @@ pub(crate) mod macros {
#[allow_internal_unstable(core_intrinsics)]
pub macro Debug($item:item) { /* compiler built-in */ }
}
#[cfg(not(bootstrap))]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[doc(inline)]
pub use macros::Debug;
Expand Down
2 changes: 0 additions & 2 deletions src/libcore/hash/mod.rs
Expand Up @@ -199,7 +199,6 @@ pub trait Hash {
}

// Separate module to reexport the macro `Hash` from prelude without the trait `Hash`.
#[cfg(not(bootstrap))]
pub(crate) mod macros {
/// Derive macro generating an impl of the trait `Hash`.
#[rustc_builtin_macro]
Expand All @@ -208,7 +207,6 @@ pub(crate) mod macros {
#[allow_internal_unstable(core_intrinsics)]
pub macro Hash($item:item) { /* compiler built-in */ }
}
#[cfg(not(bootstrap))]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[doc(inline)]
pub use macros::Hash;
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/lib.rs
Expand Up @@ -63,7 +63,7 @@
#![warn(missing_debug_implementations)]
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
#![allow(explicit_outlives_requirements)]
#![cfg_attr(not(bootstrap), allow(incomplete_features))]
#![allow(incomplete_features)]

#![feature(allow_internal_unstable)]
#![feature(arbitrary_self_types)]
Expand Down Expand Up @@ -129,7 +129,7 @@
#![feature(structural_match)]
#![feature(abi_unadjusted)]
#![feature(adx_target_feature)]
#![feature(maybe_uninit_slice, maybe_uninit_array)]
#![feature(maybe_uninit_slice)]
#![feature(external_doc)]
#![feature(mem_take)]
#![feature(associated_type_bounds)]
Expand Down
35 changes: 0 additions & 35 deletions src/libcore/macros.rs
Expand Up @@ -635,46 +635,11 @@ macro_rules! todo {
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)+)));
}

/// Creates an array of [`MaybeUninit`].
///
/// This macro constructs an uninitialized array of the type `[MaybeUninit<K>; N]`.
/// It exists solely because bootstrap does not yet support const array-init expressions.
///
/// [`MaybeUninit`]: mem/union.MaybeUninit.html
// FIXME: Remove both versions of this macro once bootstrap is 1.38.
#[macro_export]
#[unstable(feature = "maybe_uninit_array", issue = "53491")]
#[cfg(bootstrap)]
macro_rules! uninit_array {
// This `assume_init` is safe because an array of `MaybeUninit` does not
// require initialization.
($t:ty; $size:expr) => (unsafe {
MaybeUninit::<[MaybeUninit<$t>; $size]>::uninit().assume_init()
});
}

/// Creates an array of [`MaybeUninit`].
///
/// This macro constructs an uninitialized array of the type `[MaybeUninit<K>; N]`.
/// It exists solely because bootstrap does not yet support const array-init expressions.
///
/// [`MaybeUninit`]: mem/union.MaybeUninit.html
// FIXME: Just inline this version of the macro once bootstrap is 1.38.
#[macro_export]
#[unstable(feature = "maybe_uninit_array", issue = "53491")]
#[cfg(not(bootstrap))]
macro_rules! uninit_array {
($t:ty; $size:expr) => (
[MaybeUninit::<$t>::UNINIT; $size]
);
}

/// Definitions of built-in macros.
///
/// Most of the macro properties (stability, visibility, etc.) are taken from the source code here,
/// with exception of expansion functions transforming macro inputs into outputs,
/// those functions are provided by the compiler.
#[cfg(not(bootstrap))]
pub(crate) mod builtin {

/// Causes compilation to fail with the given error message when encountered.
Expand Down
1 change: 0 additions & 1 deletion src/libcore/marker.rs
Expand Up @@ -289,7 +289,6 @@ pub trait Copy : Clone {
}

/// Derive macro generating an impl of the trait `Copy`.
#[cfg(not(bootstrap))]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/mem/maybe_uninit.rs
Expand Up @@ -213,7 +213,7 @@ use crate::mem::ManuallyDrop;
#[allow(missing_debug_implementations)]
#[stable(feature = "maybe_uninit", since = "1.36.0")]
// Lang item so we can wrap other types in it. This is useful for generators.
#[cfg_attr(not(bootstrap), lang = "maybe_uninit")]
#[lang = "maybe_uninit"]
#[derive(Copy)]
#[repr(transparent)]
pub union MaybeUninit<T> {
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/mem/mod.rs
Expand Up @@ -453,7 +453,7 @@ pub const fn needs_drop<T>() -> bool {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
#[allow(deprecated_in_future)]
#[allow(deprecated)]
pub unsafe fn zeroed<T>() -> T {
intrinsics::panic_if_uninhabited::<T>();
Expand Down Expand Up @@ -481,7 +481,7 @@ pub unsafe fn zeroed<T>() -> T {
#[inline]
#[rustc_deprecated(since = "1.39.0", reason = "use `mem::MaybeUninit` instead")]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
#[allow(deprecated_in_future)]
#[allow(deprecated)]
pub unsafe fn uninitialized<T>() -> T {
intrinsics::panic_if_uninhabited::<T>();
Expand Down
4 changes: 0 additions & 4 deletions src/libcore/prelude/v1.rs
Expand Up @@ -46,16 +46,13 @@ pub use crate::option::Option::{self, Some, None};
pub use crate::result::Result::{self, Ok, Err};

// Re-exported built-in macros
#[cfg(not(bootstrap))]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[doc(no_inline)]
pub use crate::fmt::macros::Debug;
#[cfg(not(bootstrap))]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[doc(no_inline)]
pub use crate::hash::macros::Hash;

#[cfg(not(bootstrap))]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[doc(no_inline)]
pub use crate::{
Expand Down Expand Up @@ -83,7 +80,6 @@ pub use crate::{
trace_macros,
};

#[cfg(not(bootstrap))]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[allow(deprecated)]
#[doc(no_inline)]
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/lint/context.rs
Expand Up @@ -1355,7 +1355,7 @@ struct LateLintPassObjects<'a> {
lints: &'a mut [LateLintPassObject],
}

#[cfg_attr(not(bootstrap), allow(rustc::lint_pass_impl_without_macro))]
#[allow(rustc::lint_pass_impl_without_macro)]
impl LintPass for LateLintPassObjects<'_> {
fn name(&self) -> &'static str {
panic!()
Expand Down Expand Up @@ -1525,7 +1525,7 @@ struct EarlyLintPassObjects<'a> {
lints: &'a mut [EarlyLintPassObject],
}

#[cfg_attr(not(bootstrap), allow(rustc::lint_pass_impl_without_macro))]
#[allow(rustc::lint_pass_impl_without_macro)]
impl LintPass for EarlyLintPassObjects<'_> {
fn name(&self) -> &'static str {
panic!()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/internal.rs
Expand Up @@ -23,7 +23,7 @@ pub struct DefaultHashTypes {

impl DefaultHashTypes {
// we are allowed to use `HashMap` and `HashSet` as identifiers for implementing the lint itself
#[cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
#[allow(rustc::default_hash_types)]
pub fn new() -> Self {
let mut map = FxHashMap::default();
map.insert(sym::HashMap, sym::FxHashMap);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/codec.rs
Expand Up @@ -27,7 +27,7 @@ pub trait EncodableWithShorthand: Clone + Eq + Hash {
fn variant(&self) -> &Self::Variant;
}

#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
#[allow(rustc::usage_of_ty_tykind)]
impl<'tcx> EncodableWithShorthand for Ty<'tcx> {
type Variant = ty::TyKind<'tcx>;
fn variant(&self) -> &Self::Variant {
Expand Down Expand Up @@ -160,7 +160,7 @@ where
Ok(decoder.map_encoded_cnum_to_current(cnum))
}

#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
#[allow(rustc::usage_of_ty_tykind)]
#[inline]
pub fn decode_ty<D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
where
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/context.rs
Expand Up @@ -130,7 +130,7 @@ impl<'tcx> CtxtInterners<'tcx> {
}

/// Intern a type
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
#[allow(rustc::usage_of_ty_tykind)]
#[inline(never)]
fn intern_ty(&self,
st: TyKind<'tcx>
Expand Down Expand Up @@ -2076,7 +2076,7 @@ impl<'tcx> Hash for Interned<'tcx, TyS<'tcx>> {
}
}

#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
#[allow(rustc::usage_of_ty_tykind)]
impl<'tcx> Borrow<TyKind<'tcx>> for Interned<'tcx, TyS<'tcx>> {
fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> {
&self.0.sty
Expand Down Expand Up @@ -2291,7 +2291,7 @@ impl<'tcx> TyCtxt<'tcx> {
self.mk_fn_ptr(converted_sig)
}

#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
#[allow(rustc::usage_of_ty_tykind)]
#[inline]
pub fn mk_ty(&self, st: TyKind<'tcx>) -> Ty<'tcx> {
self.interners.intern_ty(st)
Expand Down

0 comments on commit 2601c86

Please sign in to comment.