1
Fork 0

Auto merge of #76090 - Dylan-DPC:rollup-eksndcr, r=Dylan-DPC

Rollup of 14 pull requests

Successful merges:

 - #75832 (Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs…)
 - #75852 (Switch to intra-doc links in `core::hash`)
 - #75874 (Shorten liballoc doc intra link while readable)
 - #75881 (Expand rustdoc theme chooser x padding)
 - #75885 (Fix another clashing_extern_declarations false positive.)
 - #75892 (Fix typo in TLS Model in Unstable Book)
 - #75910 (Add test for issue #27130)
 - #75917 (Move to intra doc links for core::ptr::non_null)
 - #75975 (Allow --bess ing expect-tests in tools)
 - #75990 (Add __fastfail for Windows on arm/aarch64)
 - #76015 (Fix loading pretty-printers in rust-lldb script)
 - #76022 (Clean up rustdoc front-end source code)
 - #76029 (Move to intra-doc links for library/core/src/sync/atomic.rs)
 - #76057 (Move retokenize hack to save_analysis)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-08-30 00:47:37 +00:00
commit 62850d882b
28 changed files with 350 additions and 590 deletions

View file

@ -3927,8 +3927,8 @@ dependencies = [
"rustc_data_structures", "rustc_data_structures",
"rustc_hir", "rustc_hir",
"rustc_hir_pretty", "rustc_hir_pretty",
"rustc_lexer",
"rustc_middle", "rustc_middle",
"rustc_parse",
"rustc_session", "rustc_session",
"rustc_span", "rustc_span",
"serde_json", "serde_json",

View file

@ -9,7 +9,7 @@
//! //!
//! # Examples //! # Examples
//! //!
//! You can explicitly create a [`Vec<T>`] with [`new`]: //! You can explicitly create a [`Vec`] with [`Vec::new`]:
//! //!
//! ``` //! ```
//! let v: Vec<i32> = Vec::new(); //! let v: Vec<i32> = Vec::new();
@ -50,8 +50,6 @@
//! v[1] = v[1] + 5; //! v[1] = v[1] + 5;
//! ``` //! ```
//! //!
//! [`Vec<T>`]: Vec
//! [`new`]: Vec::new
//! [`push`]: Vec::push //! [`push`]: Vec::push
#![stable(feature = "rust1", since = "1.0.0")] #![stable(feature = "rust1", since = "1.0.0")]

View file

@ -39,8 +39,6 @@
//! If you need more control over how a value is hashed, you need to implement //! If you need more control over how a value is hashed, you need to implement
//! the [`Hash`] trait: //! the [`Hash`] trait:
//! //!
//! [`Hash`]: trait.Hash.html
//!
//! ```rust //! ```rust
//! use std::collections::hash_map::DefaultHasher; //! use std::collections::hash_map::DefaultHasher;
//! use std::hash::{Hash, Hasher}; //! use std::hash::{Hash, Hasher};
@ -149,11 +147,9 @@ mod sip;
/// Thankfully, you won't need to worry about upholding this property when /// Thankfully, you won't need to worry about upholding this property when
/// deriving both [`Eq`] and `Hash` with `#[derive(PartialEq, Eq, Hash)]`. /// deriving both [`Eq`] and `Hash` with `#[derive(PartialEq, Eq, Hash)]`.
/// ///
/// [`Eq`]: ../../std/cmp/trait.Eq.html
/// [`Hasher`]: trait.Hasher.html
/// [`HashMap`]: ../../std/collections/struct.HashMap.html /// [`HashMap`]: ../../std/collections/struct.HashMap.html
/// [`HashSet`]: ../../std/collections/struct.HashSet.html /// [`HashSet`]: ../../std/collections/struct.HashSet.html
/// [`hash`]: #tymethod.hash /// [`hash`]: Hash::hash
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub trait Hash { pub trait Hash {
/// Feeds this value into the given [`Hasher`]. /// Feeds this value into the given [`Hasher`].
@ -168,8 +164,6 @@ pub trait Hash {
/// 7920.hash(&mut hasher); /// 7920.hash(&mut hasher);
/// println!("Hash is {:x}!", hasher.finish()); /// println!("Hash is {:x}!", hasher.finish());
/// ``` /// ```
///
/// [`Hasher`]: trait.Hasher.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
fn hash<H: Hasher>(&self, state: &mut H); fn hash<H: Hasher>(&self, state: &mut H);
@ -186,8 +180,6 @@ pub trait Hash {
/// Hash::hash_slice(&numbers, &mut hasher); /// Hash::hash_slice(&numbers, &mut hasher);
/// println!("Hash is {:x}!", hasher.finish()); /// println!("Hash is {:x}!", hasher.finish());
/// ``` /// ```
///
/// [`Hasher`]: trait.Hasher.html
#[stable(feature = "hash_slice", since = "1.3.0")] #[stable(feature = "hash_slice", since = "1.3.0")]
fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) fn hash_slice<H: Hasher>(data: &[Self], state: &mut H)
where where
@ -239,10 +231,9 @@ pub use macros::Hash;
/// println!("Hash is {:x}!", hasher.finish()); /// println!("Hash is {:x}!", hasher.finish());
/// ``` /// ```
/// ///
/// [`Hash`]: trait.Hash.html /// [`finish`]: Hasher::finish
/// [`finish`]: #tymethod.finish /// [`write`]: Hasher::write
/// [`write`]: #tymethod.write /// [`write_u8`]: Hasher::write_u8
/// [`write_u8`]: #method.write_u8
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub trait Hasher { pub trait Hasher {
/// Returns the hash value for the values written so far. /// Returns the hash value for the values written so far.
@ -264,7 +255,7 @@ pub trait Hasher {
/// println!("Hash is {:x}!", hasher.finish()); /// println!("Hash is {:x}!", hasher.finish());
/// ``` /// ```
/// ///
/// [`write`]: #tymethod.write /// [`write`]: Hasher::write
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
fn finish(&self) -> u64; fn finish(&self) -> u64;
@ -433,8 +424,7 @@ impl<H: Hasher + ?Sized> Hasher for &mut H {
/// assert_eq!(hasher_1.finish(), hasher_2.finish()); /// assert_eq!(hasher_1.finish(), hasher_2.finish());
/// ``` /// ```
/// ///
/// [`build_hasher`]: #tymethod.build_hasher /// [`build_hasher`]: BuildHasher::build_hasher
/// [`Hasher`]: trait.Hasher.html
/// [`HashMap`]: ../../std/collections/struct.HashMap.html /// [`HashMap`]: ../../std/collections/struct.HashMap.html
#[stable(since = "1.7.0", feature = "build_hasher")] #[stable(since = "1.7.0", feature = "build_hasher")]
pub trait BuildHasher { pub trait BuildHasher {
@ -456,8 +446,6 @@ pub trait BuildHasher {
/// let s = RandomState::new(); /// let s = RandomState::new();
/// let new_s = s.build_hasher(); /// let new_s = s.build_hasher();
/// ``` /// ```
///
/// [`Hasher`]: trait.Hasher.html
#[stable(since = "1.7.0", feature = "build_hasher")] #[stable(since = "1.7.0", feature = "build_hasher")]
fn build_hasher(&self) -> Self::Hasher; fn build_hasher(&self) -> Self::Hasher;
} }
@ -470,7 +458,7 @@ pub trait BuildHasher {
/// defined. /// defined.
/// ///
/// Any `BuildHasherDefault` is [zero-sized]. It can be created with /// Any `BuildHasherDefault` is [zero-sized]. It can be created with
/// [`default`][method.Default]. When using `BuildHasherDefault` with [`HashMap`] or /// [`default`][method.default]. When using `BuildHasherDefault` with [`HashMap`] or
/// [`HashSet`], this doesn't need to be done, since they implement appropriate /// [`HashSet`], this doesn't need to be done, since they implement appropriate
/// [`Default`] instances themselves. /// [`Default`] instances themselves.
/// ///
@ -503,10 +491,7 @@ pub trait BuildHasher {
/// let hash_map = HashMap::<u32, u32, MyBuildHasher>::default(); /// let hash_map = HashMap::<u32, u32, MyBuildHasher>::default();
/// ``` /// ```
/// ///
/// [`BuildHasher`]: trait.BuildHasher.html /// [method.default]: BuildHasherDefault::default
/// [`Default`]: ../default/trait.Default.html
/// [method.default]: #method.default
/// [`Hasher`]: trait.Hasher.html
/// [`HashMap`]: ../../std/collections/struct.HashMap.html /// [`HashMap`]: ../../std/collections/struct.HashMap.html
/// [`HashSet`]: ../../std/collections/struct.HashSet.html /// [`HashSet`]: ../../std/collections/struct.HashSet.html
/// [zero-sized]: https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts /// [zero-sized]: https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts

View file

@ -34,8 +34,8 @@ use crate::slice::{self, SliceIndex};
/// it is your responsibility to ensure that `as_mut` is never called, and `as_ptr` /// it is your responsibility to ensure that `as_mut` is never called, and `as_ptr`
/// is never used for mutation. /// is never used for mutation.
/// ///
/// [`PhantomData`]: ../marker/struct.PhantomData.html /// [`PhantomData`]: crate::marker::PhantomData
/// [`UnsafeCell<T>`]: ../cell/struct.UnsafeCell.html /// [`UnsafeCell<T>`]: crate::cell::UnsafeCell
#[stable(feature = "nonnull", since = "1.25.0")] #[stable(feature = "nonnull", since = "1.25.0")]
#[repr(transparent)] #[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)] #[rustc_layout_scalar_valid_range_start(1)]
@ -82,8 +82,8 @@ impl<T: Sized> NonNull<T> {
/// ///
/// For the mutable counterpart see [`as_uninit_mut`]. /// For the mutable counterpart see [`as_uninit_mut`].
/// ///
/// [`as_ref`]: #method.as_ref /// [`as_ref`]: NonNull::as_ref
/// [`as_uninit_mut`]: #method.as_uninit_mut /// [`as_uninit_mut`]: NonNull::as_uninit_mut
/// ///
/// # Safety /// # Safety
/// ///
@ -114,8 +114,8 @@ impl<T: Sized> NonNull<T> {
/// ///
/// For the shared counterpart see [`as_uninit_ref`]. /// For the shared counterpart see [`as_uninit_ref`].
/// ///
/// [`as_mut`]: #method.as_mut /// [`as_mut`]: NonNull::as_mut
/// [`as_uninit_ref`]: #method.as_uninit_ref /// [`as_uninit_ref`]: NonNull::as_uninit_ref
/// ///
/// # Safety /// # Safety
/// ///
@ -181,8 +181,8 @@ impl<T: ?Sized> NonNull<T> {
/// ///
/// For the mutable counterpart see [`as_mut`]. /// For the mutable counterpart see [`as_mut`].
/// ///
/// [`as_uninit_ref`]: #method.as_uninit_ref /// [`as_uninit_ref`]: NonNull::as_uninit_ref
/// [`as_mut`]: #method.as_mut /// [`as_mut`]: NonNull::as_mut
/// ///
/// # Safety /// # Safety
/// ///
@ -217,8 +217,8 @@ impl<T: ?Sized> NonNull<T> {
/// ///
/// For the shared counterpart see [`as_ref`]. /// For the shared counterpart see [`as_ref`].
/// ///
/// [`as_uninit_mut`]: #method.as_uninit_mut /// [`as_uninit_mut`]: NonNull::as_uninit_mut
/// [`as_ref`]: #method.as_ref /// [`as_ref`]: NonNull::as_ref
/// ///
/// # Safety /// # Safety
/// ///
@ -266,8 +266,6 @@ impl<T> NonNull<[T]> {
/// This function is safe, but dereferencing the return value is unsafe. /// This function is safe, but dereferencing the return value is unsafe.
/// See the documentation of [`slice::from_raw_parts`] for slice safety requirements. /// See the documentation of [`slice::from_raw_parts`] for slice safety requirements.
/// ///
/// [`slice::from_raw_parts`]: ../../std/slice/fn.from_raw_parts.html
///
/// # Examples /// # Examples
/// ///
/// ```rust /// ```rust
@ -357,8 +355,8 @@ impl<T> NonNull<[T]> {
/// ///
/// For the mutable counterpart see [`as_uninit_slice_mut`]. /// For the mutable counterpart see [`as_uninit_slice_mut`].
/// ///
/// [`as_ref`]: #method.as_ref /// [`as_ref`]: NonNull::as_ref
/// [`as_uninit_slice_mut`]: #method.as_uninit_slice_mut /// [`as_uninit_slice_mut`]: NonNull::as_uninit_slice_mut
/// ///
/// # Safety /// # Safety
/// ///
@ -386,10 +384,9 @@ impl<T> NonNull<[T]> {
/// ///
/// This applies even if the result of this method is unused! /// This applies even if the result of this method is unused!
/// ///
/// See also [`slice::from_raw_parts`][]. /// See also [`slice::from_raw_parts`].
/// ///
/// [valid]: crate::ptr#safety /// [valid]: crate::ptr#safety
/// [`NonNull::dangling()`]: NonNull::dangling
/// [`pointer::offset`]: ../../std/primitive.pointer.html#method.offset /// [`pointer::offset`]: ../../std/primitive.pointer.html#method.offset
#[inline] #[inline]
#[unstable(feature = "ptr_as_uninit", issue = "75402")] #[unstable(feature = "ptr_as_uninit", issue = "75402")]
@ -403,8 +400,8 @@ impl<T> NonNull<[T]> {
/// ///
/// For the shared counterpart see [`as_uninit_slice`]. /// For the shared counterpart see [`as_uninit_slice`].
/// ///
/// [`as_mut`]: #method.as_mut /// [`as_mut`]: NonNull::as_mut
/// [`as_uninit_slice`]: #method.as_uninit_slice /// [`as_uninit_slice`]: NonNull::as_uninit_slice
/// ///
/// # Safety /// # Safety
/// ///
@ -432,10 +429,9 @@ impl<T> NonNull<[T]> {
/// ///
/// This applies even if the result of this method is unused! /// This applies even if the result of this method is unused!
/// ///
/// See also [`slice::from_raw_parts_mut`][]. /// See also [`slice::from_raw_parts_mut`].
/// ///
/// [valid]: crate::ptr#safety /// [valid]: crate::ptr#safety
/// [`NonNull::dangling()`]: NonNull::dangling
/// [`pointer::offset`]: ../../std/primitive.pointer.html#method.offset /// [`pointer::offset`]: ../../std/primitive.pointer.html#method.offset
/// ///
/// # Examples /// # Examples

View file

@ -10,18 +10,10 @@
//! Atomic types present operations that, when used correctly, synchronize //! Atomic types present operations that, when used correctly, synchronize
//! updates between threads. //! updates between threads.
//! //!
//! [`AtomicBool`]: struct.AtomicBool.html
//! [`AtomicIsize`]: struct.AtomicIsize.html
//! [`AtomicUsize`]: struct.AtomicUsize.html
//! [`AtomicI8`]: struct.AtomicI8.html
//! [`AtomicU16`]: struct.AtomicU16.html
//!
//! Each method takes an [`Ordering`] which represents the strength of //! Each method takes an [`Ordering`] which represents the strength of
//! the memory barrier for that operation. These orderings are the //! the memory barrier for that operation. These orderings are the
//! same as the [C++20 atomic orderings][1]. For more information see the [nomicon][2]. //! same as the [C++20 atomic orderings][1]. For more information see the [nomicon][2].
//! //!
//! [`Ordering`]: enum.Ordering.html
//!
//! [1]: https://en.cppreference.com/w/cpp/atomic/memory_order //! [1]: https://en.cppreference.com/w/cpp/atomic/memory_order
//! [2]: ../../../nomicon/atomics.html //! [2]: ../../../nomicon/atomics.html
//! //!
@ -31,15 +23,12 @@
//! The most common way to share an atomic variable is to put it into an [`Arc`][arc] (an //! The most common way to share an atomic variable is to put it into an [`Arc`][arc] (an
//! atomically-reference-counted shared pointer). //! atomically-reference-counted shared pointer).
//! //!
//! [`Sync`]: ../../marker/trait.Sync.html
//! [arc]: ../../../std/sync/struct.Arc.html //! [arc]: ../../../std/sync/struct.Arc.html
//! //!
//! Atomic types may be stored in static variables, initialized using //! Atomic types may be stored in static variables, initialized using
//! the constant initializers like [`AtomicBool::new`]. Atomic statics //! the constant initializers like [`AtomicBool::new`]. Atomic statics
//! are often used for lazy global initialization. //! are often used for lazy global initialization.
//! //!
//! [`AtomicBool::new`]: struct.AtomicBool.html#method.new
//!
//! # Portability //! # Portability
//! //!
//! All atomic types in this module are guaranteed to be [lock-free] if they're //! All atomic types in this module are guaranteed to be [lock-free] if they're
@ -155,8 +144,6 @@ pub fn spin_loop_hint() {
/// ///
/// **Note**: This type is only available on platforms that support atomic /// **Note**: This type is only available on platforms that support atomic
/// loads and stores of `u8`. /// loads and stores of `u8`.
///
/// [`bool`]: ../../../std/primitive.bool.html
#[cfg(target_has_atomic_load_store = "8")] #[cfg(target_has_atomic_load_store = "8")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[repr(C, align(1))] #[repr(C, align(1))]
@ -212,8 +199,8 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
/// Atomic memory orderings /// Atomic memory orderings
/// ///
/// Memory orderings specify the way atomic operations synchronize memory. /// Memory orderings specify the way atomic operations synchronize memory.
/// In its weakest [`Relaxed`][Ordering::Relaxed], only the memory directly touched by the /// In its weakest [`Ordering::Relaxed`], only the memory directly touched by the
/// operation is synchronized. On the other hand, a store-load pair of [`SeqCst`][Ordering::SeqCst] /// operation is synchronized. On the other hand, a store-load pair of [`Ordering::SeqCst`]
/// operations synchronize other memory while additionally preserving a total order of such /// operations synchronize other memory while additionally preserving a total order of such
/// operations across all threads. /// operations across all threads.
/// ///
@ -223,8 +210,6 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
/// For more information see the [nomicon]. /// For more information see the [nomicon].
/// ///
/// [nomicon]: ../../../nomicon/atomics.html /// [nomicon]: ../../../nomicon/atomics.html
/// [Ordering::Relaxed]: #variant.Relaxed
/// [Ordering::SeqCst]: #variant.SeqCst
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
#[non_exhaustive] #[non_exhaustive]
@ -248,9 +233,6 @@ pub enum Ordering {
/// ///
/// Corresponds to [`memory_order_release`] in C++20. /// Corresponds to [`memory_order_release`] in C++20.
/// ///
/// [`Release`]: #variant.Release
/// [`Acquire`]: #variant.Acquire
/// [`Relaxed`]: #variant.Relaxed
/// [`memory_order_release`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Release-Acquire_ordering /// [`memory_order_release`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Release-Acquire_ordering
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
Release, Release,
@ -266,9 +248,6 @@ pub enum Ordering {
/// ///
/// Corresponds to [`memory_order_acquire`] in C++20. /// Corresponds to [`memory_order_acquire`] in C++20.
/// ///
/// [`Acquire`]: #variant.Acquire
/// [`Release`]: #variant.Release
/// [`Relaxed`]: #variant.Relaxed
/// [`memory_order_acquire`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Release-Acquire_ordering /// [`memory_order_acquire`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Release-Acquire_ordering
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
Acquire, Acquire,
@ -284,9 +263,6 @@ pub enum Ordering {
/// Corresponds to [`memory_order_acq_rel`] in C++20. /// Corresponds to [`memory_order_acq_rel`] in C++20.
/// ///
/// [`memory_order_acq_rel`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Release-Acquire_ordering /// [`memory_order_acq_rel`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Release-Acquire_ordering
/// [`Acquire`]: #variant.Acquire
/// [`Release`]: #variant.Release
/// [`Relaxed`]: #variant.Relaxed
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
AcqRel, AcqRel,
/// Like [`Acquire`]/[`Release`]/[`AcqRel`] (for load, store, and load-with-store /// Like [`Acquire`]/[`Release`]/[`AcqRel`] (for load, store, and load-with-store
@ -296,16 +272,11 @@ pub enum Ordering {
/// Corresponds to [`memory_order_seq_cst`] in C++20. /// Corresponds to [`memory_order_seq_cst`] in C++20.
/// ///
/// [`memory_order_seq_cst`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Sequentially-consistent_ordering /// [`memory_order_seq_cst`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Sequentially-consistent_ordering
/// [`Acquire`]: #variant.Acquire
/// [`Release`]: #variant.Release
/// [`AcqRel`]: #variant.AcqRel
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
SeqCst, SeqCst,
} }
/// An [`AtomicBool`] initialized to `false`. /// An [`AtomicBool`] initialized to `false`.
///
/// [`AtomicBool`]: struct.AtomicBool.html
#[cfg(target_has_atomic_load_store = "8")] #[cfg(target_has_atomic_load_store = "8")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated( #[rustc_deprecated(
@ -339,8 +310,6 @@ impl AtomicBool {
/// This is safe because the mutable reference guarantees that no other threads are /// This is safe because the mutable reference guarantees that no other threads are
/// concurrently accessing the atomic data. /// concurrently accessing the atomic data.
/// ///
/// [`bool`]: ../../../std/primitive.bool.html
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -386,13 +355,6 @@ impl AtomicBool {
/// ///
/// Panics if `order` is [`Release`] or [`AcqRel`]. /// Panics if `order` is [`Release`] or [`AcqRel`].
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -419,13 +381,6 @@ impl AtomicBool {
/// ///
/// Panics if `order` is [`Acquire`] or [`AcqRel`]. /// Panics if `order` is [`Acquire`] or [`AcqRel`].
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -456,11 +411,6 @@ impl AtomicBool {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on `u8`. /// operations on `u8`.
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -493,13 +443,6 @@ impl AtomicBool {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on `u8`. /// operations on `u8`.
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
/// [`bool`]: ../../../std/primitive.bool.html
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -539,13 +482,6 @@ impl AtomicBool {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on `u8`. /// operations on `u8`.
/// ///
/// [`bool`]: ../../../std/primitive.bool.html
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -587,7 +523,7 @@ impl AtomicBool {
/// Stores a value into the [`bool`] if the current value is the same as the `current` value. /// Stores a value into the [`bool`] if the current value is the same as the `current` value.
/// ///
/// Unlike [`compare_exchange`], this function is allowed to spuriously fail even when the /// Unlike [`AtomicBool::compare_exchange`], this function is allowed to spuriously fail even when the
/// comparison succeeds, which can result in more efficient code on some platforms. The /// comparison succeeds, which can result in more efficient code on some platforms. The
/// return value is a result indicating whether the new value was written and containing the /// return value is a result indicating whether the new value was written and containing the
/// previous value. /// previous value.
@ -603,14 +539,6 @@ impl AtomicBool {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on `u8`. /// operations on `u8`.
/// ///
/// [`bool`]: ../../../std/primitive.bool.html
/// [`compare_exchange`]: #method.compare_exchange
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -658,11 +586,6 @@ impl AtomicBool {
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and /// [`Acquire`] makes the store part of this operation [`Relaxed`], and
/// using [`Release`] makes the load part [`Relaxed`]. /// using [`Release`] makes the load part [`Relaxed`].
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
///
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on `u8`. /// operations on `u8`.
/// ///
@ -706,11 +629,6 @@ impl AtomicBool {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on `u8`. /// operations on `u8`.
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -763,11 +681,6 @@ impl AtomicBool {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on `u8`. /// operations on `u8`.
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -808,11 +721,6 @@ impl AtomicBool {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on `u8`. /// operations on `u8`.
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -850,8 +758,6 @@ impl AtomicBool {
/// use of the returned raw pointer requires an `unsafe` block and still has to uphold the same /// use of the returned raw pointer requires an `unsafe` block and still has to uphold the same
/// restriction: operations on it must be atomic. /// restriction: operations on it must be atomic.
/// ///
/// [`bool`]: ../../../std/primitive.bool.html
///
/// # Examples /// # Examples
/// ///
/// ```ignore (extern-declaration) /// ```ignore (extern-declaration)
@ -942,13 +848,6 @@ impl<T> AtomicPtr<T> {
/// ///
/// Panics if `order` is [`Release`] or [`AcqRel`]. /// Panics if `order` is [`Release`] or [`AcqRel`].
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -975,13 +874,6 @@ impl<T> AtomicPtr<T> {
/// ///
/// Panics if `order` is [`Acquire`] or [`AcqRel`]. /// Panics if `order` is [`Acquire`] or [`AcqRel`].
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -1013,11 +905,6 @@ impl<T> AtomicPtr<T> {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on pointers. /// operations on pointers.
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -1052,12 +939,6 @@ impl<T> AtomicPtr<T> {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on pointers. /// operations on pointers.
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -1096,12 +977,6 @@ impl<T> AtomicPtr<T> {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on pointers. /// operations on pointers.
/// ///
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -1143,7 +1018,7 @@ impl<T> AtomicPtr<T> {
/// Stores a value into the pointer if the current value is the same as the `current` value. /// Stores a value into the pointer if the current value is the same as the `current` value.
/// ///
/// Unlike [`compare_exchange`], this function is allowed to spuriously fail even when the /// Unlike [`AtomicPtr::compare_exchange`], this function is allowed to spuriously fail even when the
/// comparison succeeds, which can result in more efficient code on some platforms. The /// comparison succeeds, which can result in more efficient code on some platforms. The
/// return value is a result indicating whether the new value was written and containing the /// return value is a result indicating whether the new value was written and containing the
/// previous value. /// previous value.
@ -1159,13 +1034,6 @@ impl<T> AtomicPtr<T> {
/// **Note:** This method is only available on platforms that support atomic /// **Note:** This method is only available on platforms that support atomic
/// operations on pointers. /// operations on pointers.
/// ///
/// [`compare_exchange`]: #method.compare_exchange
/// [`Ordering`]: enum.Ordering.html
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -1271,7 +1139,7 @@ macro_rules! atomic_int {
#[doc = $int_ref] #[doc = $int_ref]
/// ). /// ).
/// ///
/// [module-level documentation]: index.html /// [module-level documentation]: crate::sync::atomic
#[$stable] #[$stable]
#[repr(C, align($align))] #[repr(C, align($align))]
pub struct $atomic_type { pub struct $atomic_type {
@ -1389,13 +1257,6 @@ Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`].
Panics if `order` is [`Release`] or [`AcqRel`]. Panics if `order` is [`Release`] or [`AcqRel`].
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
[`AcqRel`]: enum.Ordering.html#variant.AcqRel
[`SeqCst`]: enum.Ordering.html#variant.SeqCst
# Examples # Examples
``` ```
@ -1423,13 +1284,6 @@ assert_eq!(some_var.load(Ordering::Relaxed), 5);
Panics if `order` is [`Acquire`] or [`AcqRel`]. Panics if `order` is [`Acquire`] or [`AcqRel`].
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
[`AcqRel`]: enum.Ordering.html#variant.AcqRel
[`SeqCst`]: enum.Ordering.html#variant.SeqCst
# Examples # Examples
``` ```
@ -1459,11 +1313,6 @@ using [`Release`] makes the load part [`Relaxed`].
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
# Examples # Examples
``` ```
@ -1498,12 +1347,6 @@ happens, and using [`Release`] makes the load part [`Relaxed`].
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
[`AcqRel`]: enum.Ordering.html#variant.AcqRel
# Examples # Examples
``` ```
@ -1553,12 +1396,6 @@ and must be equivalent to or weaker than the success ordering.
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
[`SeqCst`]: enum.Ordering.html#variant.SeqCst
# Examples # Examples
``` ```
@ -1595,7 +1432,7 @@ assert_eq!(some_var.load(Ordering::Relaxed), 10);
concat!("Stores a value into the atomic integer if the current value is the same as concat!("Stores a value into the atomic integer if the current value is the same as
the `current` value. the `current` value.
Unlike [`compare_exchange`], this function is allowed to spuriously fail even Unlike [`", stringify!($atomic_type), "::compare_exchange`], this function is allowed to spuriously fail even
when the comparison succeeds, which can result in more efficient code on some when the comparison succeeds, which can result in more efficient code on some
platforms. The return value is a result indicating whether the new value was platforms. The return value is a result indicating whether the new value was
written and containing the previous value. written and containing the previous value.
@ -1608,13 +1445,6 @@ of this operation [`Relaxed`], and using [`Release`] makes the successful load
[`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`] [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
and must be equivalent to or weaker than the success ordering. and must be equivalent to or weaker than the success ordering.
[`compare_exchange`]: #method.compare_exchange
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
[`SeqCst`]: enum.Ordering.html#variant.SeqCst
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
@ -1662,11 +1492,6 @@ using [`Release`] makes the load part [`Relaxed`].
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
# Examples # Examples
``` ```
@ -1698,11 +1523,6 @@ using [`Release`] makes the load part [`Relaxed`].
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
# Examples # Examples
``` ```
@ -1737,11 +1557,6 @@ using [`Release`] makes the load part [`Relaxed`].
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
# Examples # Examples
``` ```
@ -1776,11 +1591,6 @@ using [`Release`] makes the load part [`Relaxed`].
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
# Examples # Examples
``` ```
@ -1816,11 +1626,6 @@ using [`Release`] makes the load part [`Relaxed`].
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
# Examples # Examples
``` ```
@ -1855,11 +1660,6 @@ using [`Release`] makes the load part [`Relaxed`].
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
# Examples # Examples
``` ```
@ -1890,7 +1690,7 @@ only once to the stored value.
`fetch_update` takes two [`Ordering`] arguments to describe the memory ordering of this operation. `fetch_update` takes two [`Ordering`] arguments to describe the memory ordering of this operation.
The first describes the required ordering for when the operation finally succeeds while the second The first describes the required ordering for when the operation finally succeeds while the second
describes the required ordering for loads. These correspond to the success and failure orderings of describes the required ordering for loads. These correspond to the success and failure orderings of
[`compare_exchange`] respectively. [`", stringify!($atomic_type), "::compare_exchange`] respectively.
Using [`Acquire`] as success ordering makes the store part Using [`Acquire`] as success ordering makes the store part
of this operation [`Relaxed`], and using [`Release`] makes the final successful load of this operation [`Relaxed`], and using [`Release`] makes the final successful load
@ -1900,14 +1700,6 @@ and must be equivalent to or weaker than the success ordering.
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`bool`]: ../../../std/primitive.bool.html
[`compare_exchange`]: #method.compare_exchange
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
[`SeqCst`]: enum.Ordering.html#variant.SeqCst
# Examples # Examples
```rust ```rust
@ -1954,11 +1746,6 @@ using [`Release`] makes the load part [`Relaxed`].
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
# Examples # Examples
``` ```
@ -2004,11 +1791,6 @@ using [`Release`] makes the load part [`Relaxed`].
**Note**: This method is only available on platforms that support atomic **Note**: This method is only available on platforms that support atomic
operations on [`", $s_int_type, "`](", $int_ref, "). operations on [`", $s_int_type, "`](", $int_ref, ").
[`Ordering`]: enum.Ordering.html
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
[`Release`]: enum.Ordering.html#variant.Release
[`Acquire`]: enum.Ordering.html#variant.Acquire
# Examples # Examples
``` ```
@ -2660,13 +2442,6 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
/// } /// }
/// } /// }
/// ``` /// ```
///
/// [`Ordering`]: enum.Ordering.html
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
#[inline] #[inline]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn fence(order: Ordering) { pub fn fence(order: Ordering) {
@ -2747,13 +2522,6 @@ pub fn fence(order: Ordering) {
/// } /// }
/// ``` /// ```
/// ///
/// [`fence`]: fn.fence.html
/// [`Ordering`]: enum.Ordering.html
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [memory barriers]: https://www.kernel.org/doc/Documentation/memory-barriers.txt /// [memory barriers]: https://www.kernel.org/doc/Documentation/memory-barriers.txt
#[inline] #[inline]
#[stable(feature = "compiler_fences", since = "1.21.0")] #[stable(feature = "compiler_fences", since = "1.21.0")]

View file

@ -17,7 +17,7 @@
#![feature(panic_runtime)] #![feature(panic_runtime)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(llvm_asm)] #![feature(asm)]
use core::any::Any; use core::any::Any;
@ -47,7 +47,7 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 {
} }
__rust_abort(); __rust_abort();
} }
} else if #[cfg(all(windows, any(target_arch = "x86", target_arch = "x86_64")))] { } else if #[cfg(windows)] {
// On Windows, use the processor-specific __fastfail mechanism. In Windows 8 // On Windows, use the processor-specific __fastfail mechanism. In Windows 8
// and later, this will terminate the process immediately without running any // and later, this will terminate the process immediately without running any
// in-process exception handlers. In earlier versions of Windows, this // in-process exception handlers. In earlier versions of Windows, this
@ -59,7 +59,18 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 {
// //
// Note: this is the same implementation as in libstd's `abort_internal` // Note: this is the same implementation as in libstd's `abort_internal`
unsafe fn abort() -> ! { unsafe fn abort() -> ! {
llvm_asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT const FAST_FAIL_FATAL_APP_EXIT: usize = 7;
cfg_if::cfg_if! {
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT);
} else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] {
asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT);
} else if #[cfg(target_arch = "aarch64")] {
asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT);
} else {
core::intrinsics::abort();
}
}
core::intrinsics::unreachable(); core::intrinsics::unreachable();
} }
} else { } else {

View file

@ -20,10 +20,9 @@
/// assert!(!bool_val); /// assert!(!bool_val);
/// ``` /// ```
/// ///
/// [`assert!`]: macro.assert.html /// [`BitAnd`]: ops::BitAnd
/// [`BitAnd`]: ops/trait.BitAnd.html /// [`BitOr`]: ops::BitOr
/// [`BitOr`]: ops/trait.BitOr.html /// [`Not`]: ops::Not
/// [`Not`]: ops/trait.Not.html
/// ///
/// # Examples /// # Examples
/// ///
@ -46,7 +45,7 @@
/// } /// }
/// ``` /// ```
/// ///
/// Also, since `bool` implements the [`Copy`](marker/trait.Copy.html) trait, we don't /// Also, since `bool` implements the [`Copy`] trait, we don't
/// have to worry about the move semantics (just like the integer and float primitives). /// have to worry about the move semantics (just like the integer and float primitives).
/// ///
/// Now an example of `bool` cast to integer type: /// Now an example of `bool` cast to integer type:
@ -100,8 +99,8 @@ mod prim_bool {}
/// at all we know it can never produce a value which isn't a [`u32`]. This illustrates another /// at all we know it can never produce a value which isn't a [`u32`]. This illustrates another
/// behaviour of the `!` type - expressions with type `!` will coerce into any other type. /// behaviour of the `!` type - expressions with type `!` will coerce into any other type.
/// ///
/// [`u32`]: primitive.str.html /// [`u32`]: prim@u32
/// [`exit`]: process/fn.exit.html /// [`exit`]: process::exit
/// ///
/// # `!` and generics /// # `!` and generics
/// ///
@ -185,14 +184,12 @@ mod prim_bool {}
/// ever stops, it means that an error occurred. We don't even have to wrap the loop in an `Ok` /// ever stops, it means that an error occurred. We don't even have to wrap the loop in an `Ok`
/// because `!` coerces to `Result<!, ConnectionError>` automatically. /// because `!` coerces to `Result<!, ConnectionError>` automatically.
/// ///
/// [`String::from_str`]: str/trait.FromStr.html#tymethod.from_str /// [`String::from_str`]: str::FromStr::from_str
/// [`Result<String, !>`]: result/enum.Result.html /// [`Result<String, !>`]: Result
/// [`Result<T, !>`]: result/enum.Result.html /// [`Result<T, !>`]: Result
/// [`Result<!, E>`]: result/enum.Result.html /// [`Result<!, E>`]: Result
/// [`Ok`]: result/enum.Result.html#variant.Ok /// [`String`]: string::String
/// [`String`]: string/struct.String.html /// [`FromStr`]: str::FromStr
/// [`Err`]: result/enum.Result.html#variant.Err
/// [`FromStr`]: str/trait.FromStr.html
/// ///
/// # `!` and traits /// # `!` and traits
/// ///
@ -233,11 +230,9 @@ mod prim_bool {}
/// `impl` for this which simply panics, but the same is true for any type (we could `impl /// `impl` for this which simply panics, but the same is true for any type (we could `impl
/// Default` for (eg.) [`File`] by just making [`default()`] panic.) /// Default` for (eg.) [`File`] by just making [`default()`] panic.)
/// ///
/// [`fmt::Result`]: fmt/type.Result.html /// [`File`]: fs::File
/// [`File`]: fs/struct.File.html /// [`Debug`]: fmt::Debug
/// [`Debug`]: fmt/trait.Debug.html /// [`default()`]: Default::default
/// [`Default`]: default/trait.Default.html
/// [`default()`]: default/trait.Default.html#tymethod.default
/// ///
#[unstable(feature = "never_type", issue = "35121")] #[unstable(feature = "never_type", issue = "35121")]
mod prim_never {} mod prim_never {}
@ -360,7 +355,7 @@ mod prim_unit {}
// //
/// Raw, unsafe pointers, `*const T`, and `*mut T`. /// Raw, unsafe pointers, `*const T`, and `*mut T`.
/// ///
/// *[See also the `std::ptr` module](ptr/index.html).* /// *[See also the `std::ptr` module][`ptr`].*
/// ///
/// Working with raw pointers in Rust is uncommon, typically limited to a few patterns. /// Working with raw pointers in Rust is uncommon, typically limited to a few patterns.
/// Raw pointers can be unaligned or [`null`]. However, when a raw pointer is /// Raw pointers can be unaligned or [`null`]. However, when a raw pointer is
@ -439,13 +434,13 @@ mod prim_unit {}
/// but C APIs hand out a lot of pointers generally, so are a common source /// but C APIs hand out a lot of pointers generally, so are a common source
/// of raw pointers in Rust. /// of raw pointers in Rust.
/// ///
/// [`null`]: ../std/ptr/fn.null.html /// [`null`]: ptr::null
/// [`null_mut`]: ../std/ptr/fn.null_mut.html /// [`null_mut`]: ptr::null_mut
/// [`is_null`]: ../std/primitive.pointer.html#method.is_null /// [`is_null`]: ../std/primitive.pointer.html#method.is_null
/// [`offset`]: ../std/primitive.pointer.html#method.offset /// [`offset`]: ../std/primitive.pointer.html#method.offset
/// [`into_raw`]: ../std/boxed/struct.Box.html#method.into_raw /// [`into_raw`]: Box::into_raw
/// [`drop`]: ../std/mem/fn.drop.html /// [`drop`]: mem::drop
/// [`write`]: ../std/ptr/fn.write.html /// [`write`]: ptr::write
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
mod prim_pointer {} mod prim_pointer {}
@ -458,24 +453,24 @@ mod prim_pointer {}
/// ///
/// * A list with each element, i.e., `[x, y, z]`. /// * A list with each element, i.e., `[x, y, z]`.
/// * A repeat expression `[x; N]`, which produces an array with `N` copies of `x`. /// * A repeat expression `[x; N]`, which produces an array with `N` copies of `x`.
/// The type of `x` must be [`Copy`][copy]. /// The type of `x` must be [`Copy`].
/// ///
/// Arrays of *any* size implement the following traits if the element type allows it: /// Arrays of *any* size implement the following traits if the element type allows it:
/// ///
/// - [`Debug`][debug] /// - [`Debug`]
/// - [`IntoIterator`][intoiterator] (implemented for `&[T; N]` and `&mut [T; N]`) /// - [`IntoIterator`] (implemented for `&[T; N]` and `&mut [T; N]`)
/// - [`PartialEq`][partialeq], [`PartialOrd`][partialord], [`Eq`][eq], [`Ord`][ord] /// - [`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`]
/// - [`Hash`][hash] /// - [`Hash`]
/// - [`AsRef`][asref], [`AsMut`][asmut] /// - [`AsRef`], [`AsMut`]
/// - [`Borrow`][borrow], [`BorrowMut`][borrowmut] /// - [`Borrow`], [`BorrowMut`]
/// ///
/// Arrays of sizes from 0 to 32 (inclusive) implement [`Default`][default] trait /// Arrays of sizes from 0 to 32 (inclusive) implement [`Default`] trait
/// if the element type allows it. As a stopgap, trait implementations are /// if the element type allows it. As a stopgap, trait implementations are
/// statically generated up to size 32. /// statically generated up to size 32.
/// ///
/// Arrays of *any* size are [`Copy`][copy] if the element type is [`Copy`][copy] /// Arrays of *any* size are [`Copy`] if the element type is [`Copy`]
/// and [`Clone`][clone] if the element type is [`Clone`][clone]. This works /// and [`Clone`] if the element type is [`Clone`]. This works
/// because [`Copy`][copy] and [`Clone`][clone] traits are specially known /// because [`Copy`] and [`Clone`] traits are specially known
/// to the compiler. /// to the compiler.
/// ///
/// Arrays coerce to [slices (`[T]`)][slice], so a slice method may be called on /// Arrays coerce to [slices (`[T]`)][slice], so a slice method may be called on
@ -483,7 +478,7 @@ mod prim_pointer {}
/// Slices have a dynamic size and do not coerce to arrays. /// Slices have a dynamic size and do not coerce to arrays.
/// ///
/// You can move elements out of an array with a slice pattern. If you want /// You can move elements out of an array with a slice pattern. If you want
/// one element, see [`mem::replace`][replace]. /// one element, see [`mem::replace`].
/// ///
/// # Examples /// # Examples
/// ///
@ -535,22 +530,10 @@ mod prim_pointer {}
/// ``` /// ```
/// ///
/// [slice]: primitive.slice.html /// [slice]: primitive.slice.html
/// [copy]: marker/trait.Copy.html /// [`Debug`]: fmt::Debug
/// [clone]: clone/trait.Clone.html /// [`Hash`]: hash::Hash
/// [debug]: fmt/trait.Debug.html /// [`Borrow`]: borrow::Borrow
/// [intoiterator]: iter/trait.IntoIterator.html /// [`BorrowMut`]: borrow::BorrowMut
/// [partialeq]: cmp/trait.PartialEq.html
/// [partialord]: cmp/trait.PartialOrd.html
/// [eq]: cmp/trait.Eq.html
/// [ord]: cmp/trait.Ord.html
/// [hash]: hash/trait.Hash.html
/// [asref]: convert/trait.AsRef.html
/// [asmut]: convert/trait.AsMut.html
/// [borrow]: borrow/trait.Borrow.html
/// [borrowmut]: borrow/trait.BorrowMut.html
/// [default]: default/trait.Default.html
/// [replace]: mem/fn.replace.html
/// [`IntoIterator`]: iter/trait.IntoIterator.html
/// ///
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
mod prim_array {} mod prim_array {}
@ -563,7 +546,7 @@ mod prim_array {}
/// means that elements are laid out so that every element is the same /// means that elements are laid out so that every element is the same
/// distance from its neighbors. /// distance from its neighbors.
/// ///
/// *[See also the `std::slice` module](slice/index.html).* /// *[See also the `std::slice` module][`crate::slice`].*
/// ///
/// Slices are a view into a block of memory represented as a pointer and a /// Slices are a view into a block of memory represented as a pointer and a
/// length. /// length.
@ -608,7 +591,7 @@ mod prim_slice {}
// //
/// String slices. /// String slices.
/// ///
/// *[See also the `std::str` module](str/index.html).* /// *[See also the `std::str` module][`crate::str`].*
/// ///
/// The `str` type, also called a 'string slice', is the most primitive string /// The `str` type, also called a 'string slice', is the most primitive string
/// type. It is usually seen in its borrowed form, `&str`. It is also the type /// type. It is usually seen in its borrowed form, `&str`. It is also the type
@ -660,8 +643,8 @@ mod prim_slice {}
/// assert_eq!(s, Ok(story)); /// assert_eq!(s, Ok(story));
/// ``` /// ```
/// ///
/// [`as_ptr`]: #method.as_ptr /// [`as_ptr`]: str::as_ptr
/// [`len`]: #method.len /// [`len`]: str::len
/// ///
/// Note: This example shows the internals of `&str`. `unsafe` should not be /// Note: This example shows the internals of `&str`. `unsafe` should not be
/// used to get a string slice under normal circumstances. Use `as_str` /// used to get a string slice under normal circumstances. Use `as_str`
@ -729,15 +712,8 @@ mod prim_str {}
/// * [`Default`] /// * [`Default`]
/// * [`Hash`] /// * [`Hash`]
/// ///
/// [`Clone`]: clone/trait.Clone.html /// [`Debug`]: fmt::Debug
/// [`Copy`]: marker/trait.Copy.html /// [`Hash`]: hash::Hash
/// [`PartialEq`]: cmp/trait.PartialEq.html
/// [`Eq`]: cmp/trait.Eq.html
/// [`PartialOrd`]: cmp/trait.PartialOrd.html
/// [`Ord`]: cmp/trait.Ord.html
/// [`Debug`]: fmt/trait.Debug.html
/// [`Default`]: default/trait.Default.html
/// [`Hash`]: hash/trait.Hash.html
/// ///
/// Due to a temporary restriction in Rust's type system, these traits are only /// Due to a temporary restriction in Rust's type system, these traits are only
/// implemented on tuples of arity 12 or less. In the future, this may change. /// implemented on tuples of arity 12 or less. In the future, this may change.
@ -810,7 +786,7 @@ mod prim_tuple {}
/// ///
/// For more information on floating point numbers, see [Wikipedia][wikipedia]. /// For more information on floating point numbers, see [Wikipedia][wikipedia].
/// ///
/// *[See also the `std::f32::consts` module](f32/consts/index.html).* /// *[See also the `std::f32::consts` module][`crate::f32::consts`].*
/// ///
/// [wikipedia]: https://en.wikipedia.org/wiki/Single-precision_floating-point_format /// [wikipedia]: https://en.wikipedia.org/wiki/Single-precision_floating-point_format
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
@ -819,13 +795,14 @@ mod prim_f32 {}
#[doc(primitive = "f64")] #[doc(primitive = "f64")]
/// A 64-bit floating point type (specifically, the "binary64" type defined in IEEE 754-2008). /// A 64-bit floating point type (specifically, the "binary64" type defined in IEEE 754-2008).
/// ///
/// This type is very similar to [`f32`](primitive.f32.html), but has increased /// This type is very similar to [`f32`], but has increased
/// precision by using twice as many bits. Please see [the documentation for /// precision by using twice as many bits. Please see [the documentation for
/// `f32`](primitive.f32.html) or [Wikipedia on double precision /// `f32`][`f32`] or [Wikipedia on double precision
/// values][wikipedia] for more information. /// values][wikipedia] for more information.
/// ///
/// *[See also the `std::f64::consts` module](f64/consts/index.html).* /// *[See also the `std::f64::consts` module][`crate::f64::consts`].*
/// ///
/// [`f32`]: prim@f32
/// [wikipedia]: https://en.wikipedia.org/wiki/Double-precision_floating-point_format /// [wikipedia]: https://en.wikipedia.org/wiki/Double-precision_floating-point_format
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
mod prim_f64 {} mod prim_f64 {}
@ -945,9 +922,6 @@ mod prim_usize {}
/// implicit reference-pointer coercion and raw pointer equality via [`ptr::eq`], while /// implicit reference-pointer coercion and raw pointer equality via [`ptr::eq`], while
/// [`PartialEq`] compares values. /// [`PartialEq`] compares values.
/// ///
/// [`ptr::eq`]: ptr/fn.eq.html
/// [`PartialEq`]: cmp/trait.PartialEq.html
///
/// ``` /// ```
/// use std::ptr; /// use std::ptr;
/// ///
@ -979,11 +953,9 @@ mod prim_usize {}
/// * [`Borrow`] /// * [`Borrow`]
/// * [`Pointer`] /// * [`Pointer`]
/// ///
/// [`Copy`]: marker/trait.Copy.html /// [`Deref`]: ops::Deref
/// [`Clone`]: clone/trait.Clone.html /// [`Borrow`]: borrow::Borrow
/// [`Deref`]: ops/trait.Deref.html /// [`Pointer`]: fmt::Pointer
/// [`Borrow`]: borrow/trait.Borrow.html
/// [`Pointer`]: fmt/trait.Pointer.html
/// ///
/// `&mut T` references get all of the above except `Copy` and `Clone` (to prevent creating /// `&mut T` references get all of the above except `Copy` and `Clone` (to prevent creating
/// multiple simultaneous mutable borrows), plus the following, regardless of the type of its /// multiple simultaneous mutable borrows), plus the following, regardless of the type of its
@ -992,8 +964,8 @@ mod prim_usize {}
/// * [`DerefMut`] /// * [`DerefMut`]
/// * [`BorrowMut`] /// * [`BorrowMut`]
/// ///
/// [`DerefMut`]: ops/trait.DerefMut.html /// [`DerefMut`]: ops::DerefMut
/// [`BorrowMut`]: borrow/trait.BorrowMut.html /// [`BorrowMut`]: borrow::BorrowMut
/// ///
/// The following traits are implemented on `&T` references if the underlying `T` also implements /// The following traits are implemented on `&T` references if the underlying `T` also implements
/// that trait: /// that trait:
@ -1008,18 +980,10 @@ mod prim_usize {}
/// * [`Hash`] /// * [`Hash`]
/// * [`ToSocketAddrs`] /// * [`ToSocketAddrs`]
/// ///
/// [`std::fmt`]: fmt/index.html /// [`std::fmt`]: fmt
/// [`fmt::Write`]: fmt/trait.Write.html /// ['Pointer`]: fmt::Pointer
/// [`PartialOrd`]: cmp/trait.PartialOrd.html /// [`Hash`]: hash::Hash
/// [`Ord`]: cmp/trait.Ord.html /// [`ToSocketAddrs`]: net::ToSocketAddrs
/// [`PartialEq`]: cmp/trait.PartialEq.html
/// [`Eq`]: cmp/trait.Eq.html
/// [`AsRef`]: convert/trait.AsRef.html
/// [`Fn`]: ops/trait.Fn.html
/// [`FnMut`]: ops/trait.FnMut.html
/// [`FnOnce`]: ops/trait.FnOnce.html
/// [`Hash`]: hash/trait.Hash.html
/// [`ToSocketAddrs`]: net/trait.ToSocketAddrs.html
/// ///
/// `&mut T` references get all of the above except `ToSocketAddrs`, plus the following, if `T` /// `&mut T` references get all of the above except `ToSocketAddrs`, plus the following, if `T`
/// implements that trait: /// implements that trait:
@ -1038,17 +1002,11 @@ mod prim_usize {}
/// * [`Seek`] /// * [`Seek`]
/// * [`BufRead`] /// * [`BufRead`]
/// ///
/// [`AsMut`]: convert/trait.AsMut.html /// [`FusedIterator`]: iter::FusedIterator
/// [`Iterator`]: iter/trait.Iterator.html /// [`TrustedLen`]: iter::TrustedLen
/// [`DoubleEndedIterator`]: iter/trait.DoubleEndedIterator.html /// [`Seek`]: io::Seek
/// [`ExactSizeIterator`]: iter/trait.ExactSizeIterator.html /// [`BufRead`]: io::BufRead
/// [`FusedIterator`]: iter/trait.FusedIterator.html /// [`Read`]: io::Read
/// [`TrustedLen`]: iter/trait.TrustedLen.html
/// [`Send`]: marker/trait.Send.html
/// [`io::Write`]: io/trait.Write.html
/// [`Read`]: io/trait.Read.html
/// [`Seek`]: io/trait.Seek.html
/// [`BufRead`]: io/trait.BufRead.html
/// ///
/// Note that due to method call deref coercion, simply calling a trait method will act like they /// Note that due to method call deref coercion, simply calling a trait method will act like they
/// work on references as well as they do on owned values! The implementations described here are /// work on references as well as they do on owned values! The implementations described here are
@ -1063,9 +1021,9 @@ mod prim_ref {}
/// ///
/// *See also the traits [`Fn`], [`FnMut`], and [`FnOnce`].* /// *See also the traits [`Fn`], [`FnMut`], and [`FnOnce`].*
/// ///
/// [`Fn`]: ops/trait.Fn.html /// [`Fn`]: ops::Fn
/// [`FnMut`]: ops/trait.FnMut.html /// [`FnMut`]: ops::FnMut
/// [`FnOnce`]: ops/trait.FnOnce.html /// [`FnOnce`]: ops::FnOnce
/// ///
/// Function pointers are pointers that point to *code*, not data. They can be called /// Function pointers are pointers that point to *code*, not data. They can be called
/// just like functions. Like references, function pointers are, among other things, assumed to /// just like functions. Like references, function pointers are, among other things, assumed to
@ -1177,14 +1135,8 @@ mod prim_ref {}
/// * [`Pointer`] /// * [`Pointer`]
/// * [`Debug`] /// * [`Debug`]
/// ///
/// [`Clone`]: clone/trait.Clone.html /// [`Hash`]: hash::Hash
/// [`PartialEq`]: cmp/trait.PartialEq.html /// [`Pointer`]: fmt::Pointer
/// [`Eq`]: cmp/trait.Eq.html
/// [`PartialOrd`]: cmp/trait.PartialOrd.html
/// [`Ord`]: cmp/trait.Ord.html
/// [`Hash`]: hash/trait.Hash.html
/// [`Pointer`]: fmt/trait.Pointer.html
/// [`Debug`]: fmt/trait.Debug.html
/// ///
/// Due to a temporary restriction in Rust's type system, these traits are only implemented on /// Due to a temporary restriction in Rust's type system, these traits are only implemented on
/// functions that take 12 arguments or less, with the `"Rust"` and `"C"` ABIs. In the future, this /// functions that take 12 arguments or less, with the `"Rust"` and `"C"` ABIs. In the future, this
@ -1193,7 +1145,5 @@ mod prim_ref {}
/// In addition, function pointers of *any* signature, ABI, or safety are [`Copy`], and all *safe* /// In addition, function pointers of *any* signature, ABI, or safety are [`Copy`], and all *safe*
/// function pointers implement [`Fn`], [`FnMut`], and [`FnOnce`]. This works because these traits /// function pointers implement [`Fn`], [`FnMut`], and [`FnOnce`]. This works because these traits
/// are specially known to the compiler. /// are specially known to the compiler.
///
/// [`Copy`]: marker/trait.Copy.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
mod prim_fn {} mod prim_fn {}

View file

@ -9,8 +9,6 @@ use crate::sys::fs::osstr2str;
use crate::sys_common::{AsInner, AsInnerMut, FromInner}; use crate::sys_common::{AsInner, AsInnerMut, FromInner};
/// WASI-specific extensions to [`File`]. /// WASI-specific extensions to [`File`].
///
/// [`File`]: ../../../../std/fs/struct.File.html
pub trait FileExt { pub trait FileExt {
/// Reads a number of bytes starting from a given offset. /// Reads a number of bytes starting from a given offset.
/// ///
@ -23,8 +21,6 @@ pub trait FileExt {
/// ///
/// Note that similar to [`File::read`], it is not an error to return with a /// Note that similar to [`File::read`], it is not an error to return with a
/// short read. /// short read.
///
/// [`File::read`]: ../../../../std/fs/struct.File.html#method.read
fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> { fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
let bufs = &mut [IoSliceMut::new(buf)]; let bufs = &mut [IoSliceMut::new(buf)];
self.read_vectored_at(bufs, offset) self.read_vectored_at(bufs, offset)
@ -41,8 +37,6 @@ pub trait FileExt {
/// ///
/// Note that similar to [`File::read_vectored`], it is not an error to /// Note that similar to [`File::read_vectored`], it is not an error to
/// return with a short read. /// return with a short read.
///
/// [`File::read`]: ../../../../std/fs/struct.File.html#method.read_vectored
fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize>; fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize>;
/// Reads the exact number of byte required to fill `buf` from the given offset. /// Reads the exact number of byte required to fill `buf` from the given offset.
@ -54,8 +48,7 @@ pub trait FileExt {
/// ///
/// Similar to [`Read::read_exact`] but uses [`read_at`] instead of `read`. /// Similar to [`Read::read_exact`] but uses [`read_at`] instead of `read`.
/// ///
/// [`Read::read_exact`]: ../../../../std/io/trait.Read.html#method.read_exact /// [`read_at`]: FileExt::read_at
/// [`read_at`]: #tymethod.read_at
/// ///
/// # Errors /// # Errors
/// ///
@ -73,9 +66,6 @@ pub trait FileExt {
/// If this function returns an error, it is unspecified how many bytes it /// If this function returns an error, it is unspecified how many bytes it
/// has read, but it will never read more than would be necessary to /// has read, but it will never read more than would be necessary to
/// completely fill the buffer. /// completely fill the buffer.
///
/// [`ErrorKind::Interrupted`]: ../../../../std/io/enum.ErrorKind.html#variant.Interrupted
/// [`ErrorKind::UnexpectedEof`]: ../../../../std/io/enum.ErrorKind.html#variant.UnexpectedEof
#[stable(feature = "rw_exact_all_at", since = "1.33.0")] #[stable(feature = "rw_exact_all_at", since = "1.33.0")]
fn read_exact_at(&self, mut buf: &mut [u8], mut offset: u64) -> io::Result<()> { fn read_exact_at(&self, mut buf: &mut [u8], mut offset: u64) -> io::Result<()> {
while !buf.is_empty() { while !buf.is_empty() {
@ -111,8 +101,6 @@ pub trait FileExt {
/// ///
/// Note that similar to [`File::write`], it is not an error to return a /// Note that similar to [`File::write`], it is not an error to return a
/// short write. /// short write.
///
/// [`File::write`]: ../../../../std/fs/struct.File.html#write.v
fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> { fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
let bufs = &[IoSlice::new(buf)]; let bufs = &[IoSlice::new(buf)];
self.write_vectored_at(bufs, offset) self.write_vectored_at(bufs, offset)
@ -132,8 +120,6 @@ pub trait FileExt {
/// ///
/// Note that similar to [`File::write_vectored`], it is not an error to return a /// Note that similar to [`File::write_vectored`], it is not an error to return a
/// short write. /// short write.
///
/// [`File::write`]: ../../../../std/fs/struct.File.html#method.write_vectored
fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize>; fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize>;
/// Attempts to write an entire buffer starting from a given offset. /// Attempts to write an entire buffer starting from a given offset.
@ -155,8 +141,7 @@ pub trait FileExt {
/// This function will return the first error of /// This function will return the first error of
/// non-[`ErrorKind::Interrupted`] kind that [`write_at`] returns. /// non-[`ErrorKind::Interrupted`] kind that [`write_at`] returns.
/// ///
/// [`ErrorKind::Interrupted`]: ../../../../std/io/enum.ErrorKind.html#variant.Interrupted /// [`write_at`]: FileExt::write_at
/// [`write_at`]: #tymethod.write_at
#[stable(feature = "rw_exact_all_at", since = "1.33.0")] #[stable(feature = "rw_exact_all_at", since = "1.33.0")]
fn write_all_at(&self, mut buf: &[u8], mut offset: u64) -> io::Result<()> { fn write_all_at(&self, mut buf: &[u8], mut offset: u64) -> io::Result<()> {
while !buf.is_empty() { while !buf.is_empty() {
@ -289,8 +274,6 @@ impl FileExt for fs::File {
} }
/// WASI-specific extensions to [`fs::OpenOptions`]. /// WASI-specific extensions to [`fs::OpenOptions`].
///
/// [`fs::OpenOptions`]: ../../../../std/fs/struct.OpenOptions.html
pub trait OpenOptionsExt { pub trait OpenOptionsExt {
/// Pass custom `dirflags` argument to `path_open`. /// Pass custom `dirflags` argument to `path_open`.
/// ///
@ -406,8 +389,6 @@ impl OpenOptionsExt for OpenOptions {
} }
/// WASI-specific extensions to [`fs::Metadata`]. /// WASI-specific extensions to [`fs::Metadata`].
///
/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
pub trait MetadataExt { pub trait MetadataExt {
/// Returns the `st_dev` field of the internal `filestat_t` /// Returns the `st_dev` field of the internal `filestat_t`
fn dev(&self) -> u64; fn dev(&self) -> u64;
@ -448,8 +429,6 @@ impl MetadataExt for fs::Metadata {
/// ///
/// Adds support for special WASI file types such as block/character devices, /// Adds support for special WASI file types such as block/character devices,
/// pipes, and sockets. /// pipes, and sockets.
///
/// [`FileType`]: ../../../../std/fs/struct.FileType.html
pub trait FileTypeExt { pub trait FileTypeExt {
/// Returns `true` if this file type is a block device. /// Returns `true` if this file type is a block device.
fn is_block_device(&self) -> bool; fn is_block_device(&self) -> bool;
@ -477,8 +456,6 @@ impl FileTypeExt for fs::FileType {
} }
/// WASI-specific extension methods for [`fs::DirEntry`]. /// WASI-specific extension methods for [`fs::DirEntry`].
///
/// [`fs::DirEntry`]: ../../../../std/fs/struct.DirEntry.html
pub trait DirEntryExt { pub trait DirEntryExt {
/// Returns the underlying `d_ino` field of the `dirent_t` /// Returns the underlying `d_ino` field of the `dirent_t`
fn ino(&self) -> u64; fn ino(&self) -> u64;

View file

@ -306,10 +306,20 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD {
/// that function for more information on `__fastfail` /// that function for more information on `__fastfail`
#[allow(unreachable_code)] #[allow(unreachable_code)]
pub fn abort_internal() -> ! { pub fn abort_internal() -> ! {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] const FAST_FAIL_FATAL_APP_EXIT: usize = 7;
unsafe { unsafe {
llvm_asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT cfg_if::cfg_if! {
crate::intrinsics::unreachable(); if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT);
crate::intrinsics::unreachable();
} else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] {
asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT);
crate::intrinsics::unreachable();
} else if #[cfg(target_arch = "aarch64")] {
asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT);
crate::intrinsics::unreachable();
}
}
} }
crate::intrinsics::abort(); crate::intrinsics::abort();
} }

View file

@ -232,23 +232,17 @@ impl Slice {
} }
/// Platform-specific extensions to [`OsString`]. /// Platform-specific extensions to [`OsString`].
///
/// [`OsString`]: ../../../../std/ffi/struct.OsString.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStringExt { pub trait OsStringExt {
/// Creates an [`OsString`] from a byte vector. /// Creates an [`OsString`] from a byte vector.
/// ///
/// See the module documentation for an example. /// See the module documentation for an example.
///
/// [`OsString`]: ../../../ffi/struct.OsString.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
fn from_vec(vec: Vec<u8>) -> Self; fn from_vec(vec: Vec<u8>) -> Self;
/// Yields the underlying byte vector of this [`OsString`]. /// Yields the underlying byte vector of this [`OsString`].
/// ///
/// See the module documentation for an example. /// See the module documentation for an example.
///
/// [`OsString`]: ../../../ffi/struct.OsString.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
fn into_vec(self) -> Vec<u8>; fn into_vec(self) -> Vec<u8>;
} }
@ -264,23 +258,17 @@ impl OsStringExt for OsString {
} }
/// Platform-specific extensions to [`OsStr`]. /// Platform-specific extensions to [`OsStr`].
///
/// [`OsStr`]: ../../../../std/ffi/struct.OsStr.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStrExt { pub trait OsStrExt {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
/// Creates an [`OsStr`] from a byte slice. /// Creates an [`OsStr`] from a byte slice.
/// ///
/// See the module documentation for an example. /// See the module documentation for an example.
///
/// [`OsStr`]: ../../../ffi/struct.OsStr.html
fn from_bytes(slice: &[u8]) -> &Self; fn from_bytes(slice: &[u8]) -> &Self;
/// Gets the underlying byte view of the [`OsStr`] slice. /// Gets the underlying byte view of the [`OsStr`] slice.
/// ///
/// See the module documentation for an example. /// See the module documentation for an example.
///
/// [`OsStr`]: ../../../ffi/struct.OsStr.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
fn as_bytes(&self) -> &[u8]; fn as_bytes(&self) -> &[u8];
} }

View file

@ -3,6 +3,9 @@ use crate::fmt;
use crate::sync::atomic::{AtomicBool, Ordering}; use crate::sync::atomic::{AtomicBool, Ordering};
use crate::thread; use crate::thread;
#[allow(unused_imports)] // for intra-doc links
use crate::sync::{Mutex, RwLock};
pub struct Flag { pub struct Flag {
failed: AtomicBool, failed: AtomicBool,
} }
@ -77,9 +80,6 @@ pub struct Guard {
/// } /// }
/// }; /// };
/// ``` /// ```
///
/// [`Mutex`]: ../../std/sync/struct.Mutex.html
/// [`RwLock`]: ../../std/sync/struct.RwLock.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct PoisonError<T> { pub struct PoisonError<T> {
guard: T, guard: T,
@ -89,12 +89,9 @@ pub struct PoisonError<T> {
/// can occur while trying to acquire a lock, from the [`try_lock`] method on a /// can occur while trying to acquire a lock, from the [`try_lock`] method on a
/// [`Mutex`] or the [`try_read`] and [`try_write`] methods on an [`RwLock`]. /// [`Mutex`] or the [`try_read`] and [`try_write`] methods on an [`RwLock`].
/// ///
/// [`Mutex`]: struct.Mutex.html /// [`try_lock`]: Mutex::try_lock
/// [`RwLock`]: struct.RwLock.html /// [`try_read`]: RwLock::try_read
/// [`TryLockResult`]: type.TryLockResult.html /// [`try_write`]: RwLock::try_write
/// [`try_lock`]: struct.Mutex.html#method.try_lock
/// [`try_read`]: struct.RwLock.html#method.try_read
/// [`try_write`]: struct.RwLock.html#method.try_write
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub enum TryLockError<T> { pub enum TryLockError<T> {
/// The lock could not be acquired because another thread failed while holding /// The lock could not be acquired because another thread failed while holding
@ -115,9 +112,7 @@ pub enum TryLockError<T> {
/// the associated guard, and it can be acquired through the [`into_inner`] /// the associated guard, and it can be acquired through the [`into_inner`]
/// method. /// method.
/// ///
/// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok /// [`into_inner`]: PoisonError::into_inner
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
/// [`into_inner`]: ../../std/sync/struct.PoisonError.html#method.into_inner
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub type LockResult<Guard> = Result<Guard, PoisonError<Guard>>; pub type LockResult<Guard> = Result<Guard, PoisonError<Guard>>;
@ -126,9 +121,6 @@ pub type LockResult<Guard> = Result<Guard, PoisonError<Guard>>;
/// For more information, see [`LockResult`]. A `TryLockResult` doesn't /// For more information, see [`LockResult`]. A `TryLockResult` doesn't
/// necessarily hold the associated guard in the [`Err`] type as the lock may not /// necessarily hold the associated guard in the [`Err`] type as the lock may not
/// have been acquired for other reasons. /// have been acquired for other reasons.
///
/// [`LockResult`]: ../../std/sync/type.LockResult.html
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub type TryLockResult<Guard> = Result<Guard, TryLockError<Guard>>; pub type TryLockResult<Guard> = Result<Guard, TryLockError<Guard>>;
@ -158,9 +150,6 @@ impl<T> PoisonError<T> {
/// Creates a `PoisonError`. /// Creates a `PoisonError`.
/// ///
/// This is generally created by methods like [`Mutex::lock`] or [`RwLock::read`]. /// This is generally created by methods like [`Mutex::lock`] or [`RwLock::read`].
///
/// [`Mutex::lock`]: ../../std/sync/struct.Mutex.html#method.lock
/// [`RwLock::read`]: ../../std/sync/struct.RwLock.html#method.read
#[stable(feature = "sync_poison", since = "1.2.0")] #[stable(feature = "sync_poison", since = "1.2.0")]
pub fn new(guard: T) -> PoisonError<T> { pub fn new(guard: T) -> PoisonError<T> {
PoisonError { guard } PoisonError { guard }

View file

@ -1079,6 +1079,11 @@ impl<'a> Builder<'a> {
}, },
); );
if self.config.cmd.bless() {
// Bless `expect!` tests.
cargo.env("UPDATE_EXPECT", "1");
}
if !mode.is_tool() { if !mode.is_tool() {
cargo.env("RUSTC_FORCE_UNSTABLE", "1"); cargo.env("RUSTC_FORCE_UNSTABLE", "1");
} }

View file

@ -647,6 +647,7 @@ impl Step for DebuggerScripts {
cp_debugger_script("lldb_lookup.py"); cp_debugger_script("lldb_lookup.py");
cp_debugger_script("lldb_providers.py"); cp_debugger_script("lldb_providers.py");
cp_debugger_script("lldb_commands")
} }
} }
} }

View file

@ -1754,11 +1754,6 @@ impl Step for Crate {
cargo.arg("--quiet"); cargo.arg("--quiet");
} }
if builder.config.cmd.bless() {
// Bless `expect!` tests.
cargo.env("UPDATE_EXPECT", "1");
}
if target.contains("emscripten") { if target.contains("emscripten") {
cargo.env( cargo.env(
format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),

View file

@ -22,4 +22,4 @@ The TLS data must not be in a library loaded after startup (via `dlopen`).
but not in a shared library, and is accessed only from that executable. but not in a shared library, and is accessed only from that executable.
`rustc` and LLVM may use a more optimized model than specified if they know that we are producing `rustc` and LLVM may use a more optimized model than specified if they know that we are producing
and executable rather than a library, or that the `static` item is private enough. an executable rather than a library, or that the `static` item is private enough.

View file

@ -1,4 +1,3 @@
command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_lookup.py\"
type synthetic add -l lldb_lookup.synthetic_lookup -x \".*\" --category Rust type synthetic add -l lldb_lookup.synthetic_lookup -x \".*\" --category Rust
type summary add -F lldb_lookup.summary_lookup -e -x -h \"^(alloc::([a-z_]+::)+)String$\" --category Rust type summary add -F lldb_lookup.summary_lookup -e -x -h \"^(alloc::([a-z_]+::)+)String$\" --category Rust
type summary add -F lldb_lookup.summary_lookup -e -x -h \"^&str$\" --category Rust type summary add -F lldb_lookup.summary_lookup -e -x -h \"^&str$\" --category Rust

View file

@ -30,5 +30,8 @@ EOF
fi fi
fi fi
script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_lookup.py\""
commands_file="$RUSTC_SYSROOT/lib/rustlib/etc/lldb_commands"
# Call LLDB with the commands added to the argument list # Call LLDB with the commands added to the argument list
exec "$lldb" --source-before-file ./lldb_commands "$@" exec "$lldb" --one-line-before-file "$script_import" --source-before-file "$commands_file" "$@"

View file

@ -38,6 +38,7 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::{ForeignItemKind, GenericParamKind, PatKind}; use rustc_hir::{ForeignItemKind, GenericParamKind, PatKind};
use rustc_hir::{HirId, HirIdSet, Node}; use rustc_hir::{HirId, HirIdSet, Node};
use rustc_index::vec::Idx;
use rustc_middle::lint::LintDiagnosticBuilder; use rustc_middle::lint::LintDiagnosticBuilder;
use rustc_middle::ty::subst::{GenericArgKind, Subst}; use rustc_middle::ty::subst::{GenericArgKind, Subst};
use rustc_middle::ty::{self, layout::LayoutError, Ty, TyCtxt}; use rustc_middle::ty::{self, layout::LayoutError, Ty, TyCtxt};
@ -2162,6 +2163,40 @@ impl ClashingExternDeclarations {
ckind: CItemKind, ckind: CItemKind,
) -> bool { ) -> bool {
debug!("structurally_same_type_impl(cx, a = {:?}, b = {:?})", a, b); debug!("structurally_same_type_impl(cx, a = {:?}, b = {:?})", a, b);
let tcx = cx.tcx;
// Given a transparent newtype, reach through and grab the inner
// type unless the newtype makes the type non-null.
let non_transparent_ty = |ty: Ty<'tcx>| -> Ty<'tcx> {
let mut ty = ty;
loop {
if let ty::Adt(def, substs) = ty.kind {
let is_transparent = def.subst(tcx, substs).repr.transparent();
let is_non_null = crate::types::nonnull_optimization_guaranteed(tcx, &def);
debug!(
"non_transparent_ty({:?}) -- type is transparent? {}, type is non-null? {}",
ty, is_transparent, is_non_null
);
if is_transparent && !is_non_null {
debug_assert!(def.variants.len() == 1);
let v = &def.variants[VariantIdx::new(0)];
ty = v
.transparent_newtype_field(tcx)
.expect(
"single-variant transparent structure with zero-sized field",
)
.ty(tcx, substs);
continue;
}
}
debug!("non_transparent_ty -> {:?}", ty);
return ty;
}
};
let a = non_transparent_ty(a);
let b = non_transparent_ty(b);
if !seen_types.insert((a, b)) { if !seen_types.insert((a, b)) {
// We've encountered a cycle. There's no point going any further -- the types are // We've encountered a cycle. There's no point going any further -- the types are
// structurally the same. // structurally the same.

View file

@ -11,7 +11,7 @@ use rustc_index::vec::Idx;
use rustc_middle::mir::interpret::{sign_extend, truncate}; use rustc_middle::mir::interpret::{sign_extend, truncate};
use rustc_middle::ty::layout::{IntegerExt, SizeSkeleton}; use rustc_middle::ty::layout::{IntegerExt, SizeSkeleton};
use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::subst::SubstsRef;
use rustc_middle::ty::{self, AdtKind, Ty, TypeFoldable}; use rustc_middle::ty::{self, AdtKind, Ty, TyCtxt, TypeFoldable};
use rustc_span::source_map; use rustc_span::source_map;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{Span, DUMMY_SP};
@ -527,22 +527,26 @@ enum FfiResult<'tcx> {
FfiUnsafe { ty: Ty<'tcx>, reason: String, help: Option<String> }, FfiUnsafe { ty: Ty<'tcx>, reason: String, help: Option<String> },
} }
crate fn nonnull_optimization_guaranteed<'tcx>(tcx: TyCtxt<'tcx>, def: &ty::AdtDef) -> bool {
tcx.get_attrs(def.did)
.iter()
.any(|a| tcx.sess.check_name(a, sym::rustc_nonnull_optimization_guaranteed))
}
/// Is type known to be non-null? /// Is type known to be non-null?
fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKind) -> bool { crate fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKind) -> bool {
let tcx = cx.tcx; let tcx = cx.tcx;
match ty.kind { match ty.kind {
ty::FnPtr(_) => true, ty::FnPtr(_) => true,
ty::Ref(..) => true, ty::Ref(..) => true,
ty::Adt(def, _) if def.is_box() && matches!(mode, CItemKind::Definition) => true, ty::Adt(def, _) if def.is_box() && matches!(mode, CItemKind::Definition) => true,
ty::Adt(def, substs) if def.repr.transparent() && !def.is_union() => { ty::Adt(def, substs) if def.repr.transparent() && !def.is_union() => {
let guaranteed_nonnull_optimization = tcx let marked_non_null = nonnull_optimization_guaranteed(tcx, &def);
.get_attrs(def.did)
.iter()
.any(|a| tcx.sess.check_name(a, sym::rustc_nonnull_optimization_guaranteed));
if guaranteed_nonnull_optimization { if marked_non_null {
return true; return true;
} }
for variant in &def.variants { for variant in &def.variants {
if let Some(field) = variant.transparent_newtype_field(tcx) { if let Some(field) = variant.transparent_newtype_field(tcx) {
if ty_is_known_nonnull(cx, field.ty(tcx, substs), mode) { if ty_is_known_nonnull(cx, field.ty(tcx, substs), mode) {

View file

@ -46,19 +46,10 @@ impl<'a> StringReader<'a> {
source_file: Lrc<rustc_span::SourceFile>, source_file: Lrc<rustc_span::SourceFile>,
override_span: Option<Span>, override_span: Option<Span>,
) -> Self { ) -> Self {
// Make sure external source is loaded first, before accessing it. let src = source_file.src.clone().unwrap_or_else(|| {
// While this can't show up during normal parsing, `retokenize` may
// be called with a source file from an external crate.
sess.source_map().ensure_source_file_source_present(Lrc::clone(&source_file));
let src = if let Some(src) = &source_file.src {
Lrc::clone(&src)
} else if let Some(src) = source_file.external_src.borrow().get_source() {
Lrc::clone(&src)
} else {
sess.span_diagnostic sess.span_diagnostic
.bug(&format!("cannot lex `source_file` without source: {}", source_file.name)); .bug(&format!("cannot lex `source_file` without source: {}", source_file.name));
}; });
StringReader { StringReader {
sess, sess,
@ -70,23 +61,6 @@ impl<'a> StringReader<'a> {
} }
} }
pub fn retokenize(sess: &'a ParseSess, mut span: Span) -> Self {
let begin = sess.source_map().lookup_byte_offset(span.lo());
let end = sess.source_map().lookup_byte_offset(span.hi());
// Make the range zero-length if the span is invalid.
if begin.sf.start_pos != end.sf.start_pos {
span = span.shrink_to_lo();
}
let mut sr = StringReader::new(sess, begin.sf, None);
// Seek the lexer to the right byte range.
sr.end_src_index = sr.src_index(span.hi());
sr
}
fn mk_sp(&self, lo: BytePos, hi: BytePos) -> Span { fn mk_sp(&self, lo: BytePos, hi: BytePos) -> Span {
self.override_span.unwrap_or_else(|| Span::with_root_ctxt(lo, hi)) self.override_span.unwrap_or_else(|| Span::with_root_ctxt(lo, hi))
} }

View file

@ -16,7 +16,7 @@ rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_data_structures = { path = "../librustc_data_structures" } rustc_data_structures = { path = "../librustc_data_structures" }
rustc_hir = { path = "../librustc_hir" } rustc_hir = { path = "../librustc_hir" }
rustc_hir_pretty = { path = "../librustc_hir_pretty" } rustc_hir_pretty = { path = "../librustc_hir_pretty" }
rustc_parse = { path = "../librustc_parse" } rustc_lexer = { path = "../librustc_lexer" }
serde_json = "1" serde_json = "1"
rustc_session = { path = "../librustc_session" } rustc_session = { path = "../librustc_session" }
rustc_span = { path = "../librustc_span" } rustc_span = { path = "../librustc_span" }

View file

@ -14,7 +14,7 @@
//! recording the output. //! recording the output.
use rustc_ast as ast; use rustc_ast as ast;
use rustc_ast::{token, walk_list}; use rustc_ast::walk_list;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind as HirDefKind, Res}; use rustc_hir::def::{DefKind as HirDefKind, Res};
@ -1207,9 +1207,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
// Otherwise it's a span with wrong macro expansion info, which // Otherwise it's a span with wrong macro expansion info, which
// we don't want to track anyway, since it's probably macro-internal `use` // we don't want to track anyway, since it's probably macro-internal `use`
if let Some(sub_span) = if let Some(sub_span) = self.span.sub_span_of_star(item.span) {
self.span.sub_span_of_token(item.span, token::BinOp(token::Star))
{
if !self.span.filter_generated(item.span) { if !self.span.filter_generated(item.span) {
let access = access_from!(self.save_ctxt, item, item.hir_id); let access = access_from!(self.save_ctxt, item, item.hir_id);
let span = self.span_from_span(sub_span); let span = self.span_from_span(sub_span);

View file

@ -1,6 +1,6 @@
use crate::generated_code; use crate::generated_code;
use rustc_ast::token::{self, TokenKind}; use rustc_data_structures::sync::Lrc;
use rustc_parse::lexer::{self, StringReader}; use rustc_lexer::{tokenize, TokenKind};
use rustc_session::Session; use rustc_session::Session;
use rustc_span::*; use rustc_span::*;
@ -43,62 +43,38 @@ impl<'a> SpanUtils<'a> {
} }
} }
pub fn retokenise_span(&self, span: Span) -> StringReader<'a> { /// Finds the span of `*` token withing the larger `span`.
lexer::StringReader::retokenize(&self.sess.parse_sess, span) pub fn sub_span_of_star(&self, mut span: Span) -> Option<Span> {
} let begin = self.sess.source_map().lookup_byte_offset(span.lo());
let end = self.sess.source_map().lookup_byte_offset(span.hi());
pub fn sub_span_of_token(&self, span: Span, tok: TokenKind) -> Option<Span> { // Make the range zero-length if the span is invalid.
let mut toks = self.retokenise_span(span); if begin.sf.start_pos != end.sf.start_pos {
loop { span = span.shrink_to_lo();
let next = toks.next_token();
if next == token::Eof {
return None;
}
if next == tok {
return Some(next.span);
}
} }
let sf = Lrc::clone(&begin.sf);
self.sess.source_map().ensure_source_file_source_present(Lrc::clone(&sf));
let src =
sf.src.clone().or_else(|| sf.external_src.borrow().get_source().map(Lrc::clone))?;
let to_index = |pos: BytePos| -> usize { (pos - sf.start_pos).0 as usize };
let text = &src[to_index(span.lo())..to_index(span.hi())];
let start_pos = {
let mut pos = 0;
tokenize(text)
.map(|token| {
let start = pos;
pos += token.len;
(start, token)
})
.find(|(_pos, token)| token.kind == TokenKind::Star)?
.0
};
let lo = span.lo() + BytePos(start_pos as u32);
let hi = lo + BytePos(1);
Some(span.with_lo(lo).with_hi(hi))
} }
// // Return the name for a macro definition (identifier after first `!`)
// pub fn span_for_macro_def_name(&self, span: Span) -> Option<Span> {
// let mut toks = self.retokenise_span(span);
// loop {
// let ts = toks.real_token();
// if ts == token::Eof {
// return None;
// }
// if ts == token::Not {
// let ts = toks.real_token();
// if ts.kind.is_ident() {
// return Some(ts.sp);
// } else {
// return None;
// }
// }
// }
// }
// // Return the name for a macro use (identifier before first `!`).
// pub fn span_for_macro_use_name(&self, span:Span) -> Option<Span> {
// let mut toks = self.retokenise_span(span);
// let mut prev = toks.real_token();
// loop {
// if prev == token::Eof {
// return None;
// }
// let ts = toks.real_token();
// if ts == token::Not {
// if prev.kind.is_ident() {
// return Some(prev.sp);
// } else {
// return None;
// }
// }
// prev = ts;
// }
// }
/// Return true if the span is generated code, and /// Return true if the span is generated code, and
/// it is not a subspan of the root callsite. /// it is not a subspan of the root callsite.
/// ///

View file

@ -92,6 +92,7 @@ function defocusSearchBar() {
var disableShortcuts = getCurrentValue("rustdoc-disable-shortcuts") === "true"; var disableShortcuts = getCurrentValue("rustdoc-disable-shortcuts") === "true";
var search_input = getSearchInput(); var search_input = getSearchInput();
var searchTimeout = null; var searchTimeout = null;
var toggleAllDocsId = "toggle-all-docs";
// On the search screen, so you remain on the last tab you opened. // On the search screen, so you remain on the last tab you opened.
// //
@ -1397,8 +1398,8 @@ function defocusSearchBar() {
// "current" is used to know which tab we're looking into. // "current" is used to know which tab we're looking into.
var current = 0; var current = 0;
onEachLazy(document.getElementById("results").childNodes, function(e) { onEachLazy(document.getElementById("results").childNodes, function(e) {
onEachLazy(e.getElementsByClassName("highlighted"), function(e) { onEachLazy(e.getElementsByClassName("highlighted"), function(h_e) {
actives[current].push(e); actives[current].push(h_e);
}); });
current += 1; current += 1;
}); });
@ -2121,7 +2122,7 @@ function defocusSearchBar() {
} }
function toggleAllDocs(pageId, fromAutoCollapse) { function toggleAllDocs(pageId, fromAutoCollapse) {
var innerToggle = document.getElementById("toggle-all-docs"); var innerToggle = document.getElementById(toggleAllDocsId);
if (!innerToggle) { if (!innerToggle) {
return; return;
} }
@ -2314,11 +2315,6 @@ function defocusSearchBar() {
} }
} }
var toggles = document.getElementById("toggle-all-docs");
if (toggles) {
toggles.onclick = toggleAllDocs;
}
function insertAfter(newNode, referenceNode) { function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
} }
@ -2368,6 +2364,11 @@ function defocusSearchBar() {
} }
(function() { (function() {
var toggles = document.getElementById(toggleAllDocsId);
if (toggles) {
toggles.onclick = toggleAllDocs;
}
var toggle = createSimpleToggle(false); var toggle = createSimpleToggle(false);
var hideMethodDocs = getCurrentValue("rustdoc-auto-hide-method-docs") === "true"; var hideMethodDocs = getCurrentValue("rustdoc-auto-hide-method-docs") === "true";
var hideImplementors = getCurrentValue("rustdoc-auto-collapse-implementors") !== "false"; var hideImplementors = getCurrentValue("rustdoc-auto-collapse-implementors") !== "false";

View file

@ -1290,7 +1290,7 @@ h4 > .notable-traits {
#theme-choices > button { #theme-choices > button {
border: none; border: none;
width: 100%; width: 100%;
padding: 4px; padding: 4px 8px;
text-align: center; text-align: center;
background: rgba(0,0,0,0); background: rgba(0,0,0,0);
} }

View file

@ -0,0 +1,22 @@
// compile-flags: -O
// min-llvm-version: 11.0
#![crate_type = "lib"]
// CHECK-LABEL: @trim_in_place
#[no_mangle]
pub fn trim_in_place(a: &mut &[u8]) {
while a.first() == Some(&42) {
// CHECK-NOT: slice_index_order_fail
*a = &a[1..];
}
}
// CHECK-LABEL: @trim_in_place2
#[no_mangle]
pub fn trim_in_place2(a: &mut &[u8]) {
while let Some(&42) = a.first() {
// CHECK-NOT: slice_index_order_fail
*a = &a[2..];
}
}

View file

@ -182,7 +182,9 @@ mod same_sized_members_clash {
y: f32, y: f32,
z: f32, z: f32,
} }
extern "C" { fn origin() -> Point3; } extern "C" {
fn origin() -> Point3;
}
} }
mod b { mod b {
#[repr(C)] #[repr(C)]
@ -191,8 +193,9 @@ mod same_sized_members_clash {
y: i32, y: i32,
z: i32, // NOTE: Incorrectly redeclared as i32 z: i32, // NOTE: Incorrectly redeclared as i32
} }
extern "C" { fn origin() -> Point3; } extern "C" {
//~^ WARN `origin` redeclared with a different signature fn origin() -> Point3; //~ WARN `origin` redeclared with a different signature
}
} }
} }
@ -258,6 +261,78 @@ mod non_zero_and_non_null {
} }
} }
// See #75739
mod non_zero_transparent {
mod a1 {
use std::num::NonZeroUsize;
extern "C" {
fn f1() -> NonZeroUsize;
}
}
mod b1 {
#[repr(transparent)]
struct X(NonZeroUsize);
use std::num::NonZeroUsize;
extern "C" {
fn f1() -> X;
}
}
mod a2 {
use std::num::NonZeroUsize;
extern "C" {
fn f2() -> NonZeroUsize;
}
}
mod b2 {
#[repr(transparent)]
struct X1(NonZeroUsize);
#[repr(transparent)]
struct X(X1);
use std::num::NonZeroUsize;
extern "C" {
// Same case as above, but with two layers of newtyping.
fn f2() -> X;
}
}
mod a3 {
#[repr(transparent)]
struct X(core::ptr::NonNull<i32>);
use std::num::NonZeroUsize;
extern "C" {
fn f3() -> X;
}
}
mod b3 {
extern "C" {
fn f3() -> core::ptr::NonNull<i32>;
}
}
mod a4 {
#[repr(transparent)]
enum E {
X(std::num::NonZeroUsize),
}
extern "C" {
fn f4() -> E;
}
}
mod b4 {
extern "C" {
fn f4() -> std::num::NonZeroUsize;
}
}
}
mod null_optimised_enums { mod null_optimised_enums {
mod a { mod a {
extern "C" { extern "C" {

View file

@ -106,19 +106,19 @@ LL | fn draw_point(p: Point);
found `unsafe extern "C" fn(sameish_members::b::Point)` found `unsafe extern "C" fn(sameish_members::b::Point)`
warning: `origin` redeclared with a different signature warning: `origin` redeclared with a different signature
--> $DIR/clashing-extern-fn.rs:194:22 --> $DIR/clashing-extern-fn.rs:197:13
| |
LL | extern "C" { fn origin() -> Point3; } LL | fn origin() -> Point3;
| ---------------------- `origin` previously declared here | ---------------------- `origin` previously declared here
... ...
LL | extern "C" { fn origin() -> Point3; } LL | fn origin() -> Point3;
| ^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | ^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
| |
= note: expected `unsafe extern "C" fn() -> same_sized_members_clash::a::Point3` = note: expected `unsafe extern "C" fn() -> same_sized_members_clash::a::Point3`
found `unsafe extern "C" fn() -> same_sized_members_clash::b::Point3` found `unsafe extern "C" fn() -> same_sized_members_clash::b::Point3`
warning: `transparent_incorrect` redeclared with a different signature warning: `transparent_incorrect` redeclared with a different signature
--> $DIR/clashing-extern-fn.rs:217:13 --> $DIR/clashing-extern-fn.rs:220:13
| |
LL | fn transparent_incorrect() -> T; LL | fn transparent_incorrect() -> T;
| -------------------------------- `transparent_incorrect` previously declared here | -------------------------------- `transparent_incorrect` previously declared here
@ -130,7 +130,7 @@ LL | fn transparent_incorrect() -> isize;
found `unsafe extern "C" fn() -> isize` found `unsafe extern "C" fn() -> isize`
warning: `missing_return_type` redeclared with a different signature warning: `missing_return_type` redeclared with a different signature
--> $DIR/clashing-extern-fn.rs:235:13 --> $DIR/clashing-extern-fn.rs:238:13
| |
LL | fn missing_return_type() -> usize; LL | fn missing_return_type() -> usize;
| ---------------------------------- `missing_return_type` previously declared here | ---------------------------------- `missing_return_type` previously declared here
@ -142,7 +142,7 @@ LL | fn missing_return_type();
found `unsafe extern "C" fn()` found `unsafe extern "C" fn()`
warning: `non_zero_usize` redeclared with a different signature warning: `non_zero_usize` redeclared with a different signature
--> $DIR/clashing-extern-fn.rs:253:13 --> $DIR/clashing-extern-fn.rs:256:13
| |
LL | fn non_zero_usize() -> core::num::NonZeroUsize; LL | fn non_zero_usize() -> core::num::NonZeroUsize;
| ----------------------------------------------- `non_zero_usize` previously declared here | ----------------------------------------------- `non_zero_usize` previously declared here
@ -154,7 +154,7 @@ LL | fn non_zero_usize() -> usize;
found `unsafe extern "C" fn() -> usize` found `unsafe extern "C" fn() -> usize`
warning: `non_null_ptr` redeclared with a different signature warning: `non_null_ptr` redeclared with a different signature
--> $DIR/clashing-extern-fn.rs:255:13 --> $DIR/clashing-extern-fn.rs:258:13
| |
LL | fn non_null_ptr() -> core::ptr::NonNull<usize>; LL | fn non_null_ptr() -> core::ptr::NonNull<usize>;
| ----------------------------------------------- `non_null_ptr` previously declared here | ----------------------------------------------- `non_null_ptr` previously declared here
@ -166,7 +166,7 @@ LL | fn non_null_ptr() -> *const usize;
found `unsafe extern "C" fn() -> *const usize` found `unsafe extern "C" fn() -> *const usize`
warning: `option_non_zero_usize_incorrect` redeclared with a different signature warning: `option_non_zero_usize_incorrect` redeclared with a different signature
--> $DIR/clashing-extern-fn.rs:281:13 --> $DIR/clashing-extern-fn.rs:356:13
| |
LL | fn option_non_zero_usize_incorrect() -> usize; LL | fn option_non_zero_usize_incorrect() -> usize;
| ---------------------------------------------- `option_non_zero_usize_incorrect` previously declared here | ---------------------------------------------- `option_non_zero_usize_incorrect` previously declared here
@ -178,7 +178,7 @@ LL | fn option_non_zero_usize_incorrect() -> isize;
found `unsafe extern "C" fn() -> isize` found `unsafe extern "C" fn() -> isize`
warning: `option_non_null_ptr_incorrect` redeclared with a different signature warning: `option_non_null_ptr_incorrect` redeclared with a different signature
--> $DIR/clashing-extern-fn.rs:283:13 --> $DIR/clashing-extern-fn.rs:358:13
| |
LL | fn option_non_null_ptr_incorrect() -> *const usize; LL | fn option_non_null_ptr_incorrect() -> *const usize;
| --------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here | --------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here