Bump cfgs

This commit is contained in:
Mark Rousskov 2021-03-26 16:10:21 -04:00
parent a76de0d0a7
commit b3a4f91b8d
19 changed files with 24 additions and 171 deletions

View file

@ -1,5 +1,4 @@
#![cfg_attr(bootstrap, deny(invalid_codeblock_attributes))]
#![cfg_attr(not(bootstrap), deny(rustdoc::invalid_codeblock_attributes))]
#![deny(rustdoc::invalid_codeblock_attributes)]
//! This library is used to gather all error codes into one place,
//! the goal being to make their maintenance easier.

View file

@ -133,7 +133,6 @@
#![feature(trusted_len)]
#![feature(unboxed_closures)]
#![feature(unicode_internals)]
#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
#![feature(unsize)]
#![feature(unsized_fn_params)]
#![feature(allocator_internals)]
@ -142,8 +141,7 @@
#![feature(alloc_layout_extra)]
#![feature(trusted_random_access)]
#![feature(try_trait)]
#![cfg_attr(bootstrap, feature(type_alias_impl_trait))]
#![cfg_attr(not(bootstrap), feature(min_type_alias_impl_trait))]
#![feature(min_type_alias_impl_trait)]
#![feature(associated_type_bounds)]
#![feature(slice_group_by)]
#![feature(decl_macro)]

View file

@ -691,29 +691,9 @@ mod impls {
impl<T: ?Sized> Hash for *const T {
#[inline]
fn hash<H: Hasher>(&self, state: &mut H) {
#[cfg(not(bootstrap))]
{
let (address, metadata) = self.to_raw_parts();
state.write_usize(address as usize);
metadata.hash(state);
}
#[cfg(bootstrap)]
{
if mem::size_of::<Self>() == mem::size_of::<usize>() {
// Thin pointer
state.write_usize(*self as *const () as usize);
} else {
// Fat pointer
// SAFETY: we are accessing the memory occupied by `self`
// which is guaranteed to be valid.
// This assumes a fat pointer can be represented by a `(usize, usize)`,
// which is safe to do in `std` because it is shipped and kept in sync
// with the implementation of fat pointers in `rustc`.
let (a, b) = unsafe { *(self as *const Self as *const (usize, usize)) };
state.write_usize(a);
state.write_usize(b);
}
}
let (address, metadata) = self.to_raw_parts();
state.write_usize(address as usize);
metadata.hash(state);
}
}
@ -721,29 +701,9 @@ mod impls {
impl<T: ?Sized> Hash for *mut T {
#[inline]
fn hash<H: Hasher>(&self, state: &mut H) {
#[cfg(not(bootstrap))]
{
let (address, metadata) = self.to_raw_parts();
state.write_usize(address as usize);
metadata.hash(state);
}
#[cfg(bootstrap)]
{
if mem::size_of::<Self>() == mem::size_of::<usize>() {
// Thin pointer
state.write_usize(*self as *const () as usize);
} else {
// Fat pointer
// SAFETY: we are accessing the memory occupied by `self`
// which is guaranteed to be valid.
// This assumes a fat pointer can be represented by a `(usize, usize)`,
// which is safe to do in `std` because it is shipped and kept in sync
// with the implementation of fat pointers in `rustc`.
let (a, b) = unsafe { *(self as *const Self as *const (usize, usize)) };
state.write_usize(a);
state.write_usize(b);
}
}
let (address, metadata) = self.to_raw_parts();
state.write_usize(address as usize);
metadata.hash(state);
}
}
}

View file

@ -129,7 +129,7 @@
#![feature(auto_traits)]
#![cfg_attr(bootstrap, feature(or_patterns))]
#![feature(prelude_import)]
#![cfg_attr(not(bootstrap), feature(ptr_metadata))]
#![feature(ptr_metadata)]
#![feature(repr_simd, platform_intrinsics)]
#![feature(rustc_attrs)]
#![feature(simd_ffi)]
@ -167,7 +167,6 @@
#![feature(slice_ptr_get)]
#![feature(no_niche)] // rust-lang/rust#68303
#![feature(int_error_matching)]
#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
#![deny(unsafe_op_in_unsafe_fn)]
#[prelude_import]
@ -299,8 +298,7 @@ pub mod primitive;
unused_imports,
unsafe_op_in_unsafe_fn
)]
#[cfg_attr(bootstrap, allow(non_autolinks))]
#[cfg_attr(not(bootstrap), allow(rustdoc::non_autolinks))]
#[allow(rustdoc::non_autolinks)]
// FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is
// merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
#[allow(clashing_extern_declarations)]

View file

@ -1391,7 +1391,6 @@ pub(crate) mod builtin {
}
/// Attribute macro used to apply derive macros.
#[cfg(not(bootstrap))]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro]
pub macro derive($item:item) {
@ -1453,7 +1452,6 @@ pub(crate) mod builtin {
}
/// Expands all `#[cfg]` and `#[cfg_attr]` attributes in the code fragment it's applied to.
#[cfg(not(bootstrap))]
#[unstable(
feature = "cfg_eval",
issue = "82679",

View file

@ -65,7 +65,7 @@ pub trait Deref {
/// The resulting type after dereferencing.
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "deref_target"]
#[cfg_attr(not(bootstrap), lang = "deref_target")]
#[lang = "deref_target"]
type Target: ?Sized;
/// Dereferences the value.

View file

@ -67,7 +67,6 @@ pub use crate::macros::builtin::{
bench, global_allocator, test, test_case, RustcDecodable, RustcEncodable,
};
#[cfg(not(bootstrap))]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[doc(no_inline)]
pub use crate::macros::builtin::derive;
@ -80,7 +79,6 @@ pub use crate::macros::builtin::derive;
#[doc(no_inline)]
pub use crate::macros::builtin::cfg_accessible;
#[cfg(not(bootstrap))]
#[unstable(
feature = "cfg_eval",
issue = "82679",

View file

@ -51,7 +51,6 @@ impl<T: ?Sized> *const T {
/// Decompose a (possibly wide) pointer into is address and metadata components.
///
/// The pointer can be later reconstructed with [`from_raw_parts`].
#[cfg(not(bootstrap))]
#[unstable(feature = "ptr_metadata", issue = "81513")]
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
#[inline]
@ -915,13 +914,6 @@ impl<T> *const [T] {
#[unstable(feature = "slice_ptr_len", issue = "71146")]
#[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")]
pub const fn len(self) -> usize {
#[cfg(bootstrap)]
{
// SAFETY: this is safe because `*const [T]` and `FatPtr<T>` have the same layout.
// Only `std` can make this guarantee.
unsafe { Repr { rust: self }.raw }.len
}
#[cfg(not(bootstrap))]
metadata(self)
}

View file

@ -90,11 +90,8 @@ pub use crate::intrinsics::copy;
#[doc(inline)]
pub use crate::intrinsics::write_bytes;
#[cfg(not(bootstrap))]
mod metadata;
#[cfg(not(bootstrap))]
pub(crate) use metadata::PtrRepr;
#[cfg(not(bootstrap))]
#[unstable(feature = "ptr_metadata", issue = "81513")]
pub use metadata::{from_raw_parts, from_raw_parts_mut, metadata, DynMetadata, Pointee, Thin};
@ -236,33 +233,6 @@ pub const fn null_mut<T>() -> *mut T {
0 as *mut T
}
#[cfg(bootstrap)]
#[repr(C)]
pub(crate) union Repr<T> {
pub(crate) rust: *const [T],
rust_mut: *mut [T],
pub(crate) raw: FatPtr<T>,
}
#[cfg(bootstrap)]
#[repr(C)]
pub(crate) struct FatPtr<T> {
data: *const T,
pub(crate) len: usize,
}
#[cfg(bootstrap)]
// Manual impl needed to avoid `T: Clone` bound.
impl<T> Clone for FatPtr<T> {
fn clone(&self) -> Self {
*self
}
}
#[cfg(bootstrap)]
// Manual impl needed to avoid `T: Copy` bound.
impl<T> Copy for FatPtr<T> {}
/// Forms a raw slice from a pointer and a length.
///
/// The `len` argument is the number of **elements**, not the number of bytes.
@ -287,14 +257,6 @@ impl<T> Copy for FatPtr<T> {}
#[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
#[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
#[cfg(bootstrap)]
{
// SAFETY: Accessing the value from the `Repr` union is safe since *const [T]
// and FatPtr have the same memory layouts. Only std can make this
// guarantee.
unsafe { Repr { raw: FatPtr { data, len } }.rust }
}
#[cfg(not(bootstrap))]
from_raw_parts(data.cast(), len)
}
@ -327,13 +289,6 @@ pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
#[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
#[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
#[cfg(bootstrap)]
{
// SAFETY: Accessing the value from the `Repr` union is safe since *mut [T]
// and FatPtr have the same memory layouts
unsafe { Repr { raw: FatPtr { data, len } }.rust_mut }
}
#[cfg(not(bootstrap))]
from_raw_parts_mut(data.cast(), len)
}

View file

@ -50,7 +50,6 @@ impl<T: ?Sized> *mut T {
/// Decompose a (possibly wide) pointer into is address and metadata components.
///
/// The pointer can be later reconstructed with [`from_raw_parts_mut`].
#[cfg(not(bootstrap))]
#[unstable(feature = "ptr_metadata", issue = "81513")]
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
#[inline]
@ -1175,13 +1174,6 @@ impl<T> *mut [T] {
#[unstable(feature = "slice_ptr_len", issue = "71146")]
#[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")]
pub const fn len(self) -> usize {
#[cfg(bootstrap)]
{
// SAFETY: this is safe because `*const [T]` and `FatPtr<T>` have the same layout.
// Only `std` can make this guarantee.
unsafe { Repr { rust_mut: self }.raw }.len
}
#[cfg(not(bootstrap))]
metadata(self)
}

View file

@ -181,7 +181,6 @@ impl<T: ?Sized> NonNull<T> {
/// See the documentation of [`std::ptr::from_raw_parts`] for more details.
///
/// [`std::ptr::from_raw_parts`]: crate::ptr::from_raw_parts
#[cfg(not(bootstrap))]
#[unstable(feature = "ptr_metadata", issue = "81513")]
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
#[inline]
@ -198,7 +197,6 @@ impl<T: ?Sized> NonNull<T> {
/// Decompose a (possibly wide) pointer into is address and metadata components.
///
/// The pointer can be later reconstructed with [`NonNull::from_raw_parts`].
#[cfg(not(bootstrap))]
#[unstable(feature = "ptr_metadata", issue = "81513")]
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
#[inline]

View file

@ -102,23 +102,14 @@ impl<T> [T] {
// SAFETY: const sound because we transmute out the length field as a usize (which it must be)
#[rustc_allow_const_fn_unstable(const_fn_union)]
pub const fn len(&self) -> usize {
#[cfg(bootstrap)]
{
// SAFETY: this is safe because `&[T]` and `FatPtr<T>` have the same layout.
// Only `std` can make this guarantee.
unsafe { crate::ptr::Repr { rust: self }.raw.len }
}
#[cfg(not(bootstrap))]
{
// FIXME: Replace with `crate::ptr::metadata(self)` when that is const-stable.
// As of this writing this causes a "Const-stable functions can only call other
// const-stable functions" error.
// FIXME: Replace with `crate::ptr::metadata(self)` when that is const-stable.
// As of this writing this causes a "Const-stable functions can only call other
// const-stable functions" error.
// SAFETY: Accessing the value from the `PtrRepr` union is safe since *const T
// and PtrComponents<T> have the same memory layouts. Only std can make this
// guarantee.
unsafe { crate::ptr::PtrRepr { const_ptr: self }.components.metadata }
}
// SAFETY: Accessing the value from the `PtrRepr` union is safe since *const T
// and PtrComponents<T> have the same memory layouts. Only std can make this
// guarantee.
unsafe { crate::ptr::PtrRepr { const_ptr: self }.components.metadata }
}
/// Returns `true` if the slice has a length of 0.
@ -2265,8 +2256,7 @@ impl<T> [T] {
// in crate `alloc`, and as such doesn't exists yet when building `core`.
// links to downstream crate: #74481. Since primitives are only documented in
// libstd (#73423), this never leads to broken links in practice.
#[cfg_attr(not(bootstrap), allow(rustdoc::broken_intra_doc_links))]
#[cfg_attr(bootstrap, allow(broken_intra_doc_links))]
#[allow(rustdoc::broken_intra_doc_links)]
#[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
#[inline]
pub fn binary_search_by_key<'a, B, F>(&'a self, b: &B, mut f: F) -> Result<usize, usize>

View file

@ -68,7 +68,7 @@
#![feature(option_result_unwrap_unchecked)]
#![feature(result_into_ok_or_err)]
#![feature(peekable_peek_mut)]
#![cfg_attr(not(bootstrap), feature(ptr_metadata))]
#![feature(ptr_metadata)]
#![feature(once_cell)]
#![feature(unsized_tuple_coercion)]
#![feature(nonzero_leading_trailing_zeros)]
@ -76,8 +76,7 @@
#![feature(integer_atomics)]
#![feature(slice_group_by)]
#![feature(trusted_random_access)]
#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
#![cfg_attr(not(bootstrap), feature(unsize))]
#![feature(unsize)]
#![deny(unsafe_op_in_unsafe_fn)]
extern crate test;

View file

@ -1,8 +1,6 @@
use core::cell::RefCell;
#[cfg(not(bootstrap))]
use core::ptr;
use core::ptr::*;
#[cfg(not(bootstrap))]
use std::fmt::{Debug, Display};
#[test]
@ -419,7 +417,6 @@ fn offset_from() {
}
#[test]
#[cfg(not(bootstrap))]
fn ptr_metadata() {
struct Unit;
struct Pair<A, B: ?Sized>(A, B);
@ -478,7 +475,6 @@ fn ptr_metadata() {
}
#[test]
#[cfg(not(bootstrap))]
fn ptr_metadata_bounds() {
fn metadata_eq_method_address<T: ?Sized>() -> usize {
// The `Metadata` associated type has an `Ord` bound, so this is valid:
@ -510,7 +506,6 @@ fn ptr_metadata_bounds() {
}
#[test]
#[cfg(not(bootstrap))]
fn dyn_metadata() {
#[derive(Debug)]
#[repr(align(32))]
@ -530,7 +525,6 @@ fn dyn_metadata() {
}
#[test]
#[cfg(not(bootstrap))]
fn from_raw_parts() {
let mut value = 5_u32;
let address = &mut value as *mut _ as *mut ();
@ -557,7 +551,6 @@ fn from_raw_parts() {
}
#[test]
#[cfg(not(bootstrap))]
fn thin_box() {
let foo = ThinBox::<dyn Display>::new(4);
assert_eq!(foo.to_string(), "4");

View file

@ -234,7 +234,7 @@
#![feature(box_syntax)]
#![feature(c_variadic)]
#![feature(cfg_accessible)]
#![cfg_attr(not(bootstrap), feature(cfg_eval))]
#![feature(cfg_eval)]
#![feature(cfg_target_has_atomic)]
#![feature(cfg_target_thread_local)]
#![feature(char_error_internals)]
@ -331,7 +331,6 @@
#![feature(try_blocks)]
#![feature(try_reserve)]
#![feature(unboxed_closures)]
#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
#![feature(unsafe_cell_raw_get)]
#![feature(unwind_attributes)]
#![feature(vec_into_raw_parts)]

View file

@ -54,7 +54,6 @@ pub use core::prelude::v1::{
bench, global_allocator, test, test_case, RustcDecodable, RustcEncodable,
};
#[cfg(not(bootstrap))]
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[doc(hidden)]
pub use core::prelude::v1::derive;
@ -67,7 +66,6 @@ pub use core::prelude::v1::derive;
#[doc(hidden)]
pub use core::prelude::v1::cfg_accessible;
#[cfg(not(bootstrap))]
#[unstable(
feature = "cfg_eval",
issue = "82679",

View file

@ -741,12 +741,7 @@ impl<'a> Builder<'a> {
.env("RUSTDOC_REAL", self.rustdoc(compiler))
.env("RUSTC_BOOTSTRAP", "1");
// cfg(bootstrap), can be removed on the next beta bump
if compiler.stage == 0 {
cmd.arg("-Winvalid_codeblock_attributes");
} else {
cmd.arg("-Wrustdoc::invalid_codeblock_attributes");
}
cmd.arg("-Wrustdoc::invalid_codeblock_attributes");
if self.config.deny_warnings {
cmd.arg("-Dwarnings");
@ -1303,12 +1298,7 @@ impl<'a> Builder<'a> {
// fixed via better support from Cargo.
cargo.env("RUSTC_LINT_FLAGS", lint_flags.join(" "));
// cfg(bootstrap), can be removed on the next beta bump
if compiler.stage == 0 {
rustdocflags.arg("-Winvalid_codeblock_attributes");
} else {
rustdocflags.arg("-Wrustdoc::invalid_codeblock_attributes");
}
rustdocflags.arg("-Wrustdoc::invalid_codeblock_attributes");
}
if mode == Mode::Rustc {

View file

@ -14,8 +14,6 @@
//! A few exceptions are allowed as there's known bugs in rustdoc, but this
//! should catch the majority of "broken link" cases.
#![cfg_attr(bootstrap, feature(str_split_once))]
use std::collections::hash_map::Entry;
use std::collections::{HashMap, HashSet};
use std::env;

View file

@ -3,8 +3,6 @@
//! This library contains the tidy lints and exposes it
//! to be used by tools.
#![cfg_attr(bootstrap, feature(str_split_once))]
use std::fs::File;
use std::io::Read;
use walkdir::{DirEntry, WalkDir};