From c159e1764a3dd8ac2214b80f0a2e0e5ebc6da6b0 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Tue, 18 Aug 2020 23:42:38 +0200 Subject: [PATCH 01/44] Use intra-doc links for Ordering::* --- library/core/src/intrinsics.rs | 198 ++++++++++++++++----------------- 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 3a28bc79effaf..0dcf1bd28fb2d 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -72,7 +72,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// @@ -82,7 +82,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// @@ -92,9 +92,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `success` and - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// @@ -104,9 +104,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `success` and - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// @@ -116,7 +116,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// @@ -126,9 +126,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `success` and - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// @@ -138,9 +138,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `success` and - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// @@ -150,9 +150,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `success` and - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// @@ -162,9 +162,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `success` and - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// @@ -175,7 +175,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// @@ -185,7 +185,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// @@ -195,9 +195,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `success` and - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// @@ -207,9 +207,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `success` and - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// @@ -219,7 +219,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// @@ -229,9 +229,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `success` and - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// @@ -241,9 +241,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `success` and - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// @@ -253,9 +253,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `success` and - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// @@ -265,9 +265,9 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `success` and - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// @@ -278,7 +278,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `load` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicBool::load`](../../std/sync/atomic/struct.AtomicBool.html#method.load). pub fn atomic_load(src: *const T) -> T; @@ -286,7 +286,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `load` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicBool::load`](../../std/sync/atomic/struct.AtomicBool.html#method.load). pub fn atomic_load_acq(src: *const T) -> T; @@ -294,7 +294,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `load` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicBool::load`](../../std/sync/atomic/struct.AtomicBool.html#method.load). pub fn atomic_load_relaxed(src: *const T) -> T; @@ -304,7 +304,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `store` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicBool::store`](../../std/sync/atomic/struct.AtomicBool.html#method.store). pub fn atomic_store(dst: *mut T, val: T); @@ -312,7 +312,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `store` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicBool::store`](../../std/sync/atomic/struct.AtomicBool.html#method.store). pub fn atomic_store_rel(dst: *mut T, val: T); @@ -320,7 +320,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `store` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicBool::store`](../../std/sync/atomic/struct.AtomicBool.html#method.store). pub fn atomic_store_relaxed(dst: *mut T, val: T); @@ -330,7 +330,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `swap` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap). pub fn atomic_xchg(dst: *mut T, src: T) -> T; @@ -338,7 +338,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `swap` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap). pub fn atomic_xchg_acq(dst: *mut T, src: T) -> T; @@ -346,7 +346,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `swap` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap). pub fn atomic_xchg_rel(dst: *mut T, src: T) -> T; @@ -354,7 +354,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `swap` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap). pub fn atomic_xchg_acqrel(dst: *mut T, src: T) -> T; @@ -362,7 +362,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `swap` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap). pub fn atomic_xchg_relaxed(dst: *mut T, src: T) -> T; @@ -371,7 +371,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_add` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). pub fn atomic_xadd(dst: *mut T, src: T) -> T; @@ -379,7 +379,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_add` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). pub fn atomic_xadd_acq(dst: *mut T, src: T) -> T; @@ -387,7 +387,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_add` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). pub fn atomic_xadd_rel(dst: *mut T, src: T) -> T; @@ -395,7 +395,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_add` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). pub fn atomic_xadd_acqrel(dst: *mut T, src: T) -> T; @@ -403,7 +403,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_add` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). pub fn atomic_xadd_relaxed(dst: *mut T, src: T) -> T; @@ -412,7 +412,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_sub` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub). pub fn atomic_xsub(dst: *mut T, src: T) -> T; @@ -420,7 +420,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_sub` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub). pub fn atomic_xsub_acq(dst: *mut T, src: T) -> T; @@ -428,7 +428,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_sub` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub). pub fn atomic_xsub_rel(dst: *mut T, src: T) -> T; @@ -436,7 +436,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_sub` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub). pub fn atomic_xsub_acqrel(dst: *mut T, src: T) -> T; @@ -444,7 +444,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_sub` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub). pub fn atomic_xsub_relaxed(dst: *mut T, src: T) -> T; @@ -453,7 +453,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_and` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and). pub fn atomic_and(dst: *mut T, src: T) -> T; @@ -461,7 +461,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_and` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and). pub fn atomic_and_acq(dst: *mut T, src: T) -> T; @@ -469,7 +469,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_and` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and). pub fn atomic_and_rel(dst: *mut T, src: T) -> T; @@ -477,7 +477,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_and` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and). pub fn atomic_and_acqrel(dst: *mut T, src: T) -> T; @@ -485,7 +485,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_and` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and). pub fn atomic_and_relaxed(dst: *mut T, src: T) -> T; @@ -494,7 +494,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand). pub fn atomic_nand(dst: *mut T, src: T) -> T; @@ -502,7 +502,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand). pub fn atomic_nand_acq(dst: *mut T, src: T) -> T; @@ -510,7 +510,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand). pub fn atomic_nand_rel(dst: *mut T, src: T) -> T; @@ -518,7 +518,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand). pub fn atomic_nand_acqrel(dst: *mut T, src: T) -> T; @@ -526,7 +526,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand). pub fn atomic_nand_relaxed(dst: *mut T, src: T) -> T; @@ -535,7 +535,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_or` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or). pub fn atomic_or(dst: *mut T, src: T) -> T; @@ -543,7 +543,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_or` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or). pub fn atomic_or_acq(dst: *mut T, src: T) -> T; @@ -551,7 +551,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_or` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or). pub fn atomic_or_rel(dst: *mut T, src: T) -> T; @@ -559,7 +559,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_or` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or). pub fn atomic_or_acqrel(dst: *mut T, src: T) -> T; @@ -567,7 +567,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_or` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or). pub fn atomic_or_relaxed(dst: *mut T, src: T) -> T; @@ -576,7 +576,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_xor` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor). pub fn atomic_xor(dst: *mut T, src: T) -> T; @@ -584,7 +584,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_xor` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor). pub fn atomic_xor_acq(dst: *mut T, src: T) -> T; @@ -592,7 +592,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_xor` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor). pub fn atomic_xor_rel(dst: *mut T, src: T) -> T; @@ -600,7 +600,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_xor` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor). pub fn atomic_xor_acqrel(dst: *mut T, src: T) -> T; @@ -608,7 +608,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_xor` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor). pub fn atomic_xor_relaxed(dst: *mut T, src: T) -> T; @@ -617,7 +617,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max). pub fn atomic_max(dst: *mut T, src: T) -> T; @@ -625,7 +625,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max). pub fn atomic_max_acq(dst: *mut T, src: T) -> T; @@ -633,7 +633,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max). pub fn atomic_max_rel(dst: *mut T, src: T) -> T; @@ -641,7 +641,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max). pub fn atomic_max_acqrel(dst: *mut T, src: T) -> T; @@ -649,7 +649,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html#variant.Relaxed) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max). pub fn atomic_max_relaxed(dst: *mut T, src: T) -> T; @@ -658,7 +658,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min). pub fn atomic_min(dst: *mut T, src: T) -> T; @@ -666,7 +666,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min). pub fn atomic_min_acq(dst: *mut T, src: T) -> T; @@ -674,7 +674,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min). pub fn atomic_min_rel(dst: *mut T, src: T) -> T; @@ -682,7 +682,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min). pub fn atomic_min_acqrel(dst: *mut T, src: T) -> T; @@ -690,7 +690,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html#variant.Relaxed) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min). pub fn atomic_min_relaxed(dst: *mut T, src: T) -> T; @@ -699,7 +699,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min). pub fn atomic_umin(dst: *mut T, src: T) -> T; @@ -707,7 +707,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min). pub fn atomic_umin_acq(dst: *mut T, src: T) -> T; @@ -715,7 +715,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min). pub fn atomic_umin_rel(dst: *mut T, src: T) -> T; @@ -723,7 +723,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min). pub fn atomic_umin_acqrel(dst: *mut T, src: T) -> T; @@ -731,7 +731,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html#variant.Relaxed) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min). pub fn atomic_umin_relaxed(dst: *mut T, src: T) -> T; @@ -740,7 +740,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max). pub fn atomic_umax(dst: *mut T, src: T) -> T; @@ -748,7 +748,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max). pub fn atomic_umax_acq(dst: *mut T, src: T) -> T; @@ -756,7 +756,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max). pub fn atomic_umax_rel(dst: *mut T, src: T) -> T; @@ -764,7 +764,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max). pub fn atomic_umax_acqrel(dst: *mut T, src: T) -> T; @@ -772,7 +772,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing - /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html#variant.Relaxed) + /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max). pub fn atomic_umax_relaxed(dst: *mut T, src: T) -> T; @@ -825,7 +825,7 @@ extern "rust-intrinsic" { /// The stabilized version of this intrinsic is available in /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html) /// by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. pub fn atomic_fence(); /// An atomic fence. @@ -833,7 +833,7 @@ extern "rust-intrinsic" { /// The stabilized version of this intrinsic is available in /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html) /// by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. pub fn atomic_fence_acq(); /// An atomic fence. @@ -841,7 +841,7 @@ extern "rust-intrinsic" { /// The stabilized version of this intrinsic is available in /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html) /// by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. pub fn atomic_fence_rel(); /// An atomic fence. @@ -849,7 +849,7 @@ extern "rust-intrinsic" { /// The stabilized version of this intrinsic is available in /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html) /// by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. pub fn atomic_fence_acqrel(); @@ -863,7 +863,7 @@ extern "rust-intrinsic" { /// The stabilized version of this intrinsic is available in /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html) /// by passing - /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst) + /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. pub fn atomic_singlethreadfence(); /// A compiler-only memory barrier. @@ -876,7 +876,7 @@ extern "rust-intrinsic" { /// The stabilized version of this intrinsic is available in /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html) /// by passing - /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire) + /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. pub fn atomic_singlethreadfence_acq(); /// A compiler-only memory barrier. @@ -889,7 +889,7 @@ extern "rust-intrinsic" { /// The stabilized version of this intrinsic is available in /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html) /// by passing - /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release) + /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. pub fn atomic_singlethreadfence_rel(); /// A compiler-only memory barrier. @@ -902,7 +902,7 @@ extern "rust-intrinsic" { /// The stabilized version of this intrinsic is available in /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html) /// by passing - /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel) + /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. pub fn atomic_singlethreadfence_acqrel(); From 69e5a4ccaa37b9d4c666133122f5ef4e2d0046e5 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 00:05:49 +0200 Subject: [PATCH 02/44] Use intra-doc links for AtomicBool::* --- library/core/src/intrinsics.rs | 62 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 0dcf1bd28fb2d..07169692f8f45 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -280,7 +280,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `load` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicBool::load`](../../std/sync/atomic/struct.AtomicBool.html#method.load). + /// [`AtomicBool::load`](crate::sync::atomic::AtomicBool::load). pub fn atomic_load(src: *const T) -> T; /// Loads the current value of the pointer. /// @@ -288,7 +288,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `load` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicBool::load`](../../std/sync/atomic/struct.AtomicBool.html#method.load). + /// [`AtomicBool::load`](crate::sync::atomic::AtomicBool::load). pub fn atomic_load_acq(src: *const T) -> T; /// Loads the current value of the pointer. /// @@ -296,7 +296,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `load` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicBool::load`](../../std/sync/atomic/struct.AtomicBool.html#method.load). + /// [`AtomicBool::load`](crate::sync::atomic::AtomicBool::load). pub fn atomic_load_relaxed(src: *const T) -> T; pub fn atomic_load_unordered(src: *const T) -> T; @@ -306,7 +306,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `store` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicBool::store`](../../std/sync/atomic/struct.AtomicBool.html#method.store). + /// [`AtomicBool::store`](crate::sync::atomic::AtomicBool::store). pub fn atomic_store(dst: *mut T, val: T); /// Stores the value at the specified memory location. /// @@ -314,7 +314,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `store` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicBool::store`](../../std/sync/atomic/struct.AtomicBool.html#method.store). + /// [`AtomicBool::store`](crate::sync::atomic::AtomicBool::store). pub fn atomic_store_rel(dst: *mut T, val: T); /// Stores the value at the specified memory location. /// @@ -322,7 +322,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `store` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicBool::store`](../../std/sync/atomic/struct.AtomicBool.html#method.store). + /// [`AtomicBool::store`](crate::sync::atomic::AtomicBool::store). pub fn atomic_store_relaxed(dst: *mut T, val: T); pub fn atomic_store_unordered(dst: *mut T, val: T); @@ -332,7 +332,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `swap` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap). + /// [`AtomicBool::swap`](crate::sync::atomic::AtomicBool::swap). pub fn atomic_xchg(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// @@ -340,7 +340,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `swap` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap). + /// [`AtomicBool::swap`](crate::sync::atomic::AtomicBool::swap). pub fn atomic_xchg_acq(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// @@ -348,7 +348,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `swap` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap). + /// [`AtomicBool::swap`](crate::sync::atomic::AtomicBool::swap). pub fn atomic_xchg_rel(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// @@ -356,7 +356,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `swap` method by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, - /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap). + /// [`AtomicBool::swap`](crate::sync::atomic::AtomicBool::swap). pub fn atomic_xchg_acqrel(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// @@ -364,7 +364,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `swap` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap). + /// [`AtomicBool::swap`](crate::sync::atomic::AtomicBool::swap). pub fn atomic_xchg_relaxed(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. @@ -455,7 +455,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_and` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and). + /// [`AtomicBool::fetch_and`](crate::sync::atomic::AtomicBool::fetch_and). pub fn atomic_and(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// @@ -463,7 +463,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_and` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and). + /// [`AtomicBool::fetch_and`](crate::sync::atomic::AtomicBool::fetch_and). pub fn atomic_and_acq(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// @@ -471,7 +471,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_and` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and). + /// [`AtomicBool::fetch_and`](crate::sync::atomic::AtomicBool::fetch_and). pub fn atomic_and_rel(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// @@ -479,7 +479,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_and` method by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, - /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and). + /// [`AtomicBool::fetch_and`](crate::sync::atomic::AtomicBool::fetch_and). pub fn atomic_and_acqrel(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// @@ -487,7 +487,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_and` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and). + /// [`AtomicBool::fetch_and`](crate::sync::atomic::AtomicBool::fetch_and). pub fn atomic_and_relaxed(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. @@ -496,7 +496,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand). + /// [`AtomicBool::fetch_nand`](crate::sync::atomic::AtomicBool::fetch_nand). pub fn atomic_nand(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// @@ -504,7 +504,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand). + /// [`AtomicBool::fetch_nand`](crate::sync::atomic::AtomicBool::fetch_nand). pub fn atomic_nand_acq(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// @@ -512,7 +512,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand). + /// [`AtomicBool::fetch_nand`](crate::sync::atomic::AtomicBool::fetch_nand). pub fn atomic_nand_rel(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// @@ -520,7 +520,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, - /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand). + /// [`AtomicBool::fetch_nand`](crate::sync::atomic::AtomicBool::fetch_nand). pub fn atomic_nand_acqrel(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// @@ -528,7 +528,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand). + /// [`AtomicBool::fetch_nand`](crate::sync::atomic::AtomicBool::fetch_nand). pub fn atomic_nand_relaxed(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. @@ -537,7 +537,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_or` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or). + /// [`AtomicBool::fetch_or`](crate::sync::atomic::AtomicBool::fetch_or). pub fn atomic_or(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// @@ -545,7 +545,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_or` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or). + /// [`AtomicBool::fetch_or`](crate::sync::atomic::AtomicBool::fetch_or). pub fn atomic_or_acq(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// @@ -553,7 +553,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_or` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or). + /// [`AtomicBool::fetch_or`](crate::sync::atomic::AtomicBool::fetch_or). pub fn atomic_or_rel(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// @@ -561,7 +561,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_or` method by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, - /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or). + /// [`AtomicBool::fetch_or`](crate::sync::atomic::AtomicBool::fetch_or). pub fn atomic_or_acqrel(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// @@ -569,7 +569,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_or` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or). + /// [`AtomicBool::fetch_or`](crate::sync::atomic::AtomicBool::fetch_or). pub fn atomic_or_relaxed(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. @@ -578,7 +578,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_xor` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor). + /// [`AtomicBool::fetch_xor`](crate::sync::atomic::AtomicBool::fetch_xor). pub fn atomic_xor(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// @@ -586,7 +586,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_xor` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor). + /// [`AtomicBool::fetch_xor`](crate::sync::atomic::AtomicBool::fetch_xor). pub fn atomic_xor_acq(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// @@ -594,7 +594,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_xor` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor). + /// [`AtomicBool::fetch_xor`](crate::sync::atomic::AtomicBool::fetch_xor). pub fn atomic_xor_rel(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// @@ -602,7 +602,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_xor` method by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, - /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor). + /// [`AtomicBool::fetch_xor`](crate::sync::atomic::AtomicBool::fetch_xor). pub fn atomic_xor_acqrel(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// @@ -610,7 +610,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_xor` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor). + /// [`AtomicBool::fetch_xor`](crate::sync::atomic::AtomicBool::fetch_xor). pub fn atomic_xor_relaxed(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. From 076ae25714b3e045742b4b3d6ec14ea894fb210d Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 00:10:57 +0200 Subject: [PATCH 03/44] Use intra-doc links for AtomicIsize::* --- library/core/src/intrinsics.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 07169692f8f45..fe10c1aec0ad9 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -373,7 +373,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_add` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). + /// [`AtomicIsize::fetch_add`](crate::sync::atomic::AtomicIsize::fetch_add). pub fn atomic_xadd(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// @@ -381,7 +381,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_add` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). + /// [`AtomicIsize::fetch_add`](crate::sync::atomic::AtomicIsize::fetch_add). pub fn atomic_xadd_acq(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// @@ -389,7 +389,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_add` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). + /// [`AtomicIsize::fetch_add`](crate::sync::atomic::AtomicIsize::fetch_add). pub fn atomic_xadd_rel(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// @@ -397,7 +397,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_add` method by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, - /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). + /// [`AtomicIsize::fetch_add`](crate::sync::atomic::AtomicIsize::fetch_add). pub fn atomic_xadd_acqrel(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// @@ -405,7 +405,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_add` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). + /// [`AtomicIsize::fetch_add`](crate::sync::atomic::AtomicIsize::fetch_add). pub fn atomic_xadd_relaxed(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. @@ -414,7 +414,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_sub` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub). + /// [`AtomicIsize::fetch_sub`](crate::sync::atomic::AtomicIsize::fetch_sub). pub fn atomic_xsub(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// @@ -422,7 +422,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_sub` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub). + /// [`AtomicIsize::fetch_sub`](crate::sync::atomic::AtomicIsize::fetch_sub). pub fn atomic_xsub_acq(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// @@ -430,7 +430,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_sub` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub). + /// [`AtomicIsize::fetch_sub`](crate::sync::atomic::AtomicIsize::fetch_sub). pub fn atomic_xsub_rel(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// @@ -438,7 +438,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_sub` method by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, - /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub). + /// [`AtomicIsize::fetch_sub`](crate::sync::atomic::AtomicIsize::fetch_sub). pub fn atomic_xsub_acqrel(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// @@ -446,7 +446,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` types via the `fetch_sub` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub). + /// [`AtomicIsize::fetch_sub`](crate::sync::atomic::AtomicIsize::fetch_sub). pub fn atomic_xsub_relaxed(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. From 2373dbce83ac1594ad61519d1bc5310cfde908af Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 09:52:19 +0200 Subject: [PATCH 04/44] Use intra-doc links for AtomicI32::* --- library/core/src/intrinsics.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index fe10c1aec0ad9..909d8c11b7337 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -619,7 +619,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max). + /// [`AtomicI32::fetch_max`](crate::sync::atomic::AtomicI32::fetch_max). pub fn atomic_max(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. /// @@ -627,7 +627,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max). + /// [`AtomicI32::fetch_max`](crate::sync::atomic::AtomicI32::fetch_max). pub fn atomic_max_acq(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. /// @@ -635,7 +635,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max). + /// [`AtomicI32::fetch_max`](crate::sync::atomic::AtomicI32::fetch_max). pub fn atomic_max_rel(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. /// @@ -643,7 +643,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, - /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max). + /// [`AtomicI32::fetch_max`](crate::sync::atomic::AtomicI32::fetch_max). pub fn atomic_max_acqrel(dst: *mut T, src: T) -> T; /// Maximum with the current value. /// @@ -651,7 +651,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max). + /// [`AtomicI32::fetch_max`](crate::sync::atomic::AtomicI32::fetch_max). pub fn atomic_max_relaxed(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. @@ -660,7 +660,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min). + /// [`AtomicI32::fetch_min`](crate::sync::atomic::AtomicI32::fetch_min). pub fn atomic_min(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// @@ -668,7 +668,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min). + /// [`AtomicI32::fetch_min`](crate::sync::atomic::AtomicI32::fetch_min). pub fn atomic_min_acq(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// @@ -676,7 +676,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min). + /// [`AtomicI32::fetch_min`](crate::sync::atomic::AtomicI32::fetch_min). pub fn atomic_min_rel(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// @@ -684,7 +684,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, - /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min). + /// [`AtomicI32::fetch_min`](crate::sync::atomic::AtomicI32::fetch_min). pub fn atomic_min_acqrel(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// @@ -692,7 +692,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min). + /// [`AtomicI32::fetch_min`](crate::sync::atomic::AtomicI32::fetch_min). pub fn atomic_min_relaxed(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. From 7b5ec9e9e05c2bc0a4b9a81138801450d0585a3f Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 09:58:41 +0200 Subject: [PATCH 05/44] Use intra-doc links for AtomicU32::* --- library/core/src/intrinsics.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 909d8c11b7337..e030178b35ab7 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -701,7 +701,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min). + /// [`AtomicU32::fetch_min`](crate::sync::atomic::AtomicU32::fetch_min). pub fn atomic_umin(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// @@ -709,7 +709,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min). + /// [`AtomicU32::fetch_min`](crate::sync::atomic::AtomicU32::fetch_min). pub fn atomic_umin_acq(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// @@ -717,7 +717,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min). + /// [`AtomicU32::fetch_min`](crate::sync::atomic::AtomicU32::fetch_min). pub fn atomic_umin_rel(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// @@ -725,7 +725,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, - /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min). + /// [`AtomicU32::fetch_min`](crate::sync::atomic::AtomicU32::fetch_min). pub fn atomic_umin_acqrel(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// @@ -733,7 +733,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min). + /// [`AtomicU32::fetch_min`](crate::sync::atomic::AtomicU32::fetch_min). pub fn atomic_umin_relaxed(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. @@ -742,7 +742,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. For example, - /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max). + /// [`AtomicU32::fetch_max`](crate::sync::atomic::AtomicU32::fetch_max). pub fn atomic_umax(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// @@ -750,7 +750,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. For example, - /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max). + /// [`AtomicU32::fetch_max`](crate::sync::atomic::AtomicU32::fetch_max). pub fn atomic_umax_acq(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// @@ -758,7 +758,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. For example, - /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max). + /// [`AtomicU32::fetch_max`](crate::sync::atomic::AtomicU32::fetch_max). pub fn atomic_umax_rel(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// @@ -766,7 +766,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. For example, - /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max). + /// [`AtomicU32::fetch_max`](crate::sync::atomic::AtomicU32::fetch_max). pub fn atomic_umax_acqrel(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// @@ -774,7 +774,7 @@ extern "rust-intrinsic" { /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) /// as the `order`. For example, - /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max). + /// [`AtomicU32::fetch_max`](crate::sync::atomic::AtomicU32::fetch_max). pub fn atomic_umax_relaxed(dst: *mut T, src: T) -> T; /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction From a9297384783e12de389c8438d106a91b465a0606 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 10:19:06 +0200 Subject: [PATCH 06/44] Use intra-doc links for u32::* --- library/core/src/intrinsics.rs | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index e030178b35ab7..d23e4a6ce9494 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -1656,7 +1656,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `count_ones` method. For example, - /// [`std::u32::count_ones`](../../std/primitive.u32.html#method.count_ones) + /// [`std::u32::count_ones`](u32::count_ones) #[rustc_const_stable(feature = "const_ctpop", since = "1.40.0")] pub fn ctpop(x: T) -> T; @@ -1664,7 +1664,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `leading_zeros` method. For example, - /// [`std::u32::leading_zeros`](../../std/primitive.u32.html#method.leading_zeros) + /// [`std::u32::leading_zeros`](u32::leading_zeros) /// /// # Examples /// @@ -1715,7 +1715,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `trailing_zeros` method. For example, - /// [`std::u32::trailing_zeros`](../../std/primitive.u32.html#method.trailing_zeros) + /// [`std::u32::trailing_zeros`](u32::trailing_zeros) /// /// # Examples /// @@ -1766,7 +1766,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `swap_bytes` method. For example, - /// [`std::u32::swap_bytes`](../../std/primitive.u32.html#method.swap_bytes) + /// [`std::u32::swap_bytes`](u32::swap_bytes) #[rustc_const_stable(feature = "const_bswap", since = "1.40.0")] pub fn bswap(x: T) -> T; @@ -1774,7 +1774,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `reverse_bits` method. For example, - /// [`std::u32::reverse_bits`](../../std/primitive.u32.html#method.reverse_bits) + /// [`std::u32::reverse_bits`](u32::reverse_bits) #[rustc_const_stable(feature = "const_bitreverse", since = "1.40.0")] pub fn bitreverse(x: T) -> T; @@ -1782,7 +1782,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `overflowing_add` method. For example, - /// [`std::u32::overflowing_add`](../../std/primitive.u32.html#method.overflowing_add) + /// [`std::u32::overflowing_add`](u32::overflowing_add) #[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")] pub fn add_with_overflow(x: T, y: T) -> (T, bool); @@ -1790,7 +1790,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `overflowing_sub` method. For example, - /// [`std::u32::overflowing_sub`](../../std/primitive.u32.html#method.overflowing_sub) + /// [`std::u32::overflowing_sub`](u32::overflowing_sub) #[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")] pub fn sub_with_overflow(x: T, y: T) -> (T, bool); @@ -1798,7 +1798,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `overflowing_mul` method. For example, - /// [`std::u32::overflowing_mul`](../../std/primitive.u32.html#method.overflowing_mul) + /// [`std::u32::overflowing_mul`](u32::overflowing_mul) #[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")] pub fn mul_with_overflow(x: T, y: T) -> (T, bool); @@ -1813,7 +1813,7 @@ extern "rust-intrinsic" { /// /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_div` method. For example, - /// [`std::u32::checked_div`](../../std/primitive.u32.html#method.checked_div) + /// [`std::u32::checked_div`](u32::checked_div) #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")] pub fn unchecked_div(x: T, y: T) -> T; /// Returns the remainder of an unchecked division, resulting in @@ -1821,7 +1821,7 @@ extern "rust-intrinsic" { /// /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_rem` method. For example, - /// [`std::u32::checked_rem`](../../std/primitive.u32.html#method.checked_rem) + /// [`std::u32::checked_rem`](u32::checked_rem) #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")] pub fn unchecked_rem(x: T, y: T) -> T; @@ -1830,7 +1830,7 @@ extern "rust-intrinsic" { /// /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_shl` method. For example, - /// [`std::u32::checked_shl`](../../std/primitive.u32.html#method.checked_shl) + /// [`std::u32::checked_shl`](u32::checked_shl) #[rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0")] pub fn unchecked_shl(x: T, y: T) -> T; /// Performs an unchecked right shift, resulting in undefined behavior when @@ -1838,7 +1838,7 @@ extern "rust-intrinsic" { /// /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_shr` method. For example, - /// [`std::u32::checked_shr`](../../std/primitive.u32.html#method.checked_shr) + /// [`std::u32::checked_shr`](u32::checked_shr) #[rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0")] pub fn unchecked_shr(x: T, y: T) -> T; @@ -1867,7 +1867,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `rotate_left` method. For example, - /// [`std::u32::rotate_left`](../../std/primitive.u32.html#method.rotate_left) + /// [`std::u32::rotate_left`](u32::rotate_left) #[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")] pub fn rotate_left(x: T, y: T) -> T; @@ -1875,7 +1875,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `rotate_right` method. For example, - /// [`std::u32::rotate_right`](../../std/primitive.u32.html#method.rotate_right) + /// [`std::u32::rotate_right`](u32::rotate_right) #[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")] pub fn rotate_right(x: T, y: T) -> T; @@ -1883,21 +1883,21 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `checked_add` method. For example, - /// [`std::u32::checked_add`](../../std/primitive.u32.html#method.checked_add) + /// [`std::u32::checked_add`](u32::checked_add) #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")] pub fn wrapping_add(a: T, b: T) -> T; /// Returns (a - b) mod 2N, where N is the width of T in bits. /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `checked_sub` method. For example, - /// [`std::u32::checked_sub`](../../std/primitive.u32.html#method.checked_sub) + /// [`std::u32::checked_sub`](u32::checked_sub) #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")] pub fn wrapping_sub(a: T, b: T) -> T; /// Returns (a * b) mod 2N, where N is the width of T in bits. /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `checked_mul` method. For example, - /// [`std::u32::checked_mul`](../../std/primitive.u32.html#method.checked_mul) + /// [`std::u32::checked_mul`](u32::checked_mul) #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")] pub fn wrapping_mul(a: T, b: T) -> T; @@ -1905,14 +1905,14 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `saturating_add` method. For example, - /// [`std::u32::saturating_add`](../../std/primitive.u32.html#method.saturating_add) + /// [`std::u32::saturating_add`](u32::saturating_add) #[rustc_const_stable(feature = "const_int_saturating", since = "1.40.0")] pub fn saturating_add(a: T, b: T) -> T; /// Computes `a - b`, while saturating at numeric bounds. /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `saturating_sub` method. For example, - /// [`std::u32::saturating_sub`](../../std/primitive.u32.html#method.saturating_sub) + /// [`std::u32::saturating_sub`](u32::saturating_sub) #[rustc_const_stable(feature = "const_int_saturating", since = "1.40.0")] pub fn saturating_sub(a: T, b: T) -> T; From fb7d9170f4acdbaeb473198bebfc0c19aa60e9d4 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 12:04:23 +0200 Subject: [PATCH 07/44] Use intra-doc links for f32::* and f64::* --- library/core/src/intrinsics.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index d23e4a6ce9494..8747d3c84f75f 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -1526,22 +1526,22 @@ extern "rust-intrinsic" { /// Returns the minimum of two `f32` values. /// /// The stabilized version of this intrinsic is - /// [`std::f32::min`](../../std/primitive.f32.html#method.min) + /// [`std::f32::min`](f32::min) pub fn minnumf32(x: f32, y: f32) -> f32; /// Returns the minimum of two `f64` values. /// /// The stabilized version of this intrinsic is - /// [`std::f64::min`](../../std/primitive.f64.html#method.min) + /// [`std::f64::min`](f64::min) pub fn minnumf64(x: f64, y: f64) -> f64; /// Returns the maximum of two `f32` values. /// /// The stabilized version of this intrinsic is - /// [`std::f32::max`](../../std/primitive.f32.html#method.max) + /// [`std::f32::max`](f32::max) pub fn maxnumf32(x: f32, y: f32) -> f32; /// Returns the maximum of two `f64` values. /// /// The stabilized version of this intrinsic is - /// [`std::f64::max`](../../std/primitive.f64.html#method.max) + /// [`std::f64::max`](f64::max) pub fn maxnumf64(x: f64, y: f64) -> f64; /// Copies the sign from `y` to `x` for `f32` values. From 45b4e1470c62452779d843b78988f4c9cc195268 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 12:16:16 +0200 Subject: [PATCH 08/44] Use intra-doc links for sync::* --- library/core/src/intrinsics.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 8747d3c84f75f..1e5ab83690c88 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -823,7 +823,7 @@ extern "rust-intrinsic" { /// An atomic fence. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html) + /// [`std::sync::atomic::fence`](crate::sync::atomic::fence) /// by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. @@ -831,7 +831,7 @@ extern "rust-intrinsic" { /// An atomic fence. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html) + /// [`std::sync::atomic::fence`](crate::sync::atomic::fence) /// by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. @@ -839,7 +839,7 @@ extern "rust-intrinsic" { /// An atomic fence. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html) + /// [`std::sync::atomic::fence`](crate::sync::atomic::fence) /// by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. @@ -847,7 +847,7 @@ extern "rust-intrinsic" { /// An atomic fence. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html) + /// [`std::sync::atomic::fence`](crate::sync::atomic::fence) /// by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. @@ -861,7 +861,7 @@ extern "rust-intrinsic" { /// such as when interacting with signal handlers. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html) + /// [`std::sync::atomic::compiler_fence`](crate::sync::atomic::compiler_fence) /// by passing /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) /// as the `order`. @@ -874,7 +874,7 @@ extern "rust-intrinsic" { /// such as when interacting with signal handlers. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html) + /// [`std::sync::atomic::compiler_fence`](crate::sync::atomic::compiler_fence) /// by passing /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) /// as the `order`. @@ -887,7 +887,7 @@ extern "rust-intrinsic" { /// such as when interacting with signal handlers. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html) + /// [`std::sync::atomic::compiler_fence`](crate::sync::atomic::compiler_fence) /// by passing /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) /// as the `order`. @@ -900,7 +900,7 @@ extern "rust-intrinsic" { /// such as when interacting with signal handlers. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html) + /// [`std::sync::atomic::compiler_fence`](crate::sync::atomic::compiler_fence) /// by passing /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) /// as the `order`. From 2c7998720c3493573598c6b625141a29ea15c7ef Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 12:38:32 +0200 Subject: [PATCH 09/44] Use intra-doc links for mem::* --- library/core/src/intrinsics.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 1e5ab83690c88..c3658c044f206 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -976,7 +976,7 @@ extern "rust-intrinsic" { /// items of the same type, including alignment padding. /// /// The stabilized version of this intrinsic is - /// [`std::mem::size_of`](../../std/mem/fn.size_of.html). + /// [`std::mem::size_of`](crate::mem::size_of). #[rustc_const_stable(feature = "const_size_of", since = "1.40.0")] pub fn size_of() -> usize; @@ -991,7 +991,7 @@ extern "rust-intrinsic" { /// The minimum alignment of a type. /// /// The stabilized version of this intrinsic is - /// [`std::mem::align_of`](../../std/mem/fn.align_of.html). + /// [`std::mem::align_of`](crate::mem::align_of). #[rustc_const_stable(feature = "const_min_align_of", since = "1.40.0")] pub fn min_align_of() -> usize; /// The preferred alignment of a type. @@ -1003,13 +1003,13 @@ extern "rust-intrinsic" { /// The size of the referenced value in bytes. /// /// The stabilized version of this intrinsic is - /// [`std::mem::size_of_val`](../../std/mem/fn.size_of_val.html). + /// [`std::mem::size_of_val`](crate::mem::size_of_val). #[rustc_const_unstable(feature = "const_size_of_val", issue = "46571")] pub fn size_of_val(_: *const T) -> usize; /// The required alignment of the referenced value. /// /// The stabilized version of this intrinsic is - /// [`std::mem::align_of_val`](../../std/mem/fn.align_of_val.html). + /// [`std::mem::align_of_val`](crate::mem::align_of_val). #[rustc_const_unstable(feature = "const_align_of_val", issue = "46571")] pub fn min_align_of_val(_: *const T) -> usize; @@ -1301,7 +1301,7 @@ extern "rust-intrinsic" { /// `Copy`, then the return value of this function is unspecified. /// /// The stabilized version of this intrinsic is - /// [`std::mem::needs_drop`](../../std/mem/fn.needs_drop.html). + /// [`std::mem::needs_drop`](crate::mem::needs_drop). #[rustc_const_stable(feature = "const_needs_drop", since = "1.40.0")] pub fn needs_drop() -> bool; @@ -1920,7 +1920,7 @@ extern "rust-intrinsic" { /// cast to a `u64`; if `T` has no discriminant, returns 0. /// /// The stabilized version of this intrinsic is - /// [`std::mem::discriminant`](../../std/mem/fn.discriminant.html) + /// [`std::mem::discriminant`](crate::mem::discriminant) #[rustc_const_unstable(feature = "const_discriminant", issue = "69821")] pub fn discriminant_value(v: &T) -> ::Discriminant; @@ -1928,7 +1928,7 @@ extern "rust-intrinsic" { /// if `T` has no variants, returns 0. Uninhabited variants will be counted. /// /// The to-be-stabilized version of this intrinsic is - /// [`std::mem::variant_count`](../../std/mem/fn.variant_count.html) + /// [`std::mem::variant_count`](crate::mem::variant_count) #[rustc_const_unstable(feature = "variant_count", issue = "73662")] pub fn variant_count() -> usize; From d339cfe4a120cfcd6db33e8c57efd040e5764738 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 13:38:22 +0200 Subject: [PATCH 10/44] Use intra-doc links for ptr::* --- library/core/src/intrinsics.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index c3658c044f206..ae104500106bf 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -985,7 +985,7 @@ extern "rust-intrinsic" { /// Drop glue is not run on the destination. /// /// The stabilized version of this intrinsic is - /// [`std::ptr::write`](../../std/ptr/fn.write.html). + /// [`std::ptr::write`](crate::ptr::write). pub fn move_val_init(dst: *mut T, src: T); /// The minimum alignment of a type. @@ -1372,12 +1372,12 @@ extern "rust-intrinsic" { /// Performs a volatile load from the `src` pointer. /// /// The stabilized version of this intrinsic is - /// [`std::ptr::read_volatile`](../../std/ptr/fn.read_volatile.html). + /// [`std::ptr::read_volatile`](crate::ptr::read_volatile). pub fn volatile_load(src: *const T) -> T; /// Performs a volatile store to the `dst` pointer. /// /// The stabilized version of this intrinsic is - /// [`std::ptr::write_volatile`](../../std/ptr/fn.write_volatile.html). + /// [`std::ptr::write_volatile`](crate::ptr::write_volatile). pub fn volatile_store(dst: *mut T, val: T); /// Performs a volatile load from the `src` pointer From 751e343ab2714bbbc4e2622d650f65466b98d676 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 14:13:53 +0200 Subject: [PATCH 11/44] Use intra-doc linkks --- library/core/src/intrinsics.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index ae104500106bf..3f7cd96ab4807 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -931,7 +931,7 @@ extern "rust-intrinsic" { /// reach code marked with this function. /// /// The stabilized version of this intrinsic is - /// [`std::hint::unreachable_unchecked`](../../std/hint/fn.unreachable_unchecked.html). + /// [`std::hint::unreachable_unchecked`](crate::hint::unreachable_unchecked). #[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")] pub fn unreachable() -> !; @@ -1016,7 +1016,7 @@ extern "rust-intrinsic" { /// Gets a static string slice containing the name of a type. /// /// The stabilized version of this intrinsic is - /// [`std::any::type_name`](../../std/any/fn.type_name.html) + /// [`std::any::type_name`](crate::any::type_name) #[rustc_const_unstable(feature = "const_type_name", issue = "63084")] pub fn type_name() -> &'static str; @@ -1025,7 +1025,7 @@ extern "rust-intrinsic" { /// crate it is invoked in. /// /// The stabilized version of this intrinsic is - /// [`std::any::TypeId::of`](../../std/any/struct.TypeId.html#method.of) + /// [`std::any::TypeId::of`](crate::any::TypeId::of) #[rustc_const_stable(feature = "const_type_id", since = "1.46.0")] pub fn type_id() -> u64; @@ -1049,7 +1049,7 @@ extern "rust-intrinsic" { /// Gets a reference to a static `Location` indicating where it was called. /// - /// Consider using [`std::panic::Location::caller`](../../std/panic/struct.Location.html#method.caller) + /// Consider using [`std::panic::Location::caller`](crate::panic::Location::caller) /// instead. #[rustc_const_unstable(feature = "const_caller_location", issue = "47809")] pub fn caller_location() -> &'static crate::panic::Location<'static>; @@ -2053,7 +2053,6 @@ pub(crate) fn is_nonoverlapping(src: *const T, dst: *const T, count: usize) - /// `copy_nonoverlapping` is semantically equivalent to C's [`memcpy`], but /// with the argument order swapped. /// -/// [`copy`]: ./fn.copy.html /// [`memcpy`]: https://en.cppreference.com/w/c/string/byte/memcpy /// /// # Safety @@ -2078,8 +2077,8 @@ pub(crate) fn is_nonoverlapping(src: *const T, dst: *const T, count: usize) - /// Note that even if the effectively copied size (`count * size_of::()`) is /// `0`, the pointers must be non-NULL and properly aligned. /// -/// [`Copy`]: ../marker/trait.Copy.html -/// [`read`]: ../ptr/fn.read.html +/// [`Copy`]: crate::marker::Copy +/// [`read`]: crate::ptr::read /// [read-ownership]: ../ptr/fn.read.html#ownership-of-the-returned-value /// [valid]: ../ptr/index.html#safety /// @@ -2160,7 +2159,6 @@ pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { /// order swapped. Copying takes place as if the bytes were copied from `src` /// to a temporary array and then copied from the array to `dst`. /// -/// [`copy_nonoverlapping`]: ./fn.copy_nonoverlapping.html /// [`memmove`]: https://en.cppreference.com/w/c/string/byte/memmove /// /// # Safety @@ -2181,8 +2179,8 @@ pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { /// Note that even if the effectively copied size (`count * size_of::()`) is /// `0`, the pointers must be non-NULL and properly aligned. /// -/// [`Copy`]: ../marker/trait.Copy.html -/// [`read`]: ../ptr/fn.read.html +/// [`Copy`]: crate::marker::Copy +/// [`read`]: crate::ptr::read /// [read-ownership]: ../ptr/fn.read.html#ownership-of-the-returned-value /// [valid]: ../ptr/index.html#safety /// From d1838f6c73b97f7aab716946b7cd671fde607585 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 15:12:28 +0200 Subject: [PATCH 12/44] Use intra-doc links for compare_exchange and compare_exchange_weak --- library/core/src/intrinsics.rs | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 3f7cd96ab4807..469dd0cbdd886 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -76,7 +76,7 @@ extern "rust-intrinsic" { /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// - /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange + /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange pub fn atomic_cxchg(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -86,7 +86,7 @@ extern "rust-intrinsic" { /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// - /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange + /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange pub fn atomic_cxchg_acq(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -98,7 +98,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// - /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange + /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange pub fn atomic_cxchg_rel(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -110,7 +110,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// - /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange + /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange pub fn atomic_cxchg_acqrel(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -120,7 +120,7 @@ extern "rust-intrinsic" { /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// - /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange + /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange pub fn atomic_cxchg_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -132,7 +132,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// - /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange + /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange pub fn atomic_cxchg_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -144,7 +144,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// - /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange + /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange pub fn atomic_cxchg_failacq(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -156,7 +156,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// - /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange + /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange pub fn atomic_cxchg_acq_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -168,7 +168,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange`][compare_exchange]. /// - /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange + /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange pub fn atomic_cxchg_acqrel_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. @@ -179,7 +179,7 @@ extern "rust-intrinsic" { /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// - /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak + /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak pub fn atomic_cxchgweak(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -189,7 +189,7 @@ extern "rust-intrinsic" { /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// - /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak + /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak pub fn atomic_cxchgweak_acq(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -201,7 +201,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// - /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak + /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak pub fn atomic_cxchgweak_rel(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -213,7 +213,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// - /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak + /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak pub fn atomic_cxchgweak_acqrel(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -223,7 +223,7 @@ extern "rust-intrinsic" { /// as both the `success` and `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// - /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak + /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak pub fn atomic_cxchgweak_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -235,7 +235,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// - /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak + /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak pub fn atomic_cxchgweak_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -247,7 +247,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// - /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak + /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak pub fn atomic_cxchgweak_failacq(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -259,7 +259,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// - /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak + /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak pub fn atomic_cxchgweak_acq_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -271,7 +271,7 @@ extern "rust-intrinsic" { /// as the `failure` parameters. For example, /// [`AtomicBool::compare_exchange_weak`][cew]. /// - /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak + /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak pub fn atomic_cxchgweak_acqrel_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Loads the current value of the pointer. From 6e2f07691791f4380ae7c27691b743d926a118b5 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 15:22:04 +0200 Subject: [PATCH 13/44] Use intra-doc links for links with anchors --- library/core/src/intrinsics.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 469dd0cbdd886..ed38ba7925797 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2079,8 +2079,8 @@ pub(crate) fn is_nonoverlapping(src: *const T, dst: *const T, count: usize) - /// /// [`Copy`]: crate::marker::Copy /// [`read`]: crate::ptr::read -/// [read-ownership]: ../ptr/fn.read.html#ownership-of-the-returned-value -/// [valid]: ../ptr/index.html#safety +/// [read-ownership]: crate::ptr::read +/// [valid]: crate::ptr /// /// # Examples /// @@ -2181,8 +2181,8 @@ pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { /// /// [`Copy`]: crate::marker::Copy /// [`read`]: crate::ptr::read -/// [read-ownership]: ../ptr/fn.read.html#ownership-of-the-returned-value -/// [valid]: ../ptr/index.html#safety +/// [read-ownership]: crate::ptr::read +/// [valid]: crate::ptr /// /// # Examples /// @@ -2240,7 +2240,7 @@ pub unsafe fn copy(src: *const T, dst: *mut T, count: usize) { /// Note that even if the effectively copied size (`count * size_of::()`) is /// `0`, the pointer must be non-NULL and properly aligned. /// -/// [valid]: ../ptr/index.html#safety +/// [valid]: crate::ptr /// /// # Examples /// From f71919c3db5be6fd78b0c831872b4bd6857ed086 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Wed, 19 Aug 2020 16:44:20 +0200 Subject: [PATCH 14/44] Fix anchor links --- library/core/src/intrinsics.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index ed38ba7925797..95f4db61d3921 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2079,8 +2079,8 @@ pub(crate) fn is_nonoverlapping(src: *const T, dst: *const T, count: usize) - /// /// [`Copy`]: crate::marker::Copy /// [`read`]: crate::ptr::read -/// [read-ownership]: crate::ptr::read -/// [valid]: crate::ptr +/// [read-ownership]: crate::ptr::read#ownership-of-the-returned-value +/// [valid]: crate::ptr#safety /// /// # Examples /// @@ -2181,8 +2181,8 @@ pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { /// /// [`Copy`]: crate::marker::Copy /// [`read`]: crate::ptr::read -/// [read-ownership]: crate::ptr::read -/// [valid]: crate::ptr +/// [read-ownership]: crate::ptr::read#ownership-of-the-returned-value +/// [valid]: crate::ptr#safety /// /// # Examples /// @@ -2240,7 +2240,7 @@ pub unsafe fn copy(src: *const T, dst: *mut T, count: usize) { /// Note that even if the effectively copied size (`count * size_of::()`) is /// `0`, the pointer must be non-NULL and properly aligned. /// -/// [valid]: crate::ptr +/// [valid]: crate::ptr#safety /// /// # Examples /// From d468a81a8a62131b5b88e3ca09512b8a08895274 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 20 Aug 2020 11:19:11 -0400 Subject: [PATCH 15/44] Remove duplication in `fold_item` --- .../passes/collect_intra_doc_links.rs | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 97b9fcce05b36..1036d40167c38 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -636,7 +636,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { } match disambiguator.map(Disambiguator::ns) { - Some(ns @ ValueNS) => { + Some(ns @ ValueNS | ns @ TypeNS) => { match self.resolve( path_str, disambiguator, @@ -660,28 +660,6 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { } } } - Some(ns @ TypeNS) => { - match self.resolve( - path_str, - disambiguator, - ns, - ¤t_item, - base_node, - &extra_fragment, - Some(&item), - ) { - Ok(res) => res, - Err(ErrorKind::ResolutionFailure) => { - resolution_failure(cx, &item, path_str, &dox, link_range); - // This could just be a normal link. - continue; - } - Err(ErrorKind::AnchorFailure(msg)) => { - anchor_failure(cx, &item, &ori_link, &dox, link_range, msg); - continue; - } - } - } None => { // Try everything! let mut candidates = PerNS { From 3307ba8212a440e0f13a5dfdae57f2a24acdc025 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 19 Aug 2020 22:44:21 +0200 Subject: [PATCH 16/44] Ignore code examples on given items where it doesn't make sense --- .../passes/calculate_doc_coverage.rs | 59 +++++++++++++------ 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index 0a836f46c0eb8..1d79fc3f191f2 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -31,18 +31,27 @@ fn calculate_doc_coverage(krate: clean::Crate, ctx: &DocContext<'_>) -> clean::C struct ItemCount { total: u64, with_docs: u64, + total_examples: u64, with_examples: u64, } impl ItemCount { - fn count_item(&mut self, has_docs: bool, has_doc_example: bool) { + fn count_item( + &mut self, + has_docs: bool, + has_doc_example: bool, + should_have_doc_examples: bool, + ) { self.total += 1; if has_docs { self.with_docs += 1; } - if has_doc_example { - self.with_examples += 1; + if should_have_doc_examples { + self.total_examples += 1; + if has_doc_example { + self.with_examples += 1; + } } } @@ -55,8 +64,8 @@ impl ItemCount { } fn examples_percentage(&self) -> Option { - if self.total > 0 { - Some((self.with_examples as f64 * 100.0) / self.total as f64) + if self.total_examples > 0 { + Some((self.with_examples as f64 * 100.0) / self.total_examples as f64) } else { None } @@ -70,6 +79,7 @@ impl ops::Sub for ItemCount { ItemCount { total: self.total - rhs.total, with_docs: self.with_docs - rhs.with_docs, + total_examples: self.total_examples - rhs.total_examples, with_examples: self.with_examples - rhs.with_examples, } } @@ -79,6 +89,7 @@ impl ops::AddAssign for ItemCount { fn add_assign(&mut self, rhs: Self) { self.total += rhs.total; self.with_docs += rhs.with_docs; + self.total_examples += rhs.total_examples; self.with_examples += rhs.with_examples; } } @@ -176,19 +187,6 @@ impl CoverageCalculator { impl fold::DocFolder for CoverageCalculator { fn fold_item(&mut self, i: clean::Item) -> Option { - let has_docs = !i.attrs.doc_strings.is_empty(); - let mut tests = Tests { found_tests: 0 }; - - find_testable_code( - &i.attrs.doc_strings.iter().map(|d| d.as_str()).collect::>().join("\n"), - &mut tests, - ErrorCodes::No, - false, - None, - ); - - let has_doc_example = tests.found_tests != 0; - match i.inner { _ if !i.def_id.is_local() => { // non-local items are skipped because they can be out of the users control, @@ -237,11 +235,34 @@ impl fold::DocFolder for CoverageCalculator { } } _ => { + let has_docs = !i.attrs.doc_strings.is_empty(); + let mut tests = Tests { found_tests: 0 }; + + let should_have_doc_examples = !matches!(i.inner, + clean::StructFieldItem(_) + | clean::VariantItem(_) + | clean::AssocConstItem(_, _) + | clean::AssocTypeItem(_, _) + | clean::TypedefItem(_, _) + | clean::StaticItem(_) + | clean::ConstantItem(_) + ); + if should_have_doc_examples { + find_testable_code( + &i.attrs.doc_strings.iter().map(|d| d.as_str()).collect::>().join("\n"), + &mut tests, + ErrorCodes::No, + false, + None, + ); + } + + let has_doc_example = tests.found_tests != 0; debug!("counting {:?} {:?} in {}", i.type_(), i.name, i.source.filename); self.items .entry(i.source.filename.clone()) .or_default() - .count_item(has_docs, has_doc_example); + .count_item(has_docs, has_doc_example, should_have_doc_examples); } } From 6fb7e02a3688efa5f3eec4835ef9b5de50eb3c3c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 19 Aug 2020 22:44:58 +0200 Subject: [PATCH 17/44] Update rustdoc coverage UI test --- .../passes/calculate_doc_coverage.rs | 16 +++++--- src/test/rustdoc-ui/coverage/json.rs | 40 ++++++++++++++++++- src/test/rustdoc-ui/coverage/json.stdout | 2 +- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index 1d79fc3f191f2..08502c5b81731 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -249,7 +249,12 @@ impl fold::DocFolder for CoverageCalculator { ); if should_have_doc_examples { find_testable_code( - &i.attrs.doc_strings.iter().map(|d| d.as_str()).collect::>().join("\n"), + &i.attrs + .doc_strings + .iter() + .map(|d| d.as_str()) + .collect::>() + .join("\n"), &mut tests, ErrorCodes::No, false, @@ -259,10 +264,11 @@ impl fold::DocFolder for CoverageCalculator { let has_doc_example = tests.found_tests != 0; debug!("counting {:?} {:?} in {}", i.type_(), i.name, i.source.filename); - self.items - .entry(i.source.filename.clone()) - .or_default() - .count_item(has_docs, has_doc_example, should_have_doc_examples); + self.items.entry(i.source.filename.clone()).or_default().count_item( + has_docs, + has_doc_example, + should_have_doc_examples, + ); } } diff --git a/src/test/rustdoc-ui/coverage/json.rs b/src/test/rustdoc-ui/coverage/json.rs index 2bd6a312ab583..a591cd5dba406 100644 --- a/src/test/rustdoc-ui/coverage/json.rs +++ b/src/test/rustdoc-ui/coverage/json.rs @@ -12,16 +12,54 @@ pub mod foo { pub struct X; /// Bar +/// +/// ``` +/// let x = 12; +/// ``` pub mod bar { /// bar pub struct Bar; /// X - pub enum X { Y } + pub enum X { + /// ``` + /// let x = "should be ignored!"; + /// ``` + Y + } } /// yolo +/// +/// ```text +/// should not be counted as a code example! +/// ``` pub enum Yolo { X } +impl Yolo { + /// ``` + /// let x = "should be ignored!"; + /// ``` + pub const Const: u32 = 0; +} + pub struct Xo { + /// ``` + /// let x = "should be ignored!"; + /// ``` x: T, } + +/// ``` +/// let x = "should be ignored!"; +/// ``` +pub static StaticFoo: u32 = 0; + +/// ``` +/// let x = "should be ignored!"; +/// ``` +pub const ConstFoo: u32 = 0; + +/// ``` +/// let x = "should be ignored!"; +/// ``` +pub type TypeFoo = u32; diff --git a/src/test/rustdoc-ui/coverage/json.stdout b/src/test/rustdoc-ui/coverage/json.stdout index 7b5b083e1584c..992f2751c8612 100644 --- a/src/test/rustdoc-ui/coverage/json.stdout +++ b/src/test/rustdoc-ui/coverage/json.stdout @@ -1 +1 @@ -{"$DIR/json.rs":{"total":13,"with_docs":7,"with_examples":0}} +{"$DIR/json.rs":{"total":17,"with_docs":12,"total_examples":10,"with_examples":1}} From f5d784845801f2c6ec27857f0dff865f376f2ed1 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 20 Aug 2020 12:15:17 -0400 Subject: [PATCH 18/44] Remove duplicate binding in match Co-authored-by: lzutao --- src/librustdoc/passes/collect_intra_doc_links.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 1036d40167c38..9c57435a8c016 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -636,7 +636,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { } match disambiguator.map(Disambiguator::ns) { - Some(ns @ ValueNS | ns @ TypeNS) => { + Some(ns @ (ValueNS | TypeNS)) => { match self.resolve( path_str, disambiguator, From 631c80659dab1e6f0b335cd7862eddc341eff0ac Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 Aug 2020 21:09:40 +0200 Subject: [PATCH 19/44] Remove "total" columns in --show-coverage output --- src/librustdoc/passes/calculate_doc_coverage.rs | 11 +++++------ src/test/rustdoc-ui/coverage/basic.stdout | 13 ++++++------- src/test/rustdoc-ui/coverage/doc-examples.stdout | 13 ++++++------- src/test/rustdoc-ui/coverage/empty.stdout | 13 ++++++------- src/test/rustdoc-ui/coverage/enums.stdout | 13 ++++++------- src/test/rustdoc-ui/coverage/exotic.stdout | 14 ++++++-------- src/test/rustdoc-ui/coverage/json.stdout | 2 +- src/test/rustdoc-ui/coverage/private.stdout | 13 ++++++------- src/test/rustdoc-ui/coverage/statics-consts.stdout | 13 ++++++------- src/test/rustdoc-ui/coverage/traits.stdout | 13 ++++++------- 10 files changed, 54 insertions(+), 64 deletions(-) diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index 08502c5b81731..93a271b81fb51 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -48,7 +48,7 @@ impl ItemCount { self.with_docs += 1; } if should_have_doc_examples { - self.total_examples += 1; + self.with_examples += 1; if has_doc_example { self.with_examples += 1; } @@ -132,7 +132,7 @@ impl CoverageCalculator { let mut total = ItemCount::default(); fn print_table_line() { - println!("+-{0:->35}-+-{0:->10}-+-{0:->10}-+-{0:->10}-+-{0:->10}-+-{0:->10}-+", ""); + println!("+-{0:->35}-+-{0:->10}-+-{0:->10}-+-{0:->10}-+-{0:->10}-+", ""); } fn print_table_record( @@ -142,10 +142,9 @@ impl CoverageCalculator { examples_percentage: f64, ) { println!( - "| {:<35} | {:>10} | {:>10} | {:>9.1}% | {:>10} | {:>9.1}% |", + "| {:<35} | {:>10} | {:>9.1}% | {:>10} | {:>9.1}% |", name, count.with_docs, - count.total, percentage, count.with_examples, examples_percentage, @@ -154,8 +153,8 @@ impl CoverageCalculator { print_table_line(); println!( - "| {:<35} | {:>10} | {:>10} | {:>10} | {:>10} | {:>10} |", - "File", "Documented", "Total", "Percentage", "Examples", "Percentage", + "| {:<35} | {:>10} | {:>10} | {:>10} | {:>10} |", + "File", "Documented", "Percentage", "Examples", "Percentage", ); print_table_line(); diff --git a/src/test/rustdoc-ui/coverage/basic.stdout b/src/test/rustdoc-ui/coverage/basic.stdout index 7e795acc575bc..3a869016505b1 100644 --- a/src/test/rustdoc-ui/coverage/basic.stdout +++ b/src/test/rustdoc-ui/coverage/basic.stdout @@ -1,7 +1,6 @@ -+-------------------------------------+------------+------------+------------+------------+------------+ -| File | Documented | Total | Percentage | Examples | Percentage | -+-------------------------------------+------------+------------+------------+------------+------------+ -| ...est/rustdoc-ui/coverage/basic.rs | 7 | 14 | 50.0% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ -| Total | 7 | 14 | 50.0% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| File | Documented | Percentage | Examples | Percentage | ++-------------------------------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| Total | 0 | 0.0% | 0 | 0.0% | ++-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/doc-examples.stdout b/src/test/rustdoc-ui/coverage/doc-examples.stdout index f25cf79a3f35d..3a869016505b1 100644 --- a/src/test/rustdoc-ui/coverage/doc-examples.stdout +++ b/src/test/rustdoc-ui/coverage/doc-examples.stdout @@ -1,7 +1,6 @@ -+-------------------------------------+------------+------------+------------+------------+------------+ -| File | Documented | Total | Percentage | Examples | Percentage | -+-------------------------------------+------------+------------+------------+------------+------------+ -| ...tdoc-ui/coverage/doc-examples.rs | 4 | 4 | 100.0% | 2 | 50.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ -| Total | 4 | 4 | 100.0% | 2 | 50.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| File | Documented | Percentage | Examples | Percentage | ++-------------------------------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| Total | 0 | 0.0% | 0 | 0.0% | ++-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/empty.stdout b/src/test/rustdoc-ui/coverage/empty.stdout index 2a6a2231e5b57..3a869016505b1 100644 --- a/src/test/rustdoc-ui/coverage/empty.stdout +++ b/src/test/rustdoc-ui/coverage/empty.stdout @@ -1,7 +1,6 @@ -+-------------------------------------+------------+------------+------------+------------+------------+ -| File | Documented | Total | Percentage | Examples | Percentage | -+-------------------------------------+------------+------------+------------+------------+------------+ -| ...est/rustdoc-ui/coverage/empty.rs | 0 | 1 | 0.0% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ -| Total | 0 | 1 | 0.0% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| File | Documented | Percentage | Examples | Percentage | ++-------------------------------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| Total | 0 | 0.0% | 0 | 0.0% | ++-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/enums.stdout b/src/test/rustdoc-ui/coverage/enums.stdout index dd86f61f8d501..3a869016505b1 100644 --- a/src/test/rustdoc-ui/coverage/enums.stdout +++ b/src/test/rustdoc-ui/coverage/enums.stdout @@ -1,7 +1,6 @@ -+-------------------------------------+------------+------------+------------+------------+------------+ -| File | Documented | Total | Percentage | Examples | Percentage | -+-------------------------------------+------------+------------+------------+------------+------------+ -| ...est/rustdoc-ui/coverage/enums.rs | 6 | 8 | 75.0% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ -| Total | 6 | 8 | 75.0% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| File | Documented | Percentage | Examples | Percentage | ++-------------------------------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| Total | 0 | 0.0% | 0 | 0.0% | ++-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/exotic.stdout b/src/test/rustdoc-ui/coverage/exotic.stdout index f920a3abd36bb..3a869016505b1 100644 --- a/src/test/rustdoc-ui/coverage/exotic.stdout +++ b/src/test/rustdoc-ui/coverage/exotic.stdout @@ -1,8 +1,6 @@ -+-------------------------------------+------------+------------+------------+------------+------------+ -| File | Documented | Total | Percentage | Examples | Percentage | -+-------------------------------------+------------+------------+------------+------------+------------+ -| ...st/rustdoc-ui/coverage/exotic.rs | 1 | 1 | 100.0% | 0 | 0.0% | -| | 2 | 2 | 100.0% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ -| Total | 3 | 3 | 100.0% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| File | Documented | Percentage | Examples | Percentage | ++-------------------------------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| Total | 0 | 0.0% | 0 | 0.0% | ++-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/json.stdout b/src/test/rustdoc-ui/coverage/json.stdout index 992f2751c8612..6218b5fe07a4e 100644 --- a/src/test/rustdoc-ui/coverage/json.stdout +++ b/src/test/rustdoc-ui/coverage/json.stdout @@ -1 +1 @@ -{"$DIR/json.rs":{"total":17,"with_docs":12,"total_examples":10,"with_examples":1}} +{"$DIR/json.rs":{"total":17,"with_docs":12,"total_examples":0,"with_examples":11}} diff --git a/src/test/rustdoc-ui/coverage/private.stdout b/src/test/rustdoc-ui/coverage/private.stdout index bca3d51da59d0..3a869016505b1 100644 --- a/src/test/rustdoc-ui/coverage/private.stdout +++ b/src/test/rustdoc-ui/coverage/private.stdout @@ -1,7 +1,6 @@ -+-------------------------------------+------------+------------+------------+------------+------------+ -| File | Documented | Total | Percentage | Examples | Percentage | -+-------------------------------------+------------+------------+------------+------------+------------+ -| ...t/rustdoc-ui/coverage/private.rs | 4 | 7 | 57.1% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ -| Total | 4 | 7 | 57.1% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| File | Documented | Percentage | Examples | Percentage | ++-------------------------------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| Total | 0 | 0.0% | 0 | 0.0% | ++-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/statics-consts.stdout b/src/test/rustdoc-ui/coverage/statics-consts.stdout index 31b48cc602a76..3a869016505b1 100644 --- a/src/test/rustdoc-ui/coverage/statics-consts.stdout +++ b/src/test/rustdoc-ui/coverage/statics-consts.stdout @@ -1,7 +1,6 @@ -+-------------------------------------+------------+------------+------------+------------+------------+ -| File | Documented | Total | Percentage | Examples | Percentage | -+-------------------------------------+------------+------------+------------+------------+------------+ -| ...oc-ui/coverage/statics-consts.rs | 6 | 7 | 85.7% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ -| Total | 6 | 7 | 85.7% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| File | Documented | Percentage | Examples | Percentage | ++-------------------------------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| Total | 0 | 0.0% | 0 | 0.0% | ++-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/traits.stdout b/src/test/rustdoc-ui/coverage/traits.stdout index ac63b65023d0b..3a869016505b1 100644 --- a/src/test/rustdoc-ui/coverage/traits.stdout +++ b/src/test/rustdoc-ui/coverage/traits.stdout @@ -1,7 +1,6 @@ -+-------------------------------------+------------+------------+------------+------------+------------+ -| File | Documented | Total | Percentage | Examples | Percentage | -+-------------------------------------+------------+------------+------------+------------+------------+ -| ...st/rustdoc-ui/coverage/traits.rs | 6 | 7 | 85.7% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ -| Total | 6 | 7 | 85.7% | 0 | 0.0% | -+-------------------------------------+------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| File | Documented | Percentage | Examples | Percentage | ++-------------------------------------+------------+------------+------------+------------+ ++-------------------------------------+------------+------------+------------+------------+ +| Total | 0 | 0.0% | 0 | 0.0% | ++-------------------------------------+------------+------------+------------+------------+ From 9c254c18d6d32a15879cc7f57e3039b66a481340 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 Aug 2020 21:15:02 +0200 Subject: [PATCH 20/44] Update how doc examples are counted --- .../passes/calculate_doc_coverage.rs | 34 +++++++++---------- src/test/rustdoc-ui/coverage/basic.stdout | 3 +- .../rustdoc-ui/coverage/doc-examples-json.rs | 13 +++++++ .../coverage/doc-examples-json.stdout | 1 + .../rustdoc-ui/coverage/doc-examples.stdout | 3 +- src/test/rustdoc-ui/coverage/empty.stdout | 1 + src/test/rustdoc-ui/coverage/enums.stdout | 3 +- src/test/rustdoc-ui/coverage/exotic.stdout | 4 ++- src/test/rustdoc-ui/coverage/json.stdout | 2 +- src/test/rustdoc-ui/coverage/private.stdout | 3 +- .../rustdoc-ui/coverage/statics-consts.stdout | 3 +- src/test/rustdoc-ui/coverage/traits.stdout | 3 +- 12 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 src/test/rustdoc-ui/coverage/doc-examples-json.rs create mode 100644 src/test/rustdoc-ui/coverage/doc-examples-json.stdout diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index 93a271b81fb51..1bdd337dabecb 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -47,11 +47,11 @@ impl ItemCount { if has_docs { self.with_docs += 1; } - if should_have_doc_examples { + if should_have_doc_examples || has_doc_example { + self.total_examples += 1; + } + if has_doc_example { self.with_examples += 1; - if has_doc_example { - self.with_examples += 1; - } } } @@ -246,20 +246,18 @@ impl fold::DocFolder for CoverageCalculator { | clean::StaticItem(_) | clean::ConstantItem(_) ); - if should_have_doc_examples { - find_testable_code( - &i.attrs - .doc_strings - .iter() - .map(|d| d.as_str()) - .collect::>() - .join("\n"), - &mut tests, - ErrorCodes::No, - false, - None, - ); - } + find_testable_code( + &i.attrs + .doc_strings + .iter() + .map(|d| d.as_str()) + .collect::>() + .join("\n"), + &mut tests, + ErrorCodes::No, + false, + None, + ); let has_doc_example = tests.found_tests != 0; debug!("counting {:?} {:?} in {}", i.type_(), i.name, i.source.filename); diff --git a/src/test/rustdoc-ui/coverage/basic.stdout b/src/test/rustdoc-ui/coverage/basic.stdout index 3a869016505b1..3c602b3da4c7c 100644 --- a/src/test/rustdoc-ui/coverage/basic.stdout +++ b/src/test/rustdoc-ui/coverage/basic.stdout @@ -1,6 +1,7 @@ +-------------------------------------+------------+------------+------------+------------+ | File | Documented | Percentage | Examples | Percentage | +-------------------------------------+------------+------------+------------+------------+ +| ...est/rustdoc-ui/coverage/basic.rs | 7 | 50.0% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ -| Total | 0 | 0.0% | 0 | 0.0% | +| Total | 7 | 50.0% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/doc-examples-json.rs b/src/test/rustdoc-ui/coverage/doc-examples-json.rs new file mode 100644 index 0000000000000..1da1813790e86 --- /dev/null +++ b/src/test/rustdoc-ui/coverage/doc-examples-json.rs @@ -0,0 +1,13 @@ +// check-pass +// compile-flags:-Z unstable-options --output-format json --show-coverage + +// This check ensures that only one doc example is counted since they're "optional" on +// certain items. + +/// ``` +/// let x = 12; +/// ``` +pub const Foo: u32 = 0; + +/// doc +pub const Bar: u32 = 0; diff --git a/src/test/rustdoc-ui/coverage/doc-examples-json.stdout b/src/test/rustdoc-ui/coverage/doc-examples-json.stdout new file mode 100644 index 0000000000000..92f58556975ae --- /dev/null +++ b/src/test/rustdoc-ui/coverage/doc-examples-json.stdout @@ -0,0 +1 @@ +{"$DIR/doc-examples-json.rs":{"total":3,"with_docs":2,"total_examples":2,"with_examples":1}} diff --git a/src/test/rustdoc-ui/coverage/doc-examples.stdout b/src/test/rustdoc-ui/coverage/doc-examples.stdout index 3a869016505b1..10ed13c9ff566 100644 --- a/src/test/rustdoc-ui/coverage/doc-examples.stdout +++ b/src/test/rustdoc-ui/coverage/doc-examples.stdout @@ -1,6 +1,7 @@ +-------------------------------------+------------+------------+------------+------------+ | File | Documented | Percentage | Examples | Percentage | +-------------------------------------+------------+------------+------------+------------+ +| ...tdoc-ui/coverage/doc-examples.rs | 4 | 100.0% | 2 | 50.0% | +-------------------------------------+------------+------------+------------+------------+ -| Total | 0 | 0.0% | 0 | 0.0% | +| Total | 4 | 100.0% | 2 | 50.0% | +-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/empty.stdout b/src/test/rustdoc-ui/coverage/empty.stdout index 3a869016505b1..890a7d56e162d 100644 --- a/src/test/rustdoc-ui/coverage/empty.stdout +++ b/src/test/rustdoc-ui/coverage/empty.stdout @@ -1,6 +1,7 @@ +-------------------------------------+------------+------------+------------+------------+ | File | Documented | Percentage | Examples | Percentage | +-------------------------------------+------------+------------+------------+------------+ +| ...est/rustdoc-ui/coverage/empty.rs | 0 | 0.0% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ | Total | 0 | 0.0% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/enums.stdout b/src/test/rustdoc-ui/coverage/enums.stdout index 3a869016505b1..64c012c1f66e3 100644 --- a/src/test/rustdoc-ui/coverage/enums.stdout +++ b/src/test/rustdoc-ui/coverage/enums.stdout @@ -1,6 +1,7 @@ +-------------------------------------+------------+------------+------------+------------+ | File | Documented | Percentage | Examples | Percentage | +-------------------------------------+------------+------------+------------+------------+ +| ...est/rustdoc-ui/coverage/enums.rs | 6 | 75.0% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ -| Total | 0 | 0.0% | 0 | 0.0% | +| Total | 6 | 75.0% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/exotic.stdout b/src/test/rustdoc-ui/coverage/exotic.stdout index 3a869016505b1..e282ff1284375 100644 --- a/src/test/rustdoc-ui/coverage/exotic.stdout +++ b/src/test/rustdoc-ui/coverage/exotic.stdout @@ -1,6 +1,8 @@ +-------------------------------------+------------+------------+------------+------------+ | File | Documented | Percentage | Examples | Percentage | +-------------------------------------+------------+------------+------------+------------+ +| ...st/rustdoc-ui/coverage/exotic.rs | 1 | 100.0% | 0 | 0.0% | +| | 2 | 100.0% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ -| Total | 0 | 0.0% | 0 | 0.0% | +| Total | 3 | 100.0% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/json.stdout b/src/test/rustdoc-ui/coverage/json.stdout index 6218b5fe07a4e..c2be73ce3edd7 100644 --- a/src/test/rustdoc-ui/coverage/json.stdout +++ b/src/test/rustdoc-ui/coverage/json.stdout @@ -1 +1 @@ -{"$DIR/json.rs":{"total":17,"with_docs":12,"total_examples":0,"with_examples":11}} +{"$DIR/json.rs":{"total":17,"with_docs":12,"total_examples":15,"with_examples":6}} diff --git a/src/test/rustdoc-ui/coverage/private.stdout b/src/test/rustdoc-ui/coverage/private.stdout index 3a869016505b1..37a0f5187b512 100644 --- a/src/test/rustdoc-ui/coverage/private.stdout +++ b/src/test/rustdoc-ui/coverage/private.stdout @@ -1,6 +1,7 @@ +-------------------------------------+------------+------------+------------+------------+ | File | Documented | Percentage | Examples | Percentage | +-------------------------------------+------------+------------+------------+------------+ +| ...t/rustdoc-ui/coverage/private.rs | 4 | 57.1% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ -| Total | 0 | 0.0% | 0 | 0.0% | +| Total | 4 | 57.1% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/statics-consts.stdout b/src/test/rustdoc-ui/coverage/statics-consts.stdout index 3a869016505b1..dbea3a3ea23cf 100644 --- a/src/test/rustdoc-ui/coverage/statics-consts.stdout +++ b/src/test/rustdoc-ui/coverage/statics-consts.stdout @@ -1,6 +1,7 @@ +-------------------------------------+------------+------------+------------+------------+ | File | Documented | Percentage | Examples | Percentage | +-------------------------------------+------------+------------+------------+------------+ +| ...oc-ui/coverage/statics-consts.rs | 6 | 85.7% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ -| Total | 0 | 0.0% | 0 | 0.0% | +| Total | 6 | 85.7% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/traits.stdout b/src/test/rustdoc-ui/coverage/traits.stdout index 3a869016505b1..e04d48b4980c4 100644 --- a/src/test/rustdoc-ui/coverage/traits.stdout +++ b/src/test/rustdoc-ui/coverage/traits.stdout @@ -1,6 +1,7 @@ +-------------------------------------+------------+------------+------------+------------+ | File | Documented | Percentage | Examples | Percentage | +-------------------------------------+------------+------------+------------+------------+ +| ...st/rustdoc-ui/coverage/traits.rs | 6 | 85.7% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ -| Total | 0 | 0.0% | 0 | 0.0% | +| Total | 6 | 85.7% | 0 | 0.0% | +-------------------------------------+------------+------------+------------+------------+ From d108bd53866aef2a3b76164352c095e898fe92db Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 Aug 2020 21:26:42 +0200 Subject: [PATCH 21/44] Add documentation for --show-coverage option --- src/doc/rustdoc/src/unstable-features.md | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index d16c2a9d0342c..4e407c19b4128 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -467,3 +467,36 @@ $ rustdoc src/lib.rs -Z unstable-options --runtool valgrind ``` Another use case would be to run a test inside an emulator, or through a Virtual Machine. + +### `--show-coverage`: get statistics about code documentation coverage + +This option allows you to get a nice overview over your code documentation coverage, including both +doc-comments and code examples in the doc-comments. Example: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --show-coverage ++-------------------------------------+------------+------------+------------+------------+ +| File | Documented | Percentage | Examples | Percentage | ++-------------------------------------+------------+------------+------------+------------+ +| lib.rs | 4 | 100.0% | 1 | 25.0% | ++-------------------------------------+------------+------------+------------+------------+ +| Total | 4 | 100.0% | 1 | 25.0% | ++-------------------------------------+------------+------------+------------+------------+ +``` + +You can also use this option with the `--output-format` one: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --show-coverage --output-format json +{"lib.rs":{"total":4,"with_docs":4,"total_examples":4,"with_examples":1}} +``` + +To be noted: the computation of code examples follows these rules: + +1. These items aren't accounted by default: + * struct/union field + * enum variant + * constant + * static + * typedef +2. If one of the previously listed items has a code example, then it'll be counted. From 5e9cc4e31920b72fe4f1c4a44d1a6e250e36f254 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 Aug 2020 21:28:06 +0200 Subject: [PATCH 22/44] fmt --- src/librustdoc/passes/calculate_doc_coverage.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index 1bdd337dabecb..fd3179c13fe22 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -143,11 +143,7 @@ impl CoverageCalculator { ) { println!( "| {:<35} | {:>10} | {:>9.1}% | {:>10} | {:>9.1}% |", - name, - count.with_docs, - percentage, - count.with_examples, - examples_percentage, + name, count.with_docs, percentage, count.with_examples, examples_percentage, ); } @@ -247,12 +243,7 @@ impl fold::DocFolder for CoverageCalculator { | clean::ConstantItem(_) ); find_testable_code( - &i.attrs - .doc_strings - .iter() - .map(|d| d.as_str()) - .collect::>() - .join("\n"), + &i.attrs.doc_strings.iter().map(|d| d.as_str()).collect::>().join("\n"), &mut tests, ErrorCodes::No, false, From 1ababd87942dd3f62d6abc5fa1833fce2d5b88eb Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Thu, 20 Aug 2020 23:43:46 +0200 Subject: [PATCH 23/44] Use intra-doc-links in `alloc` --- library/alloc/src/alloc.rs | 18 --- library/alloc/src/boxed.rs | 26 ++-- library/alloc/src/collections/linked_list.rs | 11 +- library/alloc/src/fmt.rs | 38 +++--- library/alloc/src/lib.rs | 10 +- library/alloc/src/macros.rs | 11 +- library/alloc/src/rc.rs | 96 ++++++--------- library/alloc/src/slice.rs | 10 +- library/alloc/src/string.rs | 2 +- library/alloc/src/sync.rs | 119 +++++++------------ 10 files changed, 121 insertions(+), 220 deletions(-) diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index fa5eb1823f1a0..87b86e590a4c8 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -36,8 +36,6 @@ extern "Rust" { /// /// Note: while this type is unstable, the functionality it provides can be /// accessed through the [free functions in `alloc`](index.html#functions). -/// -/// [`AllocRef`]: trait.AllocRef.html #[unstable(feature = "allocator_api", issue = "32838")] #[derive(Copy, Clone, Default, Debug)] pub struct Global; @@ -55,10 +53,6 @@ pub struct Global; /// /// See [`GlobalAlloc::alloc`]. /// -/// [`Global`]: struct.Global.html -/// [`AllocRef`]: trait.AllocRef.html -/// [`GlobalAlloc::alloc`]: trait.GlobalAlloc.html#tymethod.alloc -/// /// # Examples /// /// ``` @@ -92,10 +86,6 @@ pub unsafe fn alloc(layout: Layout) -> *mut u8 { /// # Safety /// /// See [`GlobalAlloc::dealloc`]. -/// -/// [`Global`]: struct.Global.html -/// [`AllocRef`]: trait.AllocRef.html -/// [`GlobalAlloc::dealloc`]: trait.GlobalAlloc.html#tymethod.dealloc #[stable(feature = "global_alloc", since = "1.28.0")] #[inline] pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) { @@ -114,10 +104,6 @@ pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) { /// # Safety /// /// See [`GlobalAlloc::realloc`]. -/// -/// [`Global`]: struct.Global.html -/// [`AllocRef`]: trait.AllocRef.html -/// [`GlobalAlloc::realloc`]: trait.GlobalAlloc.html#method.realloc #[stable(feature = "global_alloc", since = "1.28.0")] #[inline] pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { @@ -137,10 +123,6 @@ pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 /// /// See [`GlobalAlloc::alloc_zeroed`]. /// -/// [`Global`]: struct.Global.html -/// [`AllocRef`]: trait.AllocRef.html -/// [`GlobalAlloc::alloc_zeroed`]: trait.GlobalAlloc.html#method.alloc_zeroed -/// /// # Examples /// /// ``` diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 5e304beff78ab..93d0df448ea14 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -118,14 +118,13 @@ //! described in [rust-lang/unsafe-code-guidelines#198][ucg#198]. //! //! [ucg#198]: https://github.com/rust-lang/unsafe-code-guidelines/issues/198 -//! [dereferencing]: ../../std/ops/trait.Deref.html -//! [`Box`]: struct.Box.html -//! [`Box`]: struct.Box.html -//! [`Box::::from_raw(value)`]: struct.Box.html#method.from_raw -//! [`Box::::into_raw`]: struct.Box.html#method.into_raw -//! [`Global`]: ../alloc/struct.Global.html -//! [`Layout`]: ../alloc/struct.Layout.html -//! [`Layout::for_value(&*value)`]: ../alloc/struct.Layout.html#method.for_value +//! [dereferencing]: core::ops::Deref +//! [`Box`]: Box +//! [`Box::::from_raw(value)`]: Box::from_raw +//! [`Box::::into_raw`]: Box::into_raw +//! [`Global`]: crate::alloc::Global +//! [`Layout`]: crate::alloc::Layout +//! [`Layout::for_value(&*value)`]: crate::alloc::Layout::for_value #![stable(feature = "rust1", since = "1.0.0")] @@ -240,7 +239,6 @@ impl Box { /// Converts a `Box` into a `Box<[T]>` /// /// This conversion does not allocate on the heap and happens in place. - /// #[unstable(feature = "box_into_boxed_slice", issue = "71582")] pub fn into_boxed_slice(boxed: Box) -> Box<[T]> { // *mut T and *mut [T; 1] have the same size and alignment @@ -386,9 +384,8 @@ impl Box { /// } /// ``` /// - /// [memory layout]: index.html#memory-layout - /// [`Layout`]: ../alloc/struct.Layout.html - /// [`Box::into_raw`]: struct.Box.html#method.into_raw + /// [memory layout]: self#memory-layout + /// [`Layout`]: crate::Layout #[stable(feature = "box_raw", since = "1.4.0")] #[inline] pub unsafe fn from_raw(raw: *mut T) -> Self { @@ -433,8 +430,7 @@ impl Box { /// } /// ``` /// - /// [memory layout]: index.html#memory-layout - /// [`Box::from_raw`]: struct.Box.html#method.from_raw + /// [memory layout]: self#memory-layout #[stable(feature = "box_raw", since = "1.4.0")] #[inline] pub fn into_raw(b: Box) -> *mut T { @@ -478,8 +474,6 @@ impl Box { /// to call it as `Box::leak(b)` instead of `b.leak()`. This /// is so that there is no conflict with a method on the inner type. /// - /// [`Box::from_raw`]: struct.Box.html#method.from_raw - /// /// # Examples /// /// Simple usage: diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index 02a746f0e2488..74155ea66d020 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -7,8 +7,8 @@ //! array-based containers are generally faster, //! more memory efficient, and make better use of CPU cache. //! -//! [`Vec`]: ../../vec/struct.Vec.html -//! [`VecDeque`]: ../vec_deque/struct.VecDeque.html +//! [`Vec`]: crate::vec::Vec +//! [`VecDeque`]: super::vec_deque::VecDeque #![stable(feature = "rust1", since = "1.0.0")] @@ -53,8 +53,7 @@ struct Node { /// This `struct` is created by the [`iter`] method on [`LinkedList`]. See its /// documentation for more. /// -/// [`iter`]: struct.LinkedList.html#method.iter -/// [`LinkedList`]: struct.LinkedList.html +/// [`iter`]: LinkedList::iter #[stable(feature = "rust1", since = "1.0.0")] pub struct Iter<'a, T: 'a> { head: Option>>, @@ -83,8 +82,7 @@ impl Clone for Iter<'_, T> { /// This `struct` is created by the [`iter_mut`] method on [`LinkedList`]. See its /// documentation for more. /// -/// [`iter_mut`]: struct.LinkedList.html#method.iter_mut -/// [`LinkedList`]: struct.LinkedList.html +/// [`iter_mut`]: LinkedList::iter_mut #[stable(feature = "rust1", since = "1.0.0")] pub struct IterMut<'a, T: 'a> { // We do *not* exclusively own the entire list here, references to node's `element` @@ -109,7 +107,6 @@ impl fmt::Debug for IterMut<'_, T> { /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`into_iter`]: struct.LinkedList.html#method.into_iter -/// [`LinkedList`]: struct.LinkedList.html #[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct IntoIter { diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index a0b151a4496f1..016b5446f4ddb 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -501,31 +501,26 @@ //! it would internally pass around this structure until it has been determined //! where output should go to. //! -//! [`usize`]: ../../std/primitive.usize.html -//! [`isize`]: ../../std/primitive.isize.html -//! [`i8`]: ../../std/primitive.i8.html -//! [`Display`]: trait.Display.html -//! [`Binary`]: trait.Binary.html -//! [`fmt::Result`]: type.Result.html -//! [`Result`]: ../../std/result/enum.Result.html -//! [`std::fmt::Error`]: struct.Error.html -//! [`Formatter`]: struct.Formatter.html -//! [`write!`]: ../../std/macro.write.html -//! [`Debug`]: trait.Debug.html -//! [`format!`]: ../../std/macro.format.html -//! [`to_string`]: ../../std/string/trait.ToString.html -//! [`writeln!`]: ../../std/macro.writeln.html +//! [`usize`]: core::usize +//! [`isize`]: core::isize +//! [`i8`]: core::i8 +//! [`fmt::Result`]: Result +//! [`Result`]: core::result::Result +//! [`std::fmt::Error`]: Error +//! [`write!`]: core::write +//! [`write`]: core::write +//! [`format!`]: crate::format +//! [`to_string`]: crate::string::ToString +//! [`writeln!`]: core::writeln //! [`write_fmt`]: ../../std/io/trait.Write.html#method.write_fmt //! [`std::io::Write`]: ../../std/io/trait.Write.html //! [`print!`]: ../../std/macro.print.html //! [`println!`]: ../../std/macro.println.html //! [`eprint!`]: ../../std/macro.eprint.html //! [`eprintln!`]: ../../std/macro.eprintln.html -//! [`write!`]: ../../std/macro.write.html -//! [`format_args!`]: ../../std/macro.format_args.html -//! [`fmt::Arguments`]: struct.Arguments.html -//! [`write`]: fn.write.html -//! [`format`]: fn.format.html +//! [`format_args!`]: core::format_args +//! [`fmt::Arguments`]: Arguments +//! [`format`]: crate::format #![stable(feature = "rust1", since = "1.0.0")] @@ -576,9 +571,8 @@ use crate::string; /// assert_eq!(s, "Hello, world!"); /// ``` /// -/// [`Arguments`]: struct.Arguments.html -/// [`format_args!`]: ../../std/macro.format_args.html -/// [`format!`]: ../../std/macro.format.html +/// [`format_args!`]: core::format_args +/// [`format!`]: crate::format #[stable(feature = "rust1", since = "1.0.0")] pub fn format(args: Arguments<'_>) -> string::String { let capacity = args.estimated_capacity(); diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 2d25941a52412..892f794fc4232 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -50,11 +50,11 @@ //! The [`alloc`](alloc/index.html) module defines the low-level interface to the //! default global allocator. It is not compatible with the libc allocator API. //! -//! [`Arc`]: sync/index.html -//! [`Box`]: boxed/index.html -//! [`Cell`]: ../core/cell/index.html -//! [`Rc`]: rc/index.html -//! [`RefCell`]: ../core/cell/index.html +//! [`Arc`]: sync +//! [`Box`]: boxed +//! [`Cell`]: core::cell +//! [`Rc`]: rc +//! [`RefCell`]: core::cell #![allow(unused_attributes)] #![stable(feature = "alloc", since = "1.36.0")] diff --git a/library/alloc/src/macros.rs b/library/alloc/src/macros.rs index e163a166b498f..2f744618d6936 100644 --- a/library/alloc/src/macros.rs +++ b/library/alloc/src/macros.rs @@ -29,8 +29,7 @@ /// to the same boxed integer value, not five references pointing to independently /// boxed integers. /// -/// [`Vec`]: ../std/vec/struct.Vec.html -/// [`Clone`]: ../std/clone/trait.Clone.html +/// [`Vec`]: crate::vec::Vec #[cfg(not(test))] #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] @@ -81,11 +80,11 @@ macro_rules! vec { /// To convert a single value to a string, use the [`to_string`] method. This /// will use the [`Display`] formatting trait. /// -/// [fmt]: ../std/fmt/index.html +/// [fmt]: core::fmt /// [`print!`]: ../std/macro.print.html -/// [`write!`]: ../std/macro.write.html -/// [`to_string`]: ../std/string/trait.ToString.html -/// [`Display`]: ../std/fmt/trait.Display.html +/// [`write!`]: core::write +/// [`to_string`]: crate::string::ToString +/// [`Display`]: core::fmt::Display /// /// # Panics /// diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index d0a47ccea0a76..a41592a45b890 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -214,18 +214,15 @@ //! } //! ``` //! -//! [`Rc`]: struct.Rc.html -//! [`Weak`]: struct.Weak.html -//! [clone]: ../../std/clone/trait.Clone.html#tymethod.clone -//! [`Cell`]: ../../std/cell/struct.Cell.html -//! [`RefCell`]: ../../std/cell/struct.RefCell.html -//! [send]: ../../std/marker/trait.Send.html +//! [clone]: Clone::clone +//! [`Cell`]: core::cell::Cell +//! [`RefCell`]: core::cell::RefCell +//! [send]: core::marker::Send //! [arc]: ../../std/sync/struct.Arc.html -//! [`Deref`]: ../../std/ops/trait.Deref.html -//! [downgrade]: struct.Rc.html#method.downgrade -//! [upgrade]: struct.Weak.html#method.upgrade -//! [`None`]: ../../std/option/enum.Option.html#variant.None -//! [mutability]: ../../std/cell/index.html#introducing-mutability-inside-of-something-immutable +//! [`Deref`]: core::ops::Deref +//! [downgrade]: Rc::downgrade +//! [upgrade]: Weak::upgrade +//! [mutability]: core::cell#introducing-mutability-inside-of-something-immutable #![stable(feature = "rust1", since = "1.0.0")] @@ -396,13 +393,11 @@ impl Rc { /// Returns the inner value, if the `Rc` has exactly one strong reference. /// - /// Otherwise, an [`Err`][result] is returned with the same `Rc` that was + /// Otherwise, an [`Err`][Result] is returned with the same `Rc` that was /// passed in. /// /// This will succeed even if there are outstanding weak references. /// - /// [result]: ../../std/result/enum.Result.html - /// /// # Examples /// /// ``` @@ -553,7 +548,7 @@ impl Rc { /// To avoid a memory leak the pointer must be converted back to an `Rc` using /// [`Rc::from_raw`][from_raw]. /// - /// [from_raw]: struct.Rc.html#method.from_raw + /// [from_raw]: Rc::from_raw /// /// # Examples /// @@ -613,8 +608,8 @@ impl Rc { /// This function is unsafe because improper use may lead to memory unsafety, /// even if the returned `Rc` is never accessed. /// - /// [into_raw]: struct.Rc.html#method.into_raw - /// [transmute]: ../../std/mem/fn.transmute.html + /// [into_raw]: Rc::into_raw + /// [transmute]: core::mem::transmute /// /// # Examples /// @@ -645,9 +640,7 @@ impl Rc { unsafe { Self::from_ptr(rc_ptr) } } - /// Creates a new [`Weak`][weak] pointer to this allocation. - /// - /// [weak]: struct.Weak.html + /// Creates a new [`Weak`] pointer to this allocation. /// /// # Examples /// @@ -666,9 +659,7 @@ impl Rc { Weak { ptr: this.ptr } } - /// Gets the number of [`Weak`][weak] pointers to this allocation. - /// - /// [weak]: struct.Weak.html + /// Gets the number of [`Weak`] pointers to this allocation. /// /// # Examples /// @@ -704,17 +695,15 @@ impl Rc { this.strong() } - /// Returns `true` if there are no other `Rc` or [`Weak`][weak] pointers to + /// Returns `true` if there are no other `Rc` or [`Weak`] pointers to /// this allocation. - /// - /// [weak]: struct.Weak.html #[inline] fn is_unique(this: &Self) -> bool { Rc::weak_count(this) == 0 && Rc::strong_count(this) == 1 } /// Returns a mutable reference into the given `Rc`, if there are - /// no other `Rc` or [`Weak`][weak] pointers to the same allocation. + /// no other `Rc` or [`Weak`] pointers to the same allocation. /// /// Returns [`None`] otherwise, because it is not safe to /// mutate a shared value. @@ -722,10 +711,8 @@ impl Rc { /// See also [`make_mut`][make_mut], which will [`clone`][clone] /// the inner value when there are other pointers. /// - /// [weak]: struct.Weak.html - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// [make_mut]: struct.Rc.html#method.make_mut - /// [clone]: ../../std/clone/trait.Clone.html#tymethod.clone + /// [make_mut]: Rc::make_mut + /// [clone]: Clone::clone /// /// # Examples /// @@ -750,7 +737,7 @@ impl Rc { /// /// See also [`get_mut`], which is safe and does appropriate checks. /// - /// [`get_mut`]: struct.Rc.html#method.get_mut + /// [`get_mut`]: Rc::get_mut /// /// # Safety /// @@ -796,7 +783,7 @@ impl Rc { /// assert!(!Rc::ptr_eq(&five, &other_five)); /// ``` /// - /// [`ptr::eq`]: ../../std/ptr/fn.eq.html + /// [`ptr::eq`]: core::ptr::eq pub fn ptr_eq(this: &Self, other: &Self) -> bool { this.ptr.as_ptr() == other.ptr.as_ptr() } @@ -814,9 +801,8 @@ impl Rc { /// /// See also [`get_mut`], which will fail rather than cloning. /// - /// [`Weak`]: struct.Weak.html - /// [`clone`]: ../../std/clone/trait.Clone.html#tymethod.clone - /// [`get_mut`]: struct.Rc.html#method.get_mut + /// [`clone`]: Clone::clone + /// [`get_mut`]: Rc::get_mut /// /// # Examples /// @@ -1117,8 +1103,6 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Rc { /// drop(foo); // Doesn't print anything /// drop(foo2); // Prints "dropped!" /// ``` - /// - /// [`Weak`]: ../../std/rc/struct.Weak.html fn drop(&mut self) { unsafe { self.dec_strong(); @@ -1600,11 +1584,7 @@ impl> ToRcSlice for I { /// /// The typical way to obtain a `Weak` pointer is to call [`Rc::downgrade`]. /// -/// [`Rc`]: struct.Rc.html -/// [`Rc::downgrade`]: struct.Rc.html#method.downgrade -/// [`upgrade`]: struct.Weak.html#method.upgrade -/// [`Option`]: ../../std/option/enum.Option.html -/// [`None`]: ../../std/option/enum.Option.html#variant.None +/// [`upgrade`]: Weak::upgrade #[stable(feature = "rc_weak", since = "1.4.0")] pub struct Weak { // This is a `NonNull` to allow optimizing the size of this type in enums, @@ -1631,8 +1611,7 @@ impl Weak { /// Constructs a new `Weak`, without allocating any memory. /// Calling [`upgrade`] on the return value always gives [`None`]. /// - /// [`upgrade`]: #method.upgrade - /// [`None`]: ../../std/option/enum.Option.html + /// [`upgrade`]: Weak::upgrade /// /// # Examples /// @@ -1671,7 +1650,7 @@ impl Weak { /// // assert_eq!("hello", unsafe { &*weak.as_ptr() }); /// ``` /// - /// [`null`]: ../../std/ptr/fn.null.html + /// [`null`]: core::ptr::null #[stable(feature = "rc_as_ptr", since = "1.45.0")] pub fn as_ptr(&self) -> *const T { let ptr: *mut RcBox = NonNull::as_ptr(self.ptr); @@ -1713,8 +1692,8 @@ impl Weak { /// assert_eq!(0, Rc::weak_count(&strong)); /// ``` /// - /// [`from_raw`]: struct.Weak.html#method.from_raw - /// [`as_ptr`]: struct.Weak.html#method.as_ptr + /// [`from_raw`]: Weak::from_raw + /// [`as_ptr`]: Weak::as_ptr #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn into_raw(self) -> *const T { let result = self.as_ptr(); @@ -1761,12 +1740,10 @@ impl Weak { /// assert!(unsafe { Weak::from_raw(raw_2) }.upgrade().is_none()); /// ``` /// - /// [`into_raw`]: struct.Weak.html#method.into_raw - /// [`upgrade`]: struct.Weak.html#method.upgrade - /// [`Rc`]: struct.Rc.html - /// [`Weak`]: struct.Weak.html - /// [`new`]: struct.Weak.html#method.new - /// [`forget`]: ../../std/mem/fn.forget.html + /// [`into_raw`]: Weak::into_raw + /// [`upgrade`]: Weak::upgrade + /// [`new`]: Weak::new + /// [`forget`]: std::mem::forget #[stable(feature = "weak_into_raw", since = "1.45.0")] pub unsafe fn from_raw(ptr: *const T) -> Self { if ptr.is_null() { @@ -1794,9 +1771,6 @@ impl Weak { /// /// Returns [`None`] if the inner value has since been dropped. /// - /// [`Rc`]: struct.Rc.html - /// [`None`]: ../../std/option/enum.Option.html - /// /// # Examples /// /// ``` @@ -1829,8 +1803,6 @@ impl Weak { /// Gets the number of strong (`Rc`) pointers pointing to this allocation. /// /// If `self` was created using [`Weak::new`], this will return 0. - /// - /// [`Weak::new`]: #method.new #[stable(feature = "weak_counts", since = "1.41.0")] pub fn strong_count(&self) -> usize { if let Some(inner) = self.inner() { inner.strong() } else { 0 } @@ -1899,7 +1871,7 @@ impl Weak { /// assert!(!first.ptr_eq(&third)); /// ``` /// - /// [`ptr::eq`]: ../../std/ptr/fn.eq.html + /// [`ptr::eq`]: core::ptr::eq #[inline] #[stable(feature = "weak_ptr_eq", since = "1.39.0")] pub fn ptr_eq(&self, other: &Self) -> bool { @@ -1981,8 +1953,8 @@ impl Default for Weak { /// Constructs a new `Weak`, allocating memory for `T` without initializing /// it. Calling [`upgrade`] on the return value always gives [`None`]. /// - /// [`None`]: ../../std/option/enum.Option.html - /// [`upgrade`]: ../../std/rc/struct.Weak.html#method.upgrade + /// [`None`]: Option + /// [`upgrade`]: Weak::upgrade /// /// # Examples /// diff --git a/library/alloc/src/slice.rs b/library/alloc/src/slice.rs index b791c775548cd..8ea2c6dc859b2 100644 --- a/library/alloc/src/slice.rs +++ b/library/alloc/src/slice.rs @@ -70,11 +70,7 @@ //! * Further methods that return iterators are [`.split`], [`.splitn`], //! [`.chunks`], [`.windows`] and more. //! -//! [`Clone`]: ../../std/clone/trait.Clone.html -//! [`Eq`]: ../../std/cmp/trait.Eq.html -//! [`Ord`]: ../../std/cmp/trait.Ord.html -//! [`Iter`]: struct.Iter.html -//! [`Hash`]: ../../std/hash/trait.Hash.html +//! [`Hash`]: core::hash::Hash //! [`.iter`]: ../../std/primitive.slice.html#method.iter //! [`.iter_mut`]: ../../std/primitive.slice.html#method.iter_mut //! [`.split`]: ../../std/primitive.slice.html#method.split @@ -560,7 +556,7 @@ impl [u8] { /// /// To uppercase the value in-place, use [`make_ascii_uppercase`]. /// - /// [`make_ascii_uppercase`]: #method.make_ascii_uppercase + /// [`make_ascii_uppercase`]: u8::make_ascii_uppercase #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] #[inline] pub fn to_ascii_uppercase(&self) -> Vec { @@ -577,7 +573,7 @@ impl [u8] { /// /// To lowercase the value in-place, use [`make_ascii_lowercase`]. /// - /// [`make_ascii_lowercase`]: #method.make_ascii_lowercase + /// [`make_ascii_lowercase`]: u8::make_ascii_lowercase #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] #[inline] pub fn to_ascii_lowercase(&self) -> Vec { diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index d7d7b6bd157bc..223d6755e26f4 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -492,7 +492,7 @@ impl String { /// `from_utf8_lossy()` will replace any invalid UTF-8 sequences with /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], which looks like this: � /// - /// [byteslice]: ../../std/primitive.slice.html + /// [byteslice]: core::slice /// [U+FFFD]: core::char::REPLACEMENT_CHARACTER /// /// If you are sure that the byte slice is valid UTF-8, and you don't want diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index b376330313758..6234f6cc32142 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -2,9 +2,7 @@ //! Thread-safe reference-counting pointers. //! -//! See the [`Arc`][arc] documentation for more details. -//! -//! [arc]: struct.Arc.html +//! See the [`Arc`][Arc] documentation for more details. use core::any::Any; use core::borrow; @@ -100,21 +98,21 @@ macro_rules! acquire { /// ## Breaking cycles with `Weak` /// /// The [`downgrade`][downgrade] method can be used to create a non-owning -/// [`Weak`][weak] pointer. A [`Weak`][weak] pointer can be [`upgrade`][upgrade]d +/// [`Weak`] pointer. A [`Weak`] pointer can be [`upgrade`][upgrade]d /// to an `Arc`, but this will return [`None`] if the value stored in the allocation has /// already been dropped. In other words, `Weak` pointers do not keep the value /// inside the allocation alive; however, they *do* keep the allocation /// (the backing store for the value) alive. /// /// A cycle between `Arc` pointers will never be deallocated. For this reason, -/// [`Weak`][weak] is used to break cycles. For example, a tree could have -/// strong `Arc` pointers from parent nodes to children, and [`Weak`][weak] +/// [`Weak`] is used to break cycles. For example, a tree could have +/// strong `Arc` pointers from parent nodes to children, and [`Weak`] /// pointers from children back to their parents. /// /// # Cloning references /// /// Creating a new reference from an existing reference counted pointer is done using the -/// `Clone` trait implemented for [`Arc`][arc] and [`Weak`][weak]. +/// `Clone` trait implemented for [`Arc`][Arc] and [`Weak`][Weak]. /// /// ``` /// use std::sync::Arc; @@ -139,23 +137,20 @@ macro_rules! acquire { /// Arc::downgrade(&my_arc); /// ``` /// -/// [`Weak`][weak] does not auto-dereference to `T`, because the inner value may have +/// [`Weak`][Weak] does not auto-dereference to `T`, because the inner value may have /// already been dropped. /// -/// [arc]: struct.Arc.html -/// [weak]: struct.Weak.html -/// [`Rc`]: ../../std/rc/struct.Rc.html -/// [clone]: ../../std/clone/trait.Clone.html#tymethod.clone +/// [`Rc`]: crate::rc::Rc +/// [clone]: Clone::clone /// [mutex]: ../../std/sync/struct.Mutex.html /// [rwlock]: ../../std/sync/struct.RwLock.html -/// [atomic]: ../../std/sync/atomic/index.html -/// [`Send`]: ../../std/marker/trait.Send.html -/// [`Sync`]: ../../std/marker/trait.Sync.html -/// [deref]: ../../std/ops/trait.Deref.html -/// [downgrade]: struct.Arc.html#method.downgrade -/// [upgrade]: struct.Weak.html#method.upgrade -/// [`None`]: ../../std/option/enum.Option.html#variant.None -/// [`RefCell`]: ../../std/cell/struct.RefCell.html +/// [atomic]: core::sync::atomic +/// [`Send`]: core::marker::Send +/// [`Sync`]: core::marker::Sync +/// [deref]: core::ops::Deref +/// [downgrade]: Arc::downgrade +/// [upgrade]: Weak::upgrade +/// [`RefCell`]: core::cell::RefCell /// [`std::sync`]: ../../std/sync/index.html /// [`Arc::clone(&from)`]: #method.clone /// @@ -184,7 +179,7 @@ macro_rules! acquire { /// /// Sharing a mutable [`AtomicUsize`]: /// -/// [`AtomicUsize`]: ../../std/sync/atomic/struct.AtomicUsize.html +/// [`AtomicUsize`]: core::sync::atomic::AtomicUsize /// /// ```no_run /// use std::sync::Arc; @@ -254,11 +249,7 @@ impl Arc { /// /// The typical way to obtain a `Weak` pointer is to call [`Arc::downgrade`]. /// -/// [`Arc`]: struct.Arc.html -/// [`Arc::downgrade`]: struct.Arc.html#method.downgrade -/// [`upgrade`]: struct.Weak.html#method.upgrade -/// [`Option`]: ../../std/option/enum.Option.html -/// [`None`]: ../../std/option/enum.Option.html#variant.None +/// [`upgrade`]: Weak::upgrade #[stable(feature = "arc_weak", since = "1.4.0")] pub struct Weak { // This is a `NonNull` to allow optimizing the size of this type in enums, @@ -396,13 +387,11 @@ impl Arc { /// Returns the inner value, if the `Arc` has exactly one strong reference. /// - /// Otherwise, an [`Err`][result] is returned with the same `Arc` that was + /// Otherwise, an [`Err`][Result] is returned with the same `Arc` that was /// passed in. /// /// This will succeed even if there are outstanding weak references. /// - /// [result]: ../../std/result/enum.Result.html - /// /// # Examples /// /// ``` @@ -550,9 +539,7 @@ impl Arc { /// Consumes the `Arc`, returning the wrapped pointer. /// /// To avoid a memory leak the pointer must be converted back to an `Arc` using - /// [`Arc::from_raw`][from_raw]. - /// - /// [from_raw]: struct.Arc.html#method.from_raw + /// [`Arc::from_raw`]. /// /// # Examples /// @@ -612,8 +599,8 @@ impl Arc { /// This function is unsafe because improper use may lead to memory unsafety, /// even if the returned `Arc` is never accessed. /// - /// [into_raw]: struct.Arc.html#method.into_raw - /// [transmute]: ../../std/mem/fn.transmute.html + /// [into_raw]: Arc::into_raw + /// [transmute]: core::mem::transmute /// /// # Examples /// @@ -646,9 +633,7 @@ impl Arc { } } - /// Creates a new [`Weak`][weak] pointer to this allocation. - /// - /// [weak]: struct.Weak.html + /// Creates a new [`Weak`] pointer to this allocation. /// /// # Examples /// @@ -690,9 +675,7 @@ impl Arc { } } - /// Gets the number of [`Weak`][weak] pointers to this allocation. - /// - /// [weak]: struct.Weak.html + /// Gets the number of [`Weak`] pointers to this allocation. /// /// # Safety /// @@ -861,7 +844,7 @@ impl Arc { /// assert!(!Arc::ptr_eq(&five, &other_five)); /// ``` /// - /// [`ptr::eq`]: ../../std/ptr/fn.eq.html + /// [`ptr::eq`]: core::ptr::eq pub fn ptr_eq(this: &Self, other: &Self) -> bool { this.ptr.as_ptr() == other.ptr.as_ptr() } @@ -1098,7 +1081,7 @@ impl Receiver for Arc {} impl Arc { /// Makes a mutable reference into the given `Arc`. /// - /// If there are other `Arc` or [`Weak`][weak] pointers to the same allocation, + /// If there are other `Arc` or [`Weak`] pointers to the same allocation, /// then `make_mut` will create a new allocation and invoke [`clone`][clone] on the inner value /// to ensure unique ownership. This is also referred to as clone-on-write. /// @@ -1107,10 +1090,9 @@ impl Arc { /// /// See also [`get_mut`][get_mut], which will fail rather than cloning. /// - /// [weak]: struct.Weak.html - /// [clone]: ../../std/clone/trait.Clone.html#tymethod.clone - /// [get_mut]: struct.Arc.html#method.get_mut - /// [`Rc::make_mut`]: ../rc/struct.Rc.html#method.make_mut + /// [clone]: Clone::clone + /// [get_mut]: Arc::get_mut + /// [`Rc::make_mut`]: super::rc::Rc::make_mut /// /// # Examples /// @@ -1184,18 +1166,16 @@ impl Arc { impl Arc { /// Returns a mutable reference into the given `Arc`, if there are - /// no other `Arc` or [`Weak`][weak] pointers to the same allocation. + /// no other `Arc` or [`Weak`] pointers to the same allocation. /// - /// Returns [`None`][option] otherwise, because it is not safe to + /// Returns [`None`][Option] otherwise, because it is not safe to /// mutate a shared value. /// /// See also [`make_mut`][make_mut], which will [`clone`][clone] /// the inner value when there are other pointers. /// - /// [weak]: struct.Weak.html - /// [option]: ../../std/option/enum.Option.html - /// [make_mut]: struct.Arc.html#method.make_mut - /// [clone]: ../../std/clone/trait.Clone.html#tymethod.clone + /// [make_mut]: Arc::make_mut + /// [clone]: Clone::clone /// /// # Examples /// @@ -1229,7 +1209,7 @@ impl Arc { /// /// See also [`get_mut`], which is safe and does appropriate checks. /// - /// [`get_mut`]: struct.Arc.html#method.get_mut + /// [`get_mut`]: Arc::get_mut /// /// # Safety /// @@ -1315,8 +1295,6 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc { /// drop(foo); // Doesn't print anything /// drop(foo2); // Prints "dropped!" /// ``` - /// - /// [`Weak`]: ../../std/sync/struct.Weak.html #[inline] fn drop(&mut self) { // Because `fetch_sub` is already atomic, we do not need to synchronize @@ -1401,8 +1379,7 @@ impl Weak { /// Constructs a new `Weak`, without allocating any memory. /// Calling [`upgrade`] on the return value always gives [`None`]. /// - /// [`upgrade`]: struct.Weak.html#method.upgrade - /// [`None`]: ../../std/option/enum.Option.html#variant.None + /// [`upgrade`]: Weak::upgrade /// /// # Examples /// @@ -1441,7 +1418,7 @@ impl Weak { /// // assert_eq!("hello", unsafe { &*weak.as_ptr() }); /// ``` /// - /// [`null`]: ../../std/ptr/fn.null.html + /// [`null`]: core::ptr::null #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn as_ptr(&self) -> *const T { let ptr: *mut ArcInner = NonNull::as_ptr(self.ptr); @@ -1483,8 +1460,8 @@ impl Weak { /// assert_eq!(0, Arc::weak_count(&strong)); /// ``` /// - /// [`from_raw`]: struct.Weak.html#method.from_raw - /// [`as_ptr`]: struct.Weak.html#method.as_ptr + /// [`from_raw`]: Weak::from_raw + /// [`as_ptr`]: Weak::as_ptr #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn into_raw(self) -> *const T { let result = self.as_ptr(); @@ -1530,12 +1507,10 @@ impl Weak { /// assert!(unsafe { Weak::from_raw(raw_2) }.upgrade().is_none()); /// ``` /// - /// [`new`]: struct.Weak.html#method.new - /// [`into_raw`]: struct.Weak.html#method.into_raw - /// [`upgrade`]: struct.Weak.html#method.upgrade - /// [`Weak`]: struct.Weak.html - /// [`Arc`]: struct.Arc.html - /// [`forget`]: ../../std/mem/fn.forget.html + /// [`new`]: Weak::new + /// [`into_raw`]: Weak::into_raw + /// [`upgrade`]: Weak::upgrade + /// [`forget`]: std::mem::forget #[stable(feature = "weak_into_raw", since = "1.45.0")] pub unsafe fn from_raw(ptr: *const T) -> Self { if ptr.is_null() { @@ -1565,9 +1540,6 @@ impl Weak { /// /// Returns [`None`] if the inner value has since been dropped. /// - /// [`Arc`]: struct.Arc.html - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// /// # Examples /// /// ``` @@ -1619,8 +1591,6 @@ impl Weak { /// Gets the number of strong (`Arc`) pointers pointing to this allocation. /// /// If `self` was created using [`Weak::new`], this will return 0. - /// - /// [`Weak::new`]: #method.new #[stable(feature = "weak_counts", since = "1.41.0")] pub fn strong_count(&self) -> usize { if let Some(inner) = self.inner() { inner.strong.load(SeqCst) } else { 0 } @@ -1637,8 +1607,6 @@ impl Weak { /// Due to implementation details, the returned value can be off by 1 in /// either direction when other threads are manipulating any `Arc`s or /// `Weak`s pointing to the same allocation. - /// - /// [`Weak::new`]: #method.new #[stable(feature = "weak_counts", since = "1.41.0")] pub fn weak_count(&self) -> usize { self.inner() @@ -1716,7 +1684,7 @@ impl Weak { /// assert!(!first.ptr_eq(&third)); /// ``` /// - /// [`ptr::eq`]: ../../std/ptr/fn.eq.html + /// [`ptr::eq`]: core::ptr::eq #[inline] #[stable(feature = "weak_ptr_eq", since = "1.39.0")] pub fn ptr_eq(&self, other: &Self) -> bool { @@ -1765,8 +1733,7 @@ impl Default for Weak { /// Calling [`upgrade`] on the return value always /// gives [`None`]. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// [`upgrade`]: ../../std/sync/struct.Weak.html#method.upgrade + /// [`upgrade`]: Weak::upgrade /// /// # Examples /// From 6fca004ba9645b2c1d4a51ddbbac0c89dd2133d5 Mon Sep 17 00:00:00 2001 From: "Dr. Koutheir Attouchi" Date: Thu, 20 Aug 2020 18:54:40 -0400 Subject: [PATCH 24/44] Another motivation for CFG: return-oriented programming --- src/doc/unstable-book/src/compiler-flags/control-flow-guard.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md b/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md index 4115825e92083..8f53f69b5c555 100644 --- a/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md +++ b/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md @@ -19,8 +19,9 @@ CFG functionality is completely implemented in the LLVM backend and is supported ## When to use Control Flow Guard -The primary motivation for enabling CFG in Rust is to enhance security when linking against non-Rust code, especially C/C++ code. To achieve full CFG protection, all indirect calls (including any from Rust code) must have the appropriate CFG checks, as added by this flag. CFG can also improve security for Rust code that uses the `unsafe` keyword +The primary motivation for enabling CFG in Rust is to enhance security when linking against non-Rust code, especially C/C++ code. To achieve full CFG protection, all indirect calls (including any from Rust code) must have the appropriate CFG checks, as added by this flag. CFG can also improve security for Rust code that uses the `unsafe` keyword. +Another motivation behind CFG is to harden programs against [return-oriented programming (ROP)](https://en.m.wikipedia.org/wiki/Return-oriented_programming) attacks. CFG disallows an attacker from taking advantage of the programs own instructions while redirecting control flow in unexpected ways. ## Overhead of Control Flow Guard From 3b995ccc3f3b8e13af53f4bfc7bff072ee77169a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Fri, 21 Aug 2020 00:00:00 +0000 Subject: [PATCH 25/44] Extend normalization in const-eval-query-stack test Builds with debuginfo have additional information in backtrace. --- src/test/ui/consts/const-eval/const-eval-query-stack.rs | 3 ++- src/test/ui/consts/const-eval/const-eval-query-stack.stderr | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.rs b/src/test/ui/consts/const-eval/const-eval-query-stack.rs index 6962ccdec73ee..8a6f7de1c9fbd 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.rs +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.rs @@ -9,7 +9,8 @@ // normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" // normalize-stderr-test "thread.*panicked.*\n" -> "" // normalize-stderr-test "stack backtrace:\n" -> "" -// normalize-stderr-test " \d{1,}: .*\n" -> "" +// normalize-stderr-test "\s\d{1,}: .*\n" -> "" +// normalize-stderr-test "\s at .*\n" -> "" // normalize-stderr-test ".*note: Some details.*\n" -> "" #![allow(unconditional_panic)] diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr index 32233a0f6eeb7..dc2661ee79685 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr @@ -1,5 +1,5 @@ error: reaching this expression at runtime will panic or abort - --> $DIR/const-eval-query-stack.rs:18:28 + --> $DIR/const-eval-query-stack.rs:19:28 | LL | let x: &'static i32 = &(1 / 0); | -^^^^^^^ From 5673b0e49219291acfb1c52f0c3119d266ef5ce9 Mon Sep 17 00:00:00 2001 From: "Dr. Koutheir Attouchi" Date: Fri, 21 Aug 2020 03:34:25 -0400 Subject: [PATCH 26/44] Switched ROP link to Desktop layout instead of mobile layout --- src/doc/unstable-book/src/compiler-flags/control-flow-guard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md b/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md index 8f53f69b5c555..901c053877d56 100644 --- a/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md +++ b/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md @@ -21,7 +21,7 @@ CFG functionality is completely implemented in the LLVM backend and is supported The primary motivation for enabling CFG in Rust is to enhance security when linking against non-Rust code, especially C/C++ code. To achieve full CFG protection, all indirect calls (including any from Rust code) must have the appropriate CFG checks, as added by this flag. CFG can also improve security for Rust code that uses the `unsafe` keyword. -Another motivation behind CFG is to harden programs against [return-oriented programming (ROP)](https://en.m.wikipedia.org/wiki/Return-oriented_programming) attacks. CFG disallows an attacker from taking advantage of the programs own instructions while redirecting control flow in unexpected ways. +Another motivation behind CFG is to harden programs against [return-oriented programming (ROP)](https://en.wikipedia.org/wiki/Return-oriented_programming) attacks. CFG disallows an attacker from taking advantage of the programs own instructions while redirecting control flow in unexpected ways. ## Overhead of Control Flow Guard From 10a880d20e2593c3e67e38469604a88733586c17 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 21 Aug 2020 09:49:26 +0200 Subject: [PATCH 27/44] Improve wording --- src/doc/rustdoc/src/unstable-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 4e407c19b4128..f45e229506438 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -491,7 +491,7 @@ $ rustdoc src/lib.rs -Z unstable-options --show-coverage --output-format json {"lib.rs":{"total":4,"with_docs":4,"total_examples":4,"with_examples":1}} ``` -To be noted: the computation of code examples follows these rules: +Calculating code examples follows these rules: 1. These items aren't accounted by default: * struct/union field From e6642e41e0e827557dce08a3c0522e93c751e39c Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Wed, 19 Aug 2020 19:07:03 +0200 Subject: [PATCH 28/44] astconv: Split astconv.rs into its own module with submodules To separate the astconv.rs file, I split it into its own module with a subtrait called GenericAstConv. This subtrait handles methods related to generics, be it types or lifetimes. typeck: Add bounds module and Bounds struct bounds: Run fmt, add documentation generic_astconv: Add subtrait GenericAstConv Some methods of AstConv deal exclusively with Generics. Therefore, it makes sense to have them in their own trait. Some other methods from AstConv might be added to it later generic_astconv: Add more methods from AstConv Add check_generic_arg_count_for_call() and check_generic_arg_count() astconv: Add module for clarity generic: Rename GenericAstConv -> AstConvGeneric generic: add more methods to AstConvGeneric astconv: Remove AstConvGeneric trait, add impl dyn AstConv in other module astconv: Add errors module to handle AstConv complaints fmt: format code in astconv/ astconv: Remove old file astconv: Fix visibility on GenericArgPosition astconv: Fix visibility on GenericArgPosition astconv: Fix function visibility on other originally private functions --- src/librustc_typeck/astconv/errors.rs | 388 ++++++ src/librustc_typeck/astconv/generics.rs | 596 +++++++++ .../{astconv.rs => astconv/mod.rs} | 1071 +---------------- src/librustc_typeck/bounds.rs | 93 ++ src/librustc_typeck/collect.rs | 3 +- src/librustc_typeck/lib.rs | 4 +- 6 files changed, 1096 insertions(+), 1059 deletions(-) create mode 100644 src/librustc_typeck/astconv/errors.rs create mode 100644 src/librustc_typeck/astconv/generics.rs rename src/librustc_typeck/{astconv.rs => astconv/mod.rs} (65%) create mode 100644 src/librustc_typeck/bounds.rs diff --git a/src/librustc_typeck/astconv/errors.rs b/src/librustc_typeck/astconv/errors.rs new file mode 100644 index 0000000000000..685243f54cb90 --- /dev/null +++ b/src/librustc_typeck/astconv/errors.rs @@ -0,0 +1,388 @@ +use crate::astconv::AstConv; +use rustc_ast::util::lev_distance::find_best_match_for_name; +use rustc_data_structures::fx::FxHashMap; +use rustc_errors::{pluralize, struct_span_err, Applicability}; +use rustc_hir as hir; +use rustc_hir::def_id::DefId; +use rustc_middle::ty; +use rustc_session::parse::feature_err; +use rustc_span::symbol::{sym, Ident}; +use rustc_span::{Span, DUMMY_SP}; + +use std::collections::BTreeSet; + +impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { + /// On missing type parameters, emit an E0393 error and provide a structured suggestion using + /// the type parameter's name as a placeholder. + pub(crate) fn complain_about_missing_type_params( + &self, + missing_type_params: Vec, + def_id: DefId, + span: Span, + empty_generic_args: bool, + ) { + if missing_type_params.is_empty() { + return; + } + let display = + missing_type_params.iter().map(|n| format!("`{}`", n)).collect::>().join(", "); + let mut err = struct_span_err!( + self.tcx().sess, + span, + E0393, + "the type parameter{} {} must be explicitly specified", + pluralize!(missing_type_params.len()), + display, + ); + err.span_label( + self.tcx().def_span(def_id), + &format!( + "type parameter{} {} must be specified for this", + pluralize!(missing_type_params.len()), + display, + ), + ); + let mut suggested = false; + if let (Ok(snippet), true) = ( + self.tcx().sess.source_map().span_to_snippet(span), + // Don't suggest setting the type params if there are some already: the order is + // tricky to get right and the user will already know what the syntax is. + empty_generic_args, + ) { + if snippet.ends_with('>') { + // The user wrote `Trait<'a, T>` or similar. To provide an accurate suggestion + // we would have to preserve the right order. For now, as clearly the user is + // aware of the syntax, we do nothing. + } else { + // The user wrote `Iterator`, so we don't have a type we can suggest, but at + // least we can clue them to the correct syntax `Iterator`. + err.span_suggestion( + span, + &format!( + "set the type parameter{plural} to the desired type{plural}", + plural = pluralize!(missing_type_params.len()), + ), + format!("{}<{}>", snippet, missing_type_params.join(", ")), + Applicability::HasPlaceholders, + ); + suggested = true; + } + } + if !suggested { + err.span_label( + span, + format!( + "missing reference{} to {}", + pluralize!(missing_type_params.len()), + display, + ), + ); + } + err.note( + "because of the default `Self` reference, type parameters must be \ + specified on object types", + ); + err.emit(); + } + + /// When the code is using the `Fn` traits directly, instead of the `Fn(A) -> B` syntax, emit + /// an error and attempt to build a reasonable structured suggestion. + pub(crate) fn complain_about_internal_fn_trait( + &self, + span: Span, + trait_def_id: DefId, + trait_segment: &'a hir::PathSegment<'a>, + ) { + let trait_def = self.tcx().trait_def(trait_def_id); + + if !self.tcx().features().unboxed_closures + && trait_segment.generic_args().parenthesized != trait_def.paren_sugar + { + let sess = &self.tcx().sess.parse_sess; + // For now, require that parenthetical notation be used only with `Fn()` etc. + let (msg, sugg) = if trait_def.paren_sugar { + ( + "the precise format of `Fn`-family traits' type parameters is subject to \ + change", + Some(format!( + "{}{} -> {}", + trait_segment.ident, + trait_segment + .args + .as_ref() + .and_then(|args| args.args.get(0)) + .and_then(|arg| match arg { + hir::GenericArg::Type(ty) => match ty.kind { + hir::TyKind::Tup(t) => t + .iter() + .map(|e| sess.source_map().span_to_snippet(e.span)) + .collect::, _>>() + .map(|a| a.join(", ")), + _ => sess.source_map().span_to_snippet(ty.span), + } + .map(|s| format!("({})", s)) + .ok(), + _ => None, + }) + .unwrap_or_else(|| "()".to_string()), + trait_segment + .generic_args() + .bindings + .iter() + .find_map(|b| match (b.ident.name == sym::Output, &b.kind) { + (true, hir::TypeBindingKind::Equality { ty }) => { + sess.source_map().span_to_snippet(ty.span).ok() + } + _ => None, + }) + .unwrap_or_else(|| "()".to_string()), + )), + ) + } else { + ("parenthetical notation is only stable when used with `Fn`-family traits", None) + }; + let mut err = feature_err(sess, sym::unboxed_closures, span, msg); + if let Some(sugg) = sugg { + let msg = "use parenthetical notation instead"; + err.span_suggestion(span, msg, sugg, Applicability::MaybeIncorrect); + } + err.emit(); + } + } + + pub(crate) fn complain_about_assoc_type_not_found( + &self, + all_candidates: impl Fn() -> I, + ty_param_name: &str, + assoc_name: Ident, + span: Span, + ) where + I: Iterator>, + { + // The fallback span is needed because `assoc_name` might be an `Fn()`'s `Output` without a + // valid span, so we point at the whole path segment instead. + let span = if assoc_name.span != DUMMY_SP { assoc_name.span } else { span }; + let mut err = struct_span_err!( + self.tcx().sess, + span, + E0220, + "associated type `{}` not found for `{}`", + assoc_name, + ty_param_name + ); + + let all_candidate_names: Vec<_> = all_candidates() + .map(|r| self.tcx().associated_items(r.def_id()).in_definition_order()) + .flatten() + .filter_map( + |item| if item.kind == ty::AssocKind::Type { Some(item.ident.name) } else { None }, + ) + .collect(); + + if let (Some(suggested_name), true) = ( + find_best_match_for_name(all_candidate_names.iter(), assoc_name.name, None), + assoc_name.span != DUMMY_SP, + ) { + err.span_suggestion( + assoc_name.span, + "there is an associated type with a similar name", + suggested_name.to_string(), + Applicability::MaybeIncorrect, + ); + } else { + err.span_label(span, format!("associated type `{}` not found", assoc_name)); + } + + err.emit(); + } + + /// When there are any missing associated types, emit an E0191 error and attempt to supply a + /// reasonable suggestion on how to write it. For the case of multiple associated types in the + /// same trait bound have the same name (as they come from different super-traits), we instead + /// emit a generic note suggesting using a `where` clause to constraint instead. + pub(crate) fn complain_about_missing_associated_types( + &self, + associated_types: FxHashMap>, + potential_assoc_types: Vec, + trait_bounds: &[hir::PolyTraitRef<'_>], + ) { + if associated_types.values().all(|v| v.is_empty()) { + return; + } + let tcx = self.tcx(); + // FIXME: Marked `mut` so that we can replace the spans further below with a more + // appropriate one, but this should be handled earlier in the span assignment. + let mut associated_types: FxHashMap> = associated_types + .into_iter() + .map(|(span, def_ids)| { + (span, def_ids.into_iter().map(|did| tcx.associated_item(did)).collect()) + }) + .collect(); + let mut names = vec![]; + + // Account for things like `dyn Foo + 'a`, like in tests `issue-22434.rs` and + // `issue-22560.rs`. + let mut trait_bound_spans: Vec = vec![]; + for (span, items) in &associated_types { + if !items.is_empty() { + trait_bound_spans.push(*span); + } + for assoc_item in items { + let trait_def_id = assoc_item.container.id(); + names.push(format!( + "`{}` (from trait `{}`)", + assoc_item.ident, + tcx.def_path_str(trait_def_id), + )); + } + } + if let ([], [bound]) = (&potential_assoc_types[..], &trait_bounds) { + match &bound.trait_ref.path.segments[..] { + // FIXME: `trait_ref.path.span` can point to a full path with multiple + // segments, even though `trait_ref.path.segments` is of length `1`. Work + // around that bug here, even though it should be fixed elsewhere. + // This would otherwise cause an invalid suggestion. For an example, look at + // `src/test/ui/issues/issue-28344.rs` where instead of the following: + // + // error[E0191]: the value of the associated type `Output` + // (from trait `std::ops::BitXor`) must be specified + // --> $DIR/issue-28344.rs:4:17 + // | + // LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); + // | ^^^^^^ help: specify the associated type: + // | `BitXor` + // + // we would output: + // + // error[E0191]: the value of the associated type `Output` + // (from trait `std::ops::BitXor`) must be specified + // --> $DIR/issue-28344.rs:4:17 + // | + // LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); + // | ^^^^^^^^^^^^^ help: specify the associated type: + // | `BitXor::bitor` + [segment] if segment.args.is_none() => { + trait_bound_spans = vec![segment.ident.span]; + associated_types = associated_types + .into_iter() + .map(|(_, items)| (segment.ident.span, items)) + .collect(); + } + _ => {} + } + } + names.sort(); + trait_bound_spans.sort(); + let mut err = struct_span_err!( + tcx.sess, + trait_bound_spans, + E0191, + "the value of the associated type{} {} must be specified", + pluralize!(names.len()), + names.join(", "), + ); + let mut suggestions = vec![]; + let mut types_count = 0; + let mut where_constraints = vec![]; + for (span, assoc_items) in &associated_types { + let mut names: FxHashMap<_, usize> = FxHashMap::default(); + for item in assoc_items { + types_count += 1; + *names.entry(item.ident.name).or_insert(0) += 1; + } + let mut dupes = false; + for item in assoc_items { + let prefix = if names[&item.ident.name] > 1 { + let trait_def_id = item.container.id(); + dupes = true; + format!("{}::", tcx.def_path_str(trait_def_id)) + } else { + String::new() + }; + if let Some(sp) = tcx.hir().span_if_local(item.def_id) { + err.span_label(sp, format!("`{}{}` defined here", prefix, item.ident)); + } + } + if potential_assoc_types.len() == assoc_items.len() { + // Only suggest when the amount of missing associated types equals the number of + // extra type arguments present, as that gives us a relatively high confidence + // that the user forgot to give the associtated type's name. The canonical + // example would be trying to use `Iterator` instead of + // `Iterator`. + for (potential, item) in potential_assoc_types.iter().zip(assoc_items.iter()) { + if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(*potential) { + suggestions.push((*potential, format!("{} = {}", item.ident, snippet))); + } + } + } else if let (Ok(snippet), false) = + (tcx.sess.source_map().span_to_snippet(*span), dupes) + { + let types: Vec<_> = + assoc_items.iter().map(|item| format!("{} = Type", item.ident)).collect(); + let code = if snippet.ends_with('>') { + // The user wrote `Trait<'a>` or similar and we don't have a type we can + // suggest, but at least we can clue them to the correct syntax + // `Trait<'a, Item = Type>` while accounting for the `<'a>` in the + // suggestion. + format!("{}, {}>", &snippet[..snippet.len() - 1], types.join(", ")) + } else { + // The user wrote `Iterator`, so we don't have a type we can suggest, but at + // least we can clue them to the correct syntax `Iterator`. + format!("{}<{}>", snippet, types.join(", ")) + }; + suggestions.push((*span, code)); + } else if dupes { + where_constraints.push(*span); + } + } + let where_msg = "consider introducing a new type parameter, adding `where` constraints \ + using the fully-qualified path to the associated types"; + if !where_constraints.is_empty() && suggestions.is_empty() { + // If there are duplicates associated type names and a single trait bound do not + // use structured suggestion, it means that there are multiple super-traits with + // the same associated type name. + err.help(where_msg); + } + if suggestions.len() != 1 { + // We don't need this label if there's an inline suggestion, show otherwise. + for (span, assoc_items) in &associated_types { + let mut names: FxHashMap<_, usize> = FxHashMap::default(); + for item in assoc_items { + types_count += 1; + *names.entry(item.ident.name).or_insert(0) += 1; + } + let mut label = vec![]; + for item in assoc_items { + let postfix = if names[&item.ident.name] > 1 { + let trait_def_id = item.container.id(); + format!(" (from trait `{}`)", tcx.def_path_str(trait_def_id)) + } else { + String::new() + }; + label.push(format!("`{}`{}", item.ident, postfix)); + } + if !label.is_empty() { + err.span_label( + *span, + format!( + "associated type{} {} must be specified", + pluralize!(label.len()), + label.join(", "), + ), + ); + } + } + } + if !suggestions.is_empty() { + err.multipart_suggestion( + &format!("specify the associated type{}", pluralize!(types_count)), + suggestions, + Applicability::HasPlaceholders, + ); + if !where_constraints.is_empty() { + err.span_help(where_constraints, where_msg); + } + } + err.emit(); + } +} diff --git a/src/librustc_typeck/astconv/generics.rs b/src/librustc_typeck/astconv/generics.rs new file mode 100644 index 0000000000000..84dab6de95819 --- /dev/null +++ b/src/librustc_typeck/astconv/generics.rs @@ -0,0 +1,596 @@ +use crate::astconv::{ + AstConv, ExplicitLateBound, GenericArgCountMismatch, GenericArgCountResult, GenericArgPosition, +}; +use rustc_ast::ast::ParamKindOrd; +use rustc_errors::{pluralize, struct_span_err, DiagnosticId, ErrorReported}; +use rustc_hir as hir; +use rustc_hir::def_id::DefId; +use rustc_hir::{GenericArg, GenericArgs}; +use rustc_middle::ty::{ + self, subst, subst::SubstsRef, GenericParamDef, GenericParamDefKind, Ty, TyCtxt, +}; +use rustc_session::{lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS, Session}; +use rustc_span::{symbol::kw, MultiSpan, Span}; + +use smallvec::SmallVec; + +impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { + /// Report an error that a generic argument did not match the generic parameter that was + /// expected. + fn generic_arg_mismatch_err( + sess: &Session, + arg: &GenericArg<'_>, + kind: &'static str, + help: Option<&str>, + ) { + let mut err = struct_span_err!( + sess, + arg.span(), + E0747, + "{} provided when a {} was expected", + arg.descr(), + kind, + ); + + let unordered = sess.features_untracked().const_generics; + let kind_ord = match kind { + "lifetime" => ParamKindOrd::Lifetime, + "type" => ParamKindOrd::Type, + "constant" => ParamKindOrd::Const { unordered }, + // It's more concise to match on the string representation, though it means + // the match is non-exhaustive. + _ => bug!("invalid generic parameter kind {}", kind), + }; + let arg_ord = match arg { + GenericArg::Lifetime(_) => ParamKindOrd::Lifetime, + GenericArg::Type(_) => ParamKindOrd::Type, + GenericArg::Const(_) => ParamKindOrd::Const { unordered }, + }; + + // This note is only true when generic parameters are strictly ordered by their kind. + if kind_ord.cmp(&arg_ord) != core::cmp::Ordering::Equal { + let (first, last) = + if kind_ord < arg_ord { (kind, arg.descr()) } else { (arg.descr(), kind) }; + err.note(&format!("{} arguments must be provided before {} arguments", first, last)); + if let Some(help) = help { + err.help(help); + } + } + + err.emit(); + } + + /// Creates the relevant generic argument substitutions + /// corresponding to a set of generic parameters. This is a + /// rather complex function. Let us try to explain the role + /// of each of its parameters: + /// + /// To start, we are given the `def_id` of the thing we are + /// creating the substitutions for, and a partial set of + /// substitutions `parent_substs`. In general, the substitutions + /// for an item begin with substitutions for all the "parents" of + /// that item -- e.g., for a method it might include the + /// parameters from the impl. + /// + /// Therefore, the method begins by walking down these parents, + /// starting with the outermost parent and proceed inwards until + /// it reaches `def_id`. For each parent `P`, it will check `parent_substs` + /// first to see if the parent's substitutions are listed in there. If so, + /// we can append those and move on. Otherwise, it invokes the + /// three callback functions: + /// + /// - `args_for_def_id`: given the `DefId` `P`, supplies back the + /// generic arguments that were given to that parent from within + /// the path; so e.g., if you have `::Bar`, the `DefId` + /// might refer to the trait `Foo`, and the arguments might be + /// `[T]`. The boolean value indicates whether to infer values + /// for arguments whose values were not explicitly provided. + /// - `provided_kind`: given the generic parameter and the value from `args_for_def_id`, + /// instantiate a `GenericArg`. + /// - `inferred_kind`: if no parameter was provided, and inference is enabled, then + /// creates a suitable inference variable. + pub fn create_substs_for_generic_args<'b>( + tcx: TyCtxt<'tcx>, + def_id: DefId, + parent_substs: &[subst::GenericArg<'tcx>], + has_self: bool, + self_ty: Option>, + arg_count: GenericArgCountResult, + args_for_def_id: impl Fn(DefId) -> (Option<&'b GenericArgs<'b>>, bool), + mut provided_kind: impl FnMut(&GenericParamDef, &GenericArg<'_>) -> subst::GenericArg<'tcx>, + mut inferred_kind: impl FnMut( + Option<&[subst::GenericArg<'tcx>]>, + &GenericParamDef, + bool, + ) -> subst::GenericArg<'tcx>, + ) -> SubstsRef<'tcx> { + // Collect the segments of the path; we need to substitute arguments + // for parameters throughout the entire path (wherever there are + // generic parameters). + let mut parent_defs = tcx.generics_of(def_id); + let count = parent_defs.count(); + let mut stack = vec![(def_id, parent_defs)]; + while let Some(def_id) = parent_defs.parent { + parent_defs = tcx.generics_of(def_id); + stack.push((def_id, parent_defs)); + } + + // We manually build up the substitution, rather than using convenience + // methods in `subst.rs`, so that we can iterate over the arguments and + // parameters in lock-step linearly, instead of trying to match each pair. + let mut substs: SmallVec<[subst::GenericArg<'tcx>; 8]> = SmallVec::with_capacity(count); + // Iterate over each segment of the path. + while let Some((def_id, defs)) = stack.pop() { + let mut params = defs.params.iter().peekable(); + + // If we have already computed substitutions for parents, we can use those directly. + while let Some(¶m) = params.peek() { + if let Some(&kind) = parent_substs.get(param.index as usize) { + substs.push(kind); + params.next(); + } else { + break; + } + } + + // `Self` is handled first, unless it's been handled in `parent_substs`. + if has_self { + if let Some(¶m) = params.peek() { + if param.index == 0 { + if let GenericParamDefKind::Type { .. } = param.kind { + substs.push( + self_ty + .map(|ty| ty.into()) + .unwrap_or_else(|| inferred_kind(None, param, true)), + ); + params.next(); + } + } + } + } + + // Check whether this segment takes generic arguments and the user has provided any. + let (generic_args, infer_args) = args_for_def_id(def_id); + + let mut args = + generic_args.iter().flat_map(|generic_args| generic_args.args.iter()).peekable(); + + // If we encounter a type or const when we expect a lifetime, we infer the lifetimes. + // If we later encounter a lifetime, we know that the arguments were provided in the + // wrong order. `force_infer_lt` records the type or const that forced lifetimes to be + // inferred, so we can use it for diagnostics later. + let mut force_infer_lt = None; + + loop { + // We're going to iterate through the generic arguments that the user + // provided, matching them with the generic parameters we expect. + // Mismatches can occur as a result of elided lifetimes, or for malformed + // input. We try to handle both sensibly. + match (args.peek(), params.peek()) { + (Some(&arg), Some(¶m)) => { + match (arg, ¶m.kind, arg_count.explicit_late_bound) { + (GenericArg::Lifetime(_), GenericParamDefKind::Lifetime, _) + | (GenericArg::Type(_), GenericParamDefKind::Type { .. }, _) + | (GenericArg::Const(_), GenericParamDefKind::Const, _) => { + substs.push(provided_kind(param, arg)); + args.next(); + params.next(); + } + ( + GenericArg::Type(_) | GenericArg::Const(_), + GenericParamDefKind::Lifetime, + _, + ) => { + // We expected a lifetime argument, but got a type or const + // argument. That means we're inferring the lifetimes. + substs.push(inferred_kind(None, param, infer_args)); + force_infer_lt = Some(arg); + params.next(); + } + (GenericArg::Lifetime(_), _, ExplicitLateBound::Yes) => { + // We've come across a lifetime when we expected something else in + // the presence of explicit late bounds. This is most likely + // due to the presence of the explicit bound so we're just going to + // ignore it. + args.next(); + } + (_, kind, _) => { + // We expected one kind of parameter, but the user provided + // another. This is an error. However, if we already know that + // the arguments don't match up with the parameters, we won't issue + // an additional error, as the user already knows what's wrong. + if arg_count.correct.is_ok() + && arg_count.explicit_late_bound == ExplicitLateBound::No + { + // We're going to iterate over the parameters to sort them out, and + // show that order to the user as a possible order for the parameters + let mut param_types_present = defs + .params + .clone() + .into_iter() + .map(|param| { + ( + match param.kind { + GenericParamDefKind::Lifetime => { + ParamKindOrd::Lifetime + } + GenericParamDefKind::Type { .. } => { + ParamKindOrd::Type + } + GenericParamDefKind::Const => { + ParamKindOrd::Const { + unordered: tcx + .sess + .features_untracked() + .const_generics, + } + } + }, + param, + ) + }) + .collect::>(); + param_types_present.sort_by_key(|(ord, _)| *ord); + let (mut param_types_present, ordered_params): ( + Vec, + Vec, + ) = param_types_present.into_iter().unzip(); + param_types_present.dedup(); + + Self::generic_arg_mismatch_err( + tcx.sess, + arg, + kind.descr(), + Some(&format!( + "reorder the arguments: {}: `<{}>`", + param_types_present + .into_iter() + .map(|ord| format!("{}s", ord.to_string())) + .collect::>() + .join(", then "), + ordered_params + .into_iter() + .filter_map(|param| { + if param.name == kw::SelfUpper { + None + } else { + Some(param.name.to_string()) + } + }) + .collect::>() + .join(", ") + )), + ); + } + + // We've reported the error, but we want to make sure that this + // problem doesn't bubble down and create additional, irrelevant + // errors. In this case, we're simply going to ignore the argument + // and any following arguments. The rest of the parameters will be + // inferred. + while args.next().is_some() {} + } + } + } + + (Some(&arg), None) => { + // We should never be able to reach this point with well-formed input. + // There are three situations in which we can encounter this issue. + // + // 1. The number of arguments is incorrect. In this case, an error + // will already have been emitted, and we can ignore it. + // 2. There are late-bound lifetime parameters present, yet the + // lifetime arguments have also been explicitly specified by the + // user. + // 3. We've inferred some lifetimes, which have been provided later (i.e. + // after a type or const). We want to throw an error in this case. + + if arg_count.correct.is_ok() + && arg_count.explicit_late_bound == ExplicitLateBound::No + { + let kind = arg.descr(); + assert_eq!(kind, "lifetime"); + let provided = + force_infer_lt.expect("lifetimes ought to have been inferred"); + Self::generic_arg_mismatch_err(tcx.sess, provided, kind, None); + } + + break; + } + + (None, Some(¶m)) => { + // If there are fewer arguments than parameters, it means + // we're inferring the remaining arguments. + substs.push(inferred_kind(Some(&substs), param, infer_args)); + params.next(); + } + + (None, None) => break, + } + } + } + + tcx.intern_substs(&substs) + } + + /// Checks that the correct number of generic arguments have been provided. + /// Used specifically for function calls. + pub fn check_generic_arg_count_for_call( + tcx: TyCtxt<'_>, + span: Span, + def: &ty::Generics, + seg: &hir::PathSegment<'_>, + is_method_call: bool, + ) -> GenericArgCountResult { + let empty_args = hir::GenericArgs::none(); + let suppress_mismatch = Self::check_impl_trait(tcx, seg, &def); + Self::check_generic_arg_count( + tcx, + span, + def, + if let Some(ref args) = seg.args { args } else { &empty_args }, + if is_method_call { GenericArgPosition::MethodCall } else { GenericArgPosition::Value }, + def.parent.is_none() && def.has_self, // `has_self` + seg.infer_args || suppress_mismatch, // `infer_args` + ) + } + + /// Checks that the correct number of generic arguments have been provided. + /// This is used both for datatypes and function calls. + pub(crate) fn check_generic_arg_count( + tcx: TyCtxt<'_>, + span: Span, + def: &ty::Generics, + args: &hir::GenericArgs<'_>, + position: GenericArgPosition, + has_self: bool, + infer_args: bool, + ) -> GenericArgCountResult { + // At this stage we are guaranteed that the generic arguments are in the correct order, e.g. + // that lifetimes will proceed types. So it suffices to check the number of each generic + // arguments in order to validate them with respect to the generic parameters. + let param_counts = def.own_counts(); + let arg_counts = args.own_counts(); + let infer_lifetimes = position != GenericArgPosition::Type && arg_counts.lifetimes == 0; + + let mut defaults: ty::GenericParamCount = Default::default(); + for param in &def.params { + match param.kind { + GenericParamDefKind::Lifetime => {} + GenericParamDefKind::Type { has_default, .. } => { + defaults.types += has_default as usize + } + GenericParamDefKind::Const => { + // FIXME(const_generics:defaults) + } + }; + } + + if position != GenericArgPosition::Type && !args.bindings.is_empty() { + Self::prohibit_assoc_ty_binding(tcx, args.bindings[0].span); + } + + let explicit_late_bound = + Self::prohibit_explicit_late_bound_lifetimes(tcx, def, args, position); + + let check_kind_count = |kind, + required, + permitted, + provided, + offset, + unexpected_spans: &mut Vec, + silent| { + debug!( + "check_kind_count: kind: {} required: {} permitted: {} provided: {} offset: {}", + kind, required, permitted, provided, offset + ); + // We enforce the following: `required` <= `provided` <= `permitted`. + // For kinds without defaults (e.g.., lifetimes), `required == permitted`. + // For other kinds (i.e., types), `permitted` may be greater than `required`. + if required <= provided && provided <= permitted { + return Ok(()); + } + + if silent { + return Err(true); + } + + // Unfortunately lifetime and type parameter mismatches are typically styled + // differently in diagnostics, which means we have a few cases to consider here. + let (bound, quantifier) = if required != permitted { + if provided < required { + (required, "at least ") + } else { + // provided > permitted + (permitted, "at most ") + } + } else { + (required, "") + }; + + let (spans, label) = if required == permitted && provided > permitted { + // In the case when the user has provided too many arguments, + // we want to point to the unexpected arguments. + let spans: Vec = args.args[offset + permitted..offset + provided] + .iter() + .map(|arg| arg.span()) + .collect(); + unexpected_spans.extend(spans.clone()); + (spans, format!("unexpected {} argument", kind)) + } else { + ( + vec![span], + format!( + "expected {}{} {} argument{}", + quantifier, + bound, + kind, + pluralize!(bound), + ), + ) + }; + + let mut err = tcx.sess.struct_span_err_with_code( + spans.clone(), + &format!( + "wrong number of {} arguments: expected {}{}, found {}", + kind, quantifier, bound, provided, + ), + DiagnosticId::Error("E0107".into()), + ); + for span in spans { + err.span_label(span, label.as_str()); + } + err.emit(); + + Err(true) + }; + + let mut arg_count_correct = Ok(()); + let mut unexpected_spans = vec![]; + + if !infer_lifetimes || arg_counts.lifetimes > param_counts.lifetimes { + arg_count_correct = check_kind_count( + "lifetime", + param_counts.lifetimes, + param_counts.lifetimes, + arg_counts.lifetimes, + 0, + &mut unexpected_spans, + explicit_late_bound == ExplicitLateBound::Yes, + ) + .and(arg_count_correct); + } + // FIXME(const_generics:defaults) + if !infer_args || arg_counts.consts > param_counts.consts { + arg_count_correct = check_kind_count( + "const", + param_counts.consts, + param_counts.consts, + arg_counts.consts, + arg_counts.lifetimes + arg_counts.types, + &mut unexpected_spans, + false, + ) + .and(arg_count_correct); + } + // Note that type errors are currently be emitted *after* const errors. + if !infer_args || arg_counts.types > param_counts.types - defaults.types - has_self as usize + { + arg_count_correct = check_kind_count( + "type", + param_counts.types - defaults.types - has_self as usize, + param_counts.types - has_self as usize, + arg_counts.types, + arg_counts.lifetimes, + &mut unexpected_spans, + false, + ) + .and(arg_count_correct); + } + + GenericArgCountResult { + explicit_late_bound, + correct: arg_count_correct.map_err(|reported_err| GenericArgCountMismatch { + reported: if reported_err { Some(ErrorReported) } else { None }, + invalid_args: unexpected_spans, + }), + } + } + + /// Report error if there is an explicit type parameter when using `impl Trait`. + pub(crate) fn check_impl_trait( + tcx: TyCtxt<'_>, + seg: &hir::PathSegment<'_>, + generics: &ty::Generics, + ) -> bool { + let explicit = !seg.infer_args; + let impl_trait = generics.params.iter().any(|param| match param.kind { + ty::GenericParamDefKind::Type { + synthetic: Some(hir::SyntheticTyParamKind::ImplTrait), + .. + } => true, + _ => false, + }); + + if explicit && impl_trait { + let spans = seg + .generic_args() + .args + .iter() + .filter_map(|arg| match arg { + GenericArg::Type(_) => Some(arg.span()), + _ => None, + }) + .collect::>(); + + let mut err = struct_span_err! { + tcx.sess, + spans.clone(), + E0632, + "cannot provide explicit generic arguments when `impl Trait` is \ + used in argument position" + }; + + for span in spans { + err.span_label(span, "explicit generic argument not allowed"); + } + + err.emit(); + } + + impl_trait + } + + /// Emits an error regarding forbidden type binding associations + pub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_>, span: Span) { + let mut err = struct_span_err!( + tcx.sess, + span, + E0229, + "associated type bindings are not allowed here" + ); + err.span_label(span, "associated type not allowed here").emit(); + } + + /// Prohibits explicit lifetime arguments if late-bound lifetime parameters + /// are present. This is used both for datatypes and function calls. + pub(crate) fn prohibit_explicit_late_bound_lifetimes( + tcx: TyCtxt<'_>, + def: &ty::Generics, + args: &hir::GenericArgs<'_>, + position: GenericArgPosition, + ) -> ExplicitLateBound { + let param_counts = def.own_counts(); + let arg_counts = args.own_counts(); + let infer_lifetimes = position != GenericArgPosition::Type && arg_counts.lifetimes == 0; + + if infer_lifetimes { + ExplicitLateBound::No + } else if let Some(span_late) = def.has_late_bound_regions { + let msg = "cannot specify lifetime arguments explicitly \ + if late bound lifetime parameters are present"; + let note = "the late bound lifetime parameter is introduced here"; + let span = args.args[0].span(); + if position == GenericArgPosition::Value + && arg_counts.lifetimes != param_counts.lifetimes + { + let mut err = tcx.sess.struct_span_err(span, msg); + err.span_note(span_late, note); + err.emit(); + } else { + let mut multispan = MultiSpan::from_span(span); + multispan.push_span_label(span_late, note.to_string()); + tcx.struct_span_lint_hir( + LATE_BOUND_LIFETIME_ARGUMENTS, + args.args[0].id(), + multispan, + |lint| lint.build(msg).emit(), + ); + } + ExplicitLateBound::Yes + } else { + ExplicitLateBound::No + } + } +} diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv/mod.rs similarity index 65% rename from src/librustc_typeck/astconv.rs rename to src/librustc_typeck/astconv/mod.rs index 86081b150710d..15c19afdb4a20 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv/mod.rs @@ -1,17 +1,17 @@ -// ignore-tidy-filelength FIXME(#67418) Split up this file. //! Conversion from AST representation of types to the `ty.rs` representation. //! The main routine here is `ast_ty_to_ty()`; each use is parameterized by an //! instance of `AstConv`. -// ignore-tidy-filelength +mod errors; +mod generics; +use crate::bounds::Bounds; use crate::collect::PlaceholderHirTyCollector; use crate::middle::resolve_lifetime as rl; use crate::require_c_abi_if_c_variadic; -use rustc_ast::{util::lev_distance::find_best_match_for_name, ParamKindOrd}; +use rustc_ast::util::lev_distance::find_best_match_for_name; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_errors::ErrorReported; -use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId, FatalError}; +use rustc_errors::{struct_span_err, Applicability, ErrorReported, FatalError}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Namespace, Res}; use rustc_hir::def_id::{DefId, LocalDefId}; @@ -19,15 +19,11 @@ use rustc_hir::intravisit::{walk_generics, Visitor as _}; use rustc_hir::lang_items::SizedTraitLangItem; use rustc_hir::{Constness, GenericArg, GenericArgs}; use rustc_middle::ty::subst::{self, InternalSubsts, Subst, SubstsRef}; -use rustc_middle::ty::{ - self, Const, DefIdTree, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness, -}; -use rustc_middle::ty::{GenericParamDef, GenericParamDefKind}; -use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, LATE_BOUND_LIFETIME_ARGUMENTS}; -use rustc_session::parse::feature_err; -use rustc_session::Session; -use rustc_span::symbol::{kw, sym, Ident, Symbol}; -use rustc_span::{MultiSpan, Span, DUMMY_SP}; +use rustc_middle::ty::GenericParamDefKind; +use rustc_middle::ty::{self, Const, DefIdTree, Ty, TyCtxt, TypeFoldable}; +use rustc_session::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS; +use rustc_span::symbol::{Ident, Symbol}; +use rustc_span::{Span, DUMMY_SP}; use rustc_target::spec::abi; use rustc_trait_selection::traits; use rustc_trait_selection::traits::astconv_object_safety_violations; @@ -138,8 +134,10 @@ pub enum ExplicitLateBound { No, } +/// Denotes the "position" of a generic argument, indicating if it is a generic type, +/// generic function or generic method call. #[derive(Copy, Clone, PartialEq)] -enum GenericArgPosition { +pub(crate) enum GenericArgPosition { Type, Value, // e.g., functions MethodCall, @@ -243,533 +241,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { substs } - /// Report error if there is an explicit type parameter when using `impl Trait`. - fn check_impl_trait( - tcx: TyCtxt<'_>, - seg: &hir::PathSegment<'_>, - generics: &ty::Generics, - ) -> bool { - let explicit = !seg.infer_args; - let impl_trait = generics.params.iter().any(|param| match param.kind { - ty::GenericParamDefKind::Type { - synthetic: Some(hir::SyntheticTyParamKind::ImplTrait), - .. - } => true, - _ => false, - }); - - if explicit && impl_trait { - let spans = seg - .generic_args() - .args - .iter() - .filter_map(|arg| match arg { - GenericArg::Type(_) => Some(arg.span()), - _ => None, - }) - .collect::>(); - - let mut err = struct_span_err! { - tcx.sess, - spans.clone(), - E0632, - "cannot provide explicit generic arguments when `impl Trait` is \ - used in argument position" - }; - - for span in spans { - err.span_label(span, "explicit generic argument not allowed"); - } - - err.emit(); - } - - impl_trait - } - - /// Checks that the correct number of generic arguments have been provided. - /// Used specifically for function calls. - pub fn check_generic_arg_count_for_call( - tcx: TyCtxt<'_>, - span: Span, - def: &ty::Generics, - seg: &hir::PathSegment<'_>, - is_method_call: bool, - ) -> GenericArgCountResult { - let empty_args = hir::GenericArgs::none(); - let suppress_mismatch = Self::check_impl_trait(tcx, seg, &def); - Self::check_generic_arg_count( - tcx, - span, - def, - if let Some(ref args) = seg.args { args } else { &empty_args }, - if is_method_call { GenericArgPosition::MethodCall } else { GenericArgPosition::Value }, - def.parent.is_none() && def.has_self, // `has_self` - seg.infer_args || suppress_mismatch, // `infer_args` - ) - } - - /// Checks that the correct number of generic arguments have been provided. - /// This is used both for datatypes and function calls. - fn check_generic_arg_count( - tcx: TyCtxt<'_>, - span: Span, - def: &ty::Generics, - args: &hir::GenericArgs<'_>, - position: GenericArgPosition, - has_self: bool, - infer_args: bool, - ) -> GenericArgCountResult { - // At this stage we are guaranteed that the generic arguments are in the correct order, e.g. - // that lifetimes will proceed types. So it suffices to check the number of each generic - // arguments in order to validate them with respect to the generic parameters. - let param_counts = def.own_counts(); - let arg_counts = args.own_counts(); - let infer_lifetimes = position != GenericArgPosition::Type && arg_counts.lifetimes == 0; - - let mut defaults: ty::GenericParamCount = Default::default(); - for param in &def.params { - match param.kind { - GenericParamDefKind::Lifetime => {} - GenericParamDefKind::Type { has_default, .. } => { - defaults.types += has_default as usize - } - GenericParamDefKind::Const => { - // FIXME(const_generics:defaults) - } - }; - } - - if position != GenericArgPosition::Type && !args.bindings.is_empty() { - AstConv::prohibit_assoc_ty_binding(tcx, args.bindings[0].span); - } - - let explicit_late_bound = - Self::prohibit_explicit_late_bound_lifetimes(tcx, def, args, position); - - let check_kind_count = |kind, - required, - permitted, - provided, - offset, - unexpected_spans: &mut Vec, - silent| { - debug!( - "check_kind_count: kind: {} required: {} permitted: {} provided: {} offset: {}", - kind, required, permitted, provided, offset - ); - // We enforce the following: `required` <= `provided` <= `permitted`. - // For kinds without defaults (e.g.., lifetimes), `required == permitted`. - // For other kinds (i.e., types), `permitted` may be greater than `required`. - if required <= provided && provided <= permitted { - return Ok(()); - } - - if silent { - return Err(true); - } - - // Unfortunately lifetime and type parameter mismatches are typically styled - // differently in diagnostics, which means we have a few cases to consider here. - let (bound, quantifier) = if required != permitted { - if provided < required { - (required, "at least ") - } else { - // provided > permitted - (permitted, "at most ") - } - } else { - (required, "") - }; - - let (spans, label) = if required == permitted && provided > permitted { - // In the case when the user has provided too many arguments, - // we want to point to the unexpected arguments. - let spans: Vec = args.args[offset + permitted..offset + provided] - .iter() - .map(|arg| arg.span()) - .collect(); - unexpected_spans.extend(spans.clone()); - (spans, format!("unexpected {} argument", kind)) - } else { - ( - vec![span], - format!( - "expected {}{} {} argument{}", - quantifier, - bound, - kind, - pluralize!(bound), - ), - ) - }; - - let mut err = tcx.sess.struct_span_err_with_code( - spans.clone(), - &format!( - "wrong number of {} arguments: expected {}{}, found {}", - kind, quantifier, bound, provided, - ), - DiagnosticId::Error("E0107".into()), - ); - for span in spans { - err.span_label(span, label.as_str()); - } - err.emit(); - - Err(true) - }; - - let mut arg_count_correct = Ok(()); - let mut unexpected_spans = vec![]; - - if !infer_lifetimes || arg_counts.lifetimes > param_counts.lifetimes { - arg_count_correct = check_kind_count( - "lifetime", - param_counts.lifetimes, - param_counts.lifetimes, - arg_counts.lifetimes, - 0, - &mut unexpected_spans, - explicit_late_bound == ExplicitLateBound::Yes, - ) - .and(arg_count_correct); - } - // FIXME(const_generics:defaults) - if !infer_args || arg_counts.consts > param_counts.consts { - arg_count_correct = check_kind_count( - "const", - param_counts.consts, - param_counts.consts, - arg_counts.consts, - arg_counts.lifetimes + arg_counts.types, - &mut unexpected_spans, - false, - ) - .and(arg_count_correct); - } - // Note that type errors are currently be emitted *after* const errors. - if !infer_args || arg_counts.types > param_counts.types - defaults.types - has_self as usize - { - arg_count_correct = check_kind_count( - "type", - param_counts.types - defaults.types - has_self as usize, - param_counts.types - has_self as usize, - arg_counts.types, - arg_counts.lifetimes, - &mut unexpected_spans, - false, - ) - .and(arg_count_correct); - } - - GenericArgCountResult { - explicit_late_bound, - correct: arg_count_correct.map_err(|reported_err| GenericArgCountMismatch { - reported: if reported_err { Some(ErrorReported) } else { None }, - invalid_args: unexpected_spans, - }), - } - } - - /// Report an error that a generic argument did not match the generic parameter that was - /// expected. - fn generic_arg_mismatch_err( - sess: &Session, - arg: &GenericArg<'_>, - kind: &'static str, - help: Option<&str>, - ) { - let mut err = struct_span_err!( - sess, - arg.span(), - E0747, - "{} provided when a {} was expected", - arg.descr(), - kind, - ); - - let unordered = sess.features_untracked().const_generics; - let kind_ord = match kind { - "lifetime" => ParamKindOrd::Lifetime, - "type" => ParamKindOrd::Type, - "constant" => ParamKindOrd::Const { unordered }, - // It's more concise to match on the string representation, though it means - // the match is non-exhaustive. - _ => bug!("invalid generic parameter kind {}", kind), - }; - let arg_ord = match arg { - GenericArg::Lifetime(_) => ParamKindOrd::Lifetime, - GenericArg::Type(_) => ParamKindOrd::Type, - GenericArg::Const(_) => ParamKindOrd::Const { unordered }, - }; - - // This note is only true when generic parameters are strictly ordered by their kind. - if kind_ord.cmp(&arg_ord) != core::cmp::Ordering::Equal { - let (first, last) = - if kind_ord < arg_ord { (kind, arg.descr()) } else { (arg.descr(), kind) }; - err.note(&format!("{} arguments must be provided before {} arguments", first, last)); - if let Some(help) = help { - err.help(help); - } - } - - err.emit(); - } - - /// Creates the relevant generic argument substitutions - /// corresponding to a set of generic parameters. This is a - /// rather complex function. Let us try to explain the role - /// of each of its parameters: - /// - /// To start, we are given the `def_id` of the thing we are - /// creating the substitutions for, and a partial set of - /// substitutions `parent_substs`. In general, the substitutions - /// for an item begin with substitutions for all the "parents" of - /// that item -- e.g., for a method it might include the - /// parameters from the impl. - /// - /// Therefore, the method begins by walking down these parents, - /// starting with the outermost parent and proceed inwards until - /// it reaches `def_id`. For each parent `P`, it will check `parent_substs` - /// first to see if the parent's substitutions are listed in there. If so, - /// we can append those and move on. Otherwise, it invokes the - /// three callback functions: - /// - /// - `args_for_def_id`: given the `DefId` `P`, supplies back the - /// generic arguments that were given to that parent from within - /// the path; so e.g., if you have `::Bar`, the `DefId` - /// might refer to the trait `Foo`, and the arguments might be - /// `[T]`. The boolean value indicates whether to infer values - /// for arguments whose values were not explicitly provided. - /// - `provided_kind`: given the generic parameter and the value from `args_for_def_id`, - /// instantiate a `GenericArg`. - /// - `inferred_kind`: if no parameter was provided, and inference is enabled, then - /// creates a suitable inference variable. - pub fn create_substs_for_generic_args<'b>( - tcx: TyCtxt<'tcx>, - def_id: DefId, - parent_substs: &[subst::GenericArg<'tcx>], - has_self: bool, - self_ty: Option>, - arg_count: GenericArgCountResult, - args_for_def_id: impl Fn(DefId) -> (Option<&'b GenericArgs<'b>>, bool), - mut provided_kind: impl FnMut(&GenericParamDef, &GenericArg<'_>) -> subst::GenericArg<'tcx>, - mut inferred_kind: impl FnMut( - Option<&[subst::GenericArg<'tcx>]>, - &GenericParamDef, - bool, - ) -> subst::GenericArg<'tcx>, - ) -> SubstsRef<'tcx> { - // Collect the segments of the path; we need to substitute arguments - // for parameters throughout the entire path (wherever there are - // generic parameters). - let mut parent_defs = tcx.generics_of(def_id); - let count = parent_defs.count(); - let mut stack = vec![(def_id, parent_defs)]; - while let Some(def_id) = parent_defs.parent { - parent_defs = tcx.generics_of(def_id); - stack.push((def_id, parent_defs)); - } - - // We manually build up the substitution, rather than using convenience - // methods in `subst.rs`, so that we can iterate over the arguments and - // parameters in lock-step linearly, instead of trying to match each pair. - let mut substs: SmallVec<[subst::GenericArg<'tcx>; 8]> = SmallVec::with_capacity(count); - // Iterate over each segment of the path. - while let Some((def_id, defs)) = stack.pop() { - let mut params = defs.params.iter().peekable(); - - // If we have already computed substitutions for parents, we can use those directly. - while let Some(¶m) = params.peek() { - if let Some(&kind) = parent_substs.get(param.index as usize) { - substs.push(kind); - params.next(); - } else { - break; - } - } - - // `Self` is handled first, unless it's been handled in `parent_substs`. - if has_self { - if let Some(¶m) = params.peek() { - if param.index == 0 { - if let GenericParamDefKind::Type { .. } = param.kind { - substs.push( - self_ty - .map(|ty| ty.into()) - .unwrap_or_else(|| inferred_kind(None, param, true)), - ); - params.next(); - } - } - } - } - - // Check whether this segment takes generic arguments and the user has provided any. - let (generic_args, infer_args) = args_for_def_id(def_id); - - let mut args = - generic_args.iter().flat_map(|generic_args| generic_args.args.iter()).peekable(); - - // If we encounter a type or const when we expect a lifetime, we infer the lifetimes. - // If we later encounter a lifetime, we know that the arguments were provided in the - // wrong order. `force_infer_lt` records the type or const that forced lifetimes to be - // inferred, so we can use it for diagnostics later. - let mut force_infer_lt = None; - - loop { - // We're going to iterate through the generic arguments that the user - // provided, matching them with the generic parameters we expect. - // Mismatches can occur as a result of elided lifetimes, or for malformed - // input. We try to handle both sensibly. - match (args.peek(), params.peek()) { - (Some(&arg), Some(¶m)) => { - match (arg, ¶m.kind, arg_count.explicit_late_bound) { - (GenericArg::Lifetime(_), GenericParamDefKind::Lifetime, _) - | (GenericArg::Type(_), GenericParamDefKind::Type { .. }, _) - | (GenericArg::Const(_), GenericParamDefKind::Const, _) => { - substs.push(provided_kind(param, arg)); - args.next(); - params.next(); - } - ( - GenericArg::Type(_) | GenericArg::Const(_), - GenericParamDefKind::Lifetime, - _, - ) => { - // We expected a lifetime argument, but got a type or const - // argument. That means we're inferring the lifetimes. - substs.push(inferred_kind(None, param, infer_args)); - force_infer_lt = Some(arg); - params.next(); - } - (GenericArg::Lifetime(_), _, ExplicitLateBound::Yes) => { - // We've come across a lifetime when we expected something else in - // the presence of explicit late bounds. This is most likely - // due to the presence of the explicit bound so we're just going to - // ignore it. - args.next(); - } - (_, kind, _) => { - // We expected one kind of parameter, but the user provided - // another. This is an error. However, if we already know that - // the arguments don't match up with the parameters, we won't issue - // an additional error, as the user already knows what's wrong. - if arg_count.correct.is_ok() - && arg_count.explicit_late_bound == ExplicitLateBound::No - { - // We're going to iterate over the parameters to sort them out, and - // show that order to the user as a possible order for the parameters - let mut param_types_present = defs - .params - .clone() - .into_iter() - .map(|param| { - ( - match param.kind { - GenericParamDefKind::Lifetime => { - ParamKindOrd::Lifetime - } - GenericParamDefKind::Type { .. } => { - ParamKindOrd::Type - } - GenericParamDefKind::Const => { - ParamKindOrd::Const { - unordered: tcx - .sess - .features_untracked() - .const_generics, - } - } - }, - param, - ) - }) - .collect::>(); - param_types_present.sort_by_key(|(ord, _)| *ord); - let (mut param_types_present, ordered_params): ( - Vec, - Vec, - ) = param_types_present.into_iter().unzip(); - param_types_present.dedup(); - - Self::generic_arg_mismatch_err( - tcx.sess, - arg, - kind.descr(), - Some(&format!( - "reorder the arguments: {}: `<{}>`", - param_types_present - .into_iter() - .map(|ord| format!("{}s", ord.to_string())) - .collect::>() - .join(", then "), - ordered_params - .into_iter() - .filter_map(|param| { - if param.name == kw::SelfUpper { - None - } else { - Some(param.name.to_string()) - } - }) - .collect::>() - .join(", ") - )), - ); - } - - // We've reported the error, but we want to make sure that this - // problem doesn't bubble down and create additional, irrelevant - // errors. In this case, we're simply going to ignore the argument - // and any following arguments. The rest of the parameters will be - // inferred. - while args.next().is_some() {} - } - } - } - - (Some(&arg), None) => { - // We should never be able to reach this point with well-formed input. - // There are three situations in which we can encounter this issue. - // - // 1. The number of arguments is incorrect. In this case, an error - // will already have been emitted, and we can ignore it. - // 2. There are late-bound lifetime parameters present, yet the - // lifetime arguments have also been explicitly specified by the - // user. - // 3. We've inferred some lifetimes, which have been provided later (i.e. - // after a type or const). We want to throw an error in this case. - - if arg_count.correct.is_ok() - && arg_count.explicit_late_bound == ExplicitLateBound::No - { - let kind = arg.descr(); - assert_eq!(kind, "lifetime"); - let provided = - force_infer_lt.expect("lifetimes ought to have been inferred"); - Self::generic_arg_mismatch_err(tcx.sess, provided, kind, None); - } - - break; - } - - (None, Some(¶m)) => { - // If there are fewer arguments than parameters, it means - // we're inferring the remaining arguments. - substs.push(inferred_kind(Some(&substs), param, infer_args)); - params.next(); - } - - (None, None) => break, - } - } - } - - tcx.intern_substs(&substs) - } - /// Given the type/lifetime/const arguments provided to some path (along with /// an implicit `Self`, if this is a trait reference), returns the complete /// set of substitutions. This may involve applying defaulted type parameters. @@ -1023,79 +494,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } } - /// On missing type parameters, emit an E0393 error and provide a structured suggestion using - /// the type parameter's name as a placeholder. - fn complain_about_missing_type_params( - &self, - missing_type_params: Vec, - def_id: DefId, - span: Span, - empty_generic_args: bool, - ) { - if missing_type_params.is_empty() { - return; - } - let display = - missing_type_params.iter().map(|n| format!("`{}`", n)).collect::>().join(", "); - let mut err = struct_span_err!( - self.tcx().sess, - span, - E0393, - "the type parameter{} {} must be explicitly specified", - pluralize!(missing_type_params.len()), - display, - ); - err.span_label( - self.tcx().def_span(def_id), - &format!( - "type parameter{} {} must be specified for this", - pluralize!(missing_type_params.len()), - display, - ), - ); - let mut suggested = false; - if let (Ok(snippet), true) = ( - self.tcx().sess.source_map().span_to_snippet(span), - // Don't suggest setting the type params if there are some already: the order is - // tricky to get right and the user will already know what the syntax is. - empty_generic_args, - ) { - if snippet.ends_with('>') { - // The user wrote `Trait<'a, T>` or similar. To provide an accurate suggestion - // we would have to preserve the right order. For now, as clearly the user is - // aware of the syntax, we do nothing. - } else { - // The user wrote `Iterator`, so we don't have a type we can suggest, but at - // least we can clue them to the correct syntax `Iterator`. - err.span_suggestion( - span, - &format!( - "set the type parameter{plural} to the desired type{plural}", - plural = pluralize!(missing_type_params.len()), - ), - format!("{}<{}>", snippet, missing_type_params.join(", ")), - Applicability::HasPlaceholders, - ); - suggested = true; - } - } - if !suggested { - err.span_label( - span, - format!( - "missing reference{} to {}", - pluralize!(missing_type_params.len()), - display, - ), - ); - } - err.note( - "because of the default `Self` reference, type parameters must be \ - specified on object types", - ); - err.emit(); - } - /// Instantiates the path for the given trait reference, assuming that it's /// bound to a valid trait type. Returns the `DefId` of the defining trait. /// The type _cannot_ be a type other than a trait type. @@ -1242,76 +640,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let (substs, assoc_bindings, _) = self.create_substs_for_ast_trait_ref(span, trait_def_id, self_ty, trait_segment); if let Some(b) = assoc_bindings.first() { - AstConv::prohibit_assoc_ty_binding(self.tcx(), b.span); + Self::prohibit_assoc_ty_binding(self.tcx(), b.span); } ty::TraitRef::new(trait_def_id, substs) } - /// When the code is using the `Fn` traits directly, instead of the `Fn(A) -> B` syntax, emit - /// an error and attempt to build a reasonable structured suggestion. - fn complain_about_internal_fn_trait( - &self, - span: Span, - trait_def_id: DefId, - trait_segment: &'a hir::PathSegment<'a>, - ) { - let trait_def = self.tcx().trait_def(trait_def_id); - - if !self.tcx().features().unboxed_closures - && trait_segment.generic_args().parenthesized != trait_def.paren_sugar - { - let sess = &self.tcx().sess.parse_sess; - // For now, require that parenthetical notation be used only with `Fn()` etc. - let (msg, sugg) = if trait_def.paren_sugar { - ( - "the precise format of `Fn`-family traits' type parameters is subject to \ - change", - Some(format!( - "{}{} -> {}", - trait_segment.ident, - trait_segment - .args - .as_ref() - .and_then(|args| args.args.get(0)) - .and_then(|arg| match arg { - hir::GenericArg::Type(ty) => match ty.kind { - hir::TyKind::Tup(t) => t - .iter() - .map(|e| sess.source_map().span_to_snippet(e.span)) - .collect::, _>>() - .map(|a| a.join(", ")), - _ => sess.source_map().span_to_snippet(ty.span), - } - .map(|s| format!("({})", s)) - .ok(), - _ => None, - }) - .unwrap_or_else(|| "()".to_string()), - trait_segment - .generic_args() - .bindings - .iter() - .find_map(|b| match (b.ident.name == sym::Output, &b.kind) { - (true, hir::TypeBindingKind::Equality { ty }) => { - sess.source_map().span_to_snippet(ty.span).ok() - } - _ => None, - }) - .unwrap_or_else(|| "()".to_string()), - )), - ) - } else { - ("parenthetical notation is only stable when used with `Fn`-family traits", None) - }; - let mut err = feature_err(sess, sym::unboxed_closures, span, msg); - if let Some(sugg) = sugg { - let msg = "use parenthetical notation instead"; - err.span_suggestion(span, msg, sugg, Applicability::MaybeIncorrect); - } - err.emit(); - } - } - fn create_substs_for_ast_trait_ref<'a>( &self, span: Span, @@ -1912,196 +1245,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ty } - /// When there are any missing associated types, emit an E0191 error and attempt to supply a - /// reasonable suggestion on how to write it. For the case of multiple associated types in the - /// same trait bound have the same name (as they come from different super-traits), we instead - /// emit a generic note suggesting using a `where` clause to constraint instead. - fn complain_about_missing_associated_types( - &self, - associated_types: FxHashMap>, - potential_assoc_types: Vec, - trait_bounds: &[hir::PolyTraitRef<'_>], - ) { - if associated_types.values().all(|v| v.is_empty()) { - return; - } - let tcx = self.tcx(); - // FIXME: Marked `mut` so that we can replace the spans further below with a more - // appropriate one, but this should be handled earlier in the span assignment. - let mut associated_types: FxHashMap> = associated_types - .into_iter() - .map(|(span, def_ids)| { - (span, def_ids.into_iter().map(|did| tcx.associated_item(did)).collect()) - }) - .collect(); - let mut names = vec![]; - - // Account for things like `dyn Foo + 'a`, like in tests `issue-22434.rs` and - // `issue-22560.rs`. - let mut trait_bound_spans: Vec = vec![]; - for (span, items) in &associated_types { - if !items.is_empty() { - trait_bound_spans.push(*span); - } - for assoc_item in items { - let trait_def_id = assoc_item.container.id(); - names.push(format!( - "`{}` (from trait `{}`)", - assoc_item.ident, - tcx.def_path_str(trait_def_id), - )); - } - } - if let ([], [bound]) = (&potential_assoc_types[..], &trait_bounds) { - match &bound.trait_ref.path.segments[..] { - // FIXME: `trait_ref.path.span` can point to a full path with multiple - // segments, even though `trait_ref.path.segments` is of length `1`. Work - // around that bug here, even though it should be fixed elsewhere. - // This would otherwise cause an invalid suggestion. For an example, look at - // `src/test/ui/issues/issue-28344.rs` where instead of the following: - // - // error[E0191]: the value of the associated type `Output` - // (from trait `std::ops::BitXor`) must be specified - // --> $DIR/issue-28344.rs:4:17 - // | - // LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); - // | ^^^^^^ help: specify the associated type: - // | `BitXor` - // - // we would output: - // - // error[E0191]: the value of the associated type `Output` - // (from trait `std::ops::BitXor`) must be specified - // --> $DIR/issue-28344.rs:4:17 - // | - // LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); - // | ^^^^^^^^^^^^^ help: specify the associated type: - // | `BitXor::bitor` - [segment] if segment.args.is_none() => { - trait_bound_spans = vec![segment.ident.span]; - associated_types = associated_types - .into_iter() - .map(|(_, items)| (segment.ident.span, items)) - .collect(); - } - _ => {} - } - } - names.sort(); - trait_bound_spans.sort(); - let mut err = struct_span_err!( - tcx.sess, - trait_bound_spans, - E0191, - "the value of the associated type{} {} must be specified", - pluralize!(names.len()), - names.join(", "), - ); - let mut suggestions = vec![]; - let mut types_count = 0; - let mut where_constraints = vec![]; - for (span, assoc_items) in &associated_types { - let mut names: FxHashMap<_, usize> = FxHashMap::default(); - for item in assoc_items { - types_count += 1; - *names.entry(item.ident.name).or_insert(0) += 1; - } - let mut dupes = false; - for item in assoc_items { - let prefix = if names[&item.ident.name] > 1 { - let trait_def_id = item.container.id(); - dupes = true; - format!("{}::", tcx.def_path_str(trait_def_id)) - } else { - String::new() - }; - if let Some(sp) = tcx.hir().span_if_local(item.def_id) { - err.span_label(sp, format!("`{}{}` defined here", prefix, item.ident)); - } - } - if potential_assoc_types.len() == assoc_items.len() { - // Only suggest when the amount of missing associated types equals the number of - // extra type arguments present, as that gives us a relatively high confidence - // that the user forgot to give the associtated type's name. The canonical - // example would be trying to use `Iterator` instead of - // `Iterator`. - for (potential, item) in potential_assoc_types.iter().zip(assoc_items.iter()) { - if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(*potential) { - suggestions.push((*potential, format!("{} = {}", item.ident, snippet))); - } - } - } else if let (Ok(snippet), false) = - (tcx.sess.source_map().span_to_snippet(*span), dupes) - { - let types: Vec<_> = - assoc_items.iter().map(|item| format!("{} = Type", item.ident)).collect(); - let code = if snippet.ends_with('>') { - // The user wrote `Trait<'a>` or similar and we don't have a type we can - // suggest, but at least we can clue them to the correct syntax - // `Trait<'a, Item = Type>` while accounting for the `<'a>` in the - // suggestion. - format!("{}, {}>", &snippet[..snippet.len() - 1], types.join(", ")) - } else { - // The user wrote `Iterator`, so we don't have a type we can suggest, but at - // least we can clue them to the correct syntax `Iterator`. - format!("{}<{}>", snippet, types.join(", ")) - }; - suggestions.push((*span, code)); - } else if dupes { - where_constraints.push(*span); - } - } - let where_msg = "consider introducing a new type parameter, adding `where` constraints \ - using the fully-qualified path to the associated types"; - if !where_constraints.is_empty() && suggestions.is_empty() { - // If there are duplicates associated type names and a single trait bound do not - // use structured suggestion, it means that there are multiple super-traits with - // the same associated type name. - err.help(where_msg); - } - if suggestions.len() != 1 { - // We don't need this label if there's an inline suggestion, show otherwise. - for (span, assoc_items) in &associated_types { - let mut names: FxHashMap<_, usize> = FxHashMap::default(); - for item in assoc_items { - types_count += 1; - *names.entry(item.ident.name).or_insert(0) += 1; - } - let mut label = vec![]; - for item in assoc_items { - let postfix = if names[&item.ident.name] > 1 { - let trait_def_id = item.container.id(); - format!(" (from trait `{}`)", tcx.def_path_str(trait_def_id)) - } else { - String::new() - }; - label.push(format!("`{}`{}", item.ident, postfix)); - } - if !label.is_empty() { - err.span_label( - *span, - format!( - "associated type{} {} must be specified", - pluralize!(label.len()), - label.join(", "), - ), - ); - } - } - } - if !suggestions.is_empty() { - err.multipart_suggestion( - &format!("specify the associated type{}", pluralize!(types_count)), - suggestions, - Applicability::HasPlaceholders, - ); - if !where_constraints.is_empty() { - err.span_help(where_constraints, where_msg); - } - } - err.emit(); - } - fn report_ambiguous_associated_type( &self, span: Span, @@ -2289,52 +1432,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { Ok(bound) } - fn complain_about_assoc_type_not_found( - &self, - all_candidates: impl Fn() -> I, - ty_param_name: &str, - assoc_name: Ident, - span: Span, - ) where - I: Iterator>, - { - // The fallback span is needed because `assoc_name` might be an `Fn()`'s `Output` without a - // valid span, so we point at the whole path segment instead. - let span = if assoc_name.span != DUMMY_SP { assoc_name.span } else { span }; - let mut err = struct_span_err!( - self.tcx().sess, - span, - E0220, - "associated type `{}` not found for `{}`", - assoc_name, - ty_param_name - ); - - let all_candidate_names: Vec<_> = all_candidates() - .map(|r| self.tcx().associated_items(r.def_id()).in_definition_order()) - .flatten() - .filter_map( - |item| if item.kind == ty::AssocKind::Type { Some(item.ident.name) } else { None }, - ) - .collect(); - - if let (Some(suggested_name), true) = ( - find_best_match_for_name(all_candidate_names.iter(), assoc_name.name, None), - assoc_name.span != DUMMY_SP, - ) { - err.span_suggestion( - assoc_name.span, - "there is an associated type with a similar name", - suggested_name.to_string(), - Applicability::MaybeIncorrect, - ); - } else { - err.span_label(span, format!("associated type `{}` not found", assoc_name)); - } - - err.emit(); - } - // Create a type from a path to an associated type. // For a path `A::B::C::D`, `qself_ty` and `qself_def` are the type and def for `A::B::C` // and item_segment is the path segment for `D`. We return a type and a def for @@ -2637,57 +1734,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { has_err } - pub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_>, span: Span) { - let mut err = struct_span_err!( - tcx.sess, - span, - E0229, - "associated type bindings are not allowed here" - ); - err.span_label(span, "associated type not allowed here").emit(); - } - - /// Prohibits explicit lifetime arguments if late-bound lifetime parameters - /// are present. This is used both for datatypes and function calls. - fn prohibit_explicit_late_bound_lifetimes( - tcx: TyCtxt<'_>, - def: &ty::Generics, - args: &hir::GenericArgs<'_>, - position: GenericArgPosition, - ) -> ExplicitLateBound { - let param_counts = def.own_counts(); - let arg_counts = args.own_counts(); - let infer_lifetimes = position != GenericArgPosition::Type && arg_counts.lifetimes == 0; - - if infer_lifetimes { - ExplicitLateBound::No - } else if let Some(span_late) = def.has_late_bound_regions { - let msg = "cannot specify lifetime arguments explicitly \ - if late bound lifetime parameters are present"; - let note = "the late bound lifetime parameter is introduced here"; - let span = args.args[0].span(); - if position == GenericArgPosition::Value - && arg_counts.lifetimes != param_counts.lifetimes - { - let mut err = tcx.sess.struct_span_err(span, msg); - err.span_note(span_late, note); - err.emit(); - } else { - let mut multispan = MultiSpan::from_span(span); - multispan.push_span_label(span_late, note.to_string()); - tcx.struct_span_lint_hir( - LATE_BOUND_LIFETIME_ARGUMENTS, - args.args[0].id(), - multispan, - |lint| lint.build(msg).emit(), - ); - } - ExplicitLateBound::Yes - } else { - ExplicitLateBound::No - } - } - // FIXME(eddyb, varkor) handle type paths here too, not just value ones. pub fn def_ids_for_value_path_segments( &self, @@ -3248,92 +2294,3 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { Some(r) } } - -/// Collects together a list of bounds that are applied to some type, -/// after they've been converted into `ty` form (from the HIR -/// representations). These lists of bounds occur in many places in -/// Rust's syntax: -/// -/// ```text -/// trait Foo: Bar + Baz { } -/// ^^^^^^^^^ supertrait list bounding the `Self` type parameter -/// -/// fn foo() { } -/// ^^^^^^^^^ bounding the type parameter `T` -/// -/// impl dyn Bar + Baz -/// ^^^^^^^^^ bounding the forgotten dynamic type -/// ``` -/// -/// Our representation is a bit mixed here -- in some cases, we -/// include the self type (e.g., `trait_bounds`) but in others we do -#[derive(Default, PartialEq, Eq, Clone, Debug)] -pub struct Bounds<'tcx> { - /// A list of region bounds on the (implicit) self type. So if you - /// had `T: 'a + 'b` this might would be a list `['a, 'b]` (but - /// the `T` is not explicitly included). - pub region_bounds: Vec<(ty::Region<'tcx>, Span)>, - - /// A list of trait bounds. So if you had `T: Debug` this would be - /// `T: Debug`. Note that the self-type is explicit here. - pub trait_bounds: Vec<(ty::PolyTraitRef<'tcx>, Span, Constness)>, - - /// A list of projection equality bounds. So if you had `T: - /// Iterator` this would include `::Item => u32`. Note that the self-type is explicit - /// here. - pub projection_bounds: Vec<(ty::PolyProjectionPredicate<'tcx>, Span)>, - - /// `Some` if there is *no* `?Sized` predicate. The `span` - /// is the location in the source of the `T` declaration which can - /// be cited as the source of the `T: Sized` requirement. - pub implicitly_sized: Option, -} - -impl<'tcx> Bounds<'tcx> { - /// Converts a bounds list into a flat set of predicates (like - /// where-clauses). Because some of our bounds listings (e.g., - /// regions) don't include the self-type, you must supply the - /// self-type here (the `param_ty` parameter). - pub fn predicates( - &self, - tcx: TyCtxt<'tcx>, - param_ty: Ty<'tcx>, - ) -> Vec<(ty::Predicate<'tcx>, Span)> { - // If it could be sized, and is, add the `Sized` predicate. - let sized_predicate = self.implicitly_sized.and_then(|span| { - tcx.lang_items().sized_trait().map(|sized| { - let trait_ref = ty::Binder::bind(ty::TraitRef { - def_id: sized, - substs: tcx.mk_substs_trait(param_ty, &[]), - }); - (trait_ref.without_const().to_predicate(tcx), span) - }) - }); - - sized_predicate - .into_iter() - .chain( - self.region_bounds - .iter() - .map(|&(region_bound, span)| { - // Account for the binder being introduced below; no need to shift `param_ty` - // because, at present at least, it either only refers to early-bound regions, - // or it's a generic associated type that deliberately has escaping bound vars. - let region_bound = ty::fold::shift_region(tcx, region_bound, 1); - let outlives = ty::OutlivesPredicate(param_ty, region_bound); - (ty::Binder::bind(outlives).to_predicate(tcx), span) - }) - .chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| { - let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx); - (predicate, span) - })) - .chain( - self.projection_bounds - .iter() - .map(|&(projection, span)| (projection.to_predicate(tcx), span)), - ), - ) - .collect() - } -} diff --git a/src/librustc_typeck/bounds.rs b/src/librustc_typeck/bounds.rs new file mode 100644 index 0000000000000..63295f5faacc9 --- /dev/null +++ b/src/librustc_typeck/bounds.rs @@ -0,0 +1,93 @@ +//! Bounds are restrictions applied to some types after they've been converted into the +//! `ty` form from the HIR. + +use rustc_hir::Constness; +use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, WithConstness}; +use rustc_span::Span; + +/// Collects together a list of type bounds. These lists of bounds occur in many places +/// in Rust's syntax: +/// +/// ```text +/// trait Foo: Bar + Baz { } +/// ^^^^^^^^^ supertrait list bounding the `Self` type parameter +/// +/// fn foo() { } +/// ^^^^^^^^^ bounding the type parameter `T` +/// +/// impl dyn Bar + Baz +/// ^^^^^^^^^ bounding the forgotten dynamic type +/// ``` +/// +/// Our representation is a bit mixed here -- in some cases, we +/// include the self type (e.g., `trait_bounds`) but in others we do not +#[derive(Default, PartialEq, Eq, Clone, Debug)] +pub struct Bounds<'tcx> { + /// A list of region bounds on the (implicit) self type. So if you + /// had `T: 'a + 'b` this might would be a list `['a, 'b]` (but + /// the `T` is not explicitly included). + pub region_bounds: Vec<(ty::Region<'tcx>, Span)>, + + /// A list of trait bounds. So if you had `T: Debug` this would be + /// `T: Debug`. Note that the self-type is explicit here. + pub trait_bounds: Vec<(ty::PolyTraitRef<'tcx>, Span, Constness)>, + + /// A list of projection equality bounds. So if you had `T: + /// Iterator` this would include `::Item => u32`. Note that the self-type is explicit + /// here. + pub projection_bounds: Vec<(ty::PolyProjectionPredicate<'tcx>, Span)>, + + /// `Some` if there is *no* `?Sized` predicate. The `span` + /// is the location in the source of the `T` declaration which can + /// be cited as the source of the `T: Sized` requirement. + pub implicitly_sized: Option, +} + +impl<'tcx> Bounds<'tcx> { + /// Converts a bounds list into a flat set of predicates (like + /// where-clauses). Because some of our bounds listings (e.g., + /// regions) don't include the self-type, you must supply the + /// self-type here (the `param_ty` parameter). + pub fn predicates( + &self, + tcx: TyCtxt<'tcx>, + param_ty: Ty<'tcx>, + ) -> Vec<(ty::Predicate<'tcx>, Span)> { + // If it could be sized, and is, add the `Sized` predicate. + let sized_predicate = self.implicitly_sized.and_then(|span| { + tcx.lang_items().sized_trait().map(|sized| { + let trait_ref = ty::Binder::bind(ty::TraitRef { + def_id: sized, + substs: tcx.mk_substs_trait(param_ty, &[]), + }); + (trait_ref.without_const().to_predicate(tcx), span) + }) + }); + + sized_predicate + .into_iter() + .chain( + self.region_bounds + .iter() + .map(|&(region_bound, span)| { + // Account for the binder being introduced below; no need to shift `param_ty` + // because, at present at least, it either only refers to early-bound regions, + // or it's a generic associated type that deliberately has escaping bound vars. + let region_bound = ty::fold::shift_region(tcx, region_bound, 1); + let outlives = ty::OutlivesPredicate(param_ty, region_bound); + (ty::Binder::bind(outlives).to_predicate(tcx), span) + }) + .chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| { + let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx); + (predicate, span) + })) + .chain( + self.projection_bounds + .iter() + .map(|&(projection, span)| (projection.to_predicate(tcx), span)), + ), + ) + .collect() + } +} diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 7fb4026117be9..9afac60bb5bb7 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -14,7 +14,8 @@ //! At present, however, we do run collection across all items in the //! crate as a kind of pass. This should eventually be factored away. -use crate::astconv::{AstConv, Bounds, SizedByDefault}; +use crate::astconv::{AstConv, SizedByDefault}; +use crate::bounds::Bounds; use crate::check::intrinsic::intrinsic_operation_unsafety; use crate::constrained_generic_params as cgp; use crate::middle::resolve_lifetime as rl; diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 4248253172598..62f92fe7ffa48 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -79,6 +79,7 @@ pub mod check; pub mod expr_use_visitor; mod astconv; +mod bounds; mod check_unused; mod coherence; mod collect; @@ -109,7 +110,8 @@ use rustc_trait_selection::traits::{ use std::iter; -use astconv::{AstConv, Bounds}; +use astconv::AstConv; +use bounds::Bounds; fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) { if decl.c_variadic && !(abi == Abi::C || abi == Abi::Cdecl) { From 35994db6d3426e3f4545e0061cb5046a7979265f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 21 Aug 2020 13:30:39 +0200 Subject: [PATCH 29/44] Minor, remove double nesting of a test module --- src/librustc_lexer/src/tests.rs | 257 +++++++++++++++----------------- 1 file changed, 121 insertions(+), 136 deletions(-) diff --git a/src/librustc_lexer/src/tests.rs b/src/librustc_lexer/src/tests.rs index e6acc26ec2f34..b0209ac2899d6 100644 --- a/src/librustc_lexer/src/tests.rs +++ b/src/librustc_lexer/src/tests.rs @@ -1,137 +1,122 @@ -#[cfg(test)] -mod tests { - use crate::*; - - fn check_raw_str(s: &str, expected_hashes: u16, expected_err: Option) { - let s = &format!("r{}", s); - let mut cursor = Cursor::new(s); - cursor.bump(); - let (n_hashes, err) = cursor.raw_double_quoted_string(0); - assert_eq!(n_hashes, expected_hashes); - assert_eq!(err, expected_err); - } - - #[test] - fn test_naked_raw_str() { - check_raw_str(r#""abc""#, 0, None); - } - - #[test] - fn test_raw_no_start() { - check_raw_str(r##""abc"#"##, 0, None); - } - - #[test] - fn test_too_many_terminators() { - // this error is handled in the parser later - check_raw_str(r###"#"abc"##"###, 1, None); - } - - #[test] - fn test_unterminated() { - check_raw_str( - r#"#"abc"#, - 1, - Some(RawStrError::NoTerminator { - expected: 1, - found: 0, - possible_terminator_offset: None, - }), - ); - check_raw_str( - r###"##"abc"#"###, - 2, - Some(RawStrError::NoTerminator { - expected: 2, - found: 1, - possible_terminator_offset: Some(7), - }), - ); - // We're looking for "# not just any # - check_raw_str( - r###"##"abc#"###, - 2, - Some(RawStrError::NoTerminator { - expected: 2, - found: 0, - possible_terminator_offset: None, - }), - ) - } - - #[test] - fn test_invalid_start() { - check_raw_str(r##"#~"abc"#"##, 1, Some(RawStrError::InvalidStarter { bad_char: '~' })); - } - - #[test] - fn test_unterminated_no_pound() { - // https://github.com/rust-lang/rust/issues/70677 - check_raw_str( - r#"""#, - 0, - Some(RawStrError::NoTerminator { - expected: 0, - found: 0, - possible_terminator_offset: None, - }), - ); - } - - #[test] - fn test_valid_shebang() { - // https://github.com/rust-lang/rust/issues/70528 - let input = "#!/usr/bin/rustrun\nlet x = 5;"; - assert_eq!(strip_shebang(input), Some(18)); - } - - #[test] - fn test_invalid_shebang_valid_rust_syntax() { - // https://github.com/rust-lang/rust/issues/70528 - let input = "#! [bad_attribute]"; - assert_eq!(strip_shebang(input), None); - } - - #[test] - fn test_shebang_second_line() { - // Because shebangs are interpreted by the kernel, they must be on the first line - let input = "\n#!/bin/bash"; - assert_eq!(strip_shebang(input), None); - } - - #[test] - fn test_shebang_space() { - let input = "#! /bin/bash"; - assert_eq!(strip_shebang(input), Some(input.len())); - } - - #[test] - fn test_shebang_empty_shebang() { - let input = "#! \n[attribute(foo)]"; - assert_eq!(strip_shebang(input), None); - } - - #[test] - fn test_invalid_shebang_comment() { - let input = "#!//bin/ami/a/comment\n["; - assert_eq!(strip_shebang(input), None) - } - - #[test] - fn test_invalid_shebang_another_comment() { - let input = "#!/*bin/ami/a/comment*/\n[attribute"; - assert_eq!(strip_shebang(input), None) - } - - #[test] - fn test_shebang_valid_rust_after() { - let input = "#!/*bin/ami/a/comment*/\npub fn main() {}"; - assert_eq!(strip_shebang(input), Some(23)) - } - - #[test] - fn test_shebang_followed_by_attrib() { - let input = "#!/bin/rust-scripts\n#![allow_unused(true)]"; - assert_eq!(strip_shebang(input), Some(19)); - } +use super::*; + +fn check_raw_str(s: &str, expected_hashes: u16, expected_err: Option) { + let s = &format!("r{}", s); + let mut cursor = Cursor::new(s); + cursor.bump(); + let (n_hashes, err) = cursor.raw_double_quoted_string(0); + assert_eq!(n_hashes, expected_hashes); + assert_eq!(err, expected_err); +} + +#[test] +fn test_naked_raw_str() { + check_raw_str(r#""abc""#, 0, None); +} + +#[test] +fn test_raw_no_start() { + check_raw_str(r##""abc"#"##, 0, None); +} + +#[test] +fn test_too_many_terminators() { + // this error is handled in the parser later + check_raw_str(r###"#"abc"##"###, 1, None); +} + +#[test] +fn test_unterminated() { + check_raw_str( + r#"#"abc"#, + 1, + Some(RawStrError::NoTerminator { expected: 1, found: 0, possible_terminator_offset: None }), + ); + check_raw_str( + r###"##"abc"#"###, + 2, + Some(RawStrError::NoTerminator { + expected: 2, + found: 1, + possible_terminator_offset: Some(7), + }), + ); + // We're looking for "# not just any # + check_raw_str( + r###"##"abc#"###, + 2, + Some(RawStrError::NoTerminator { expected: 2, found: 0, possible_terminator_offset: None }), + ) +} + +#[test] +fn test_invalid_start() { + check_raw_str(r##"#~"abc"#"##, 1, Some(RawStrError::InvalidStarter { bad_char: '~' })); +} + +#[test] +fn test_unterminated_no_pound() { + // https://github.com/rust-lang/rust/issues/70677 + check_raw_str( + r#"""#, + 0, + Some(RawStrError::NoTerminator { expected: 0, found: 0, possible_terminator_offset: None }), + ); +} + +#[test] +fn test_valid_shebang() { + // https://github.com/rust-lang/rust/issues/70528 + let input = "#!/usr/bin/rustrun\nlet x = 5;"; + assert_eq!(strip_shebang(input), Some(18)); +} + +#[test] +fn test_invalid_shebang_valid_rust_syntax() { + // https://github.com/rust-lang/rust/issues/70528 + let input = "#! [bad_attribute]"; + assert_eq!(strip_shebang(input), None); +} + +#[test] +fn test_shebang_second_line() { + // Because shebangs are interpreted by the kernel, they must be on the first line + let input = "\n#!/bin/bash"; + assert_eq!(strip_shebang(input), None); +} + +#[test] +fn test_shebang_space() { + let input = "#! /bin/bash"; + assert_eq!(strip_shebang(input), Some(input.len())); +} + +#[test] +fn test_shebang_empty_shebang() { + let input = "#! \n[attribute(foo)]"; + assert_eq!(strip_shebang(input), None); +} + +#[test] +fn test_invalid_shebang_comment() { + let input = "#!//bin/ami/a/comment\n["; + assert_eq!(strip_shebang(input), None) +} + +#[test] +fn test_invalid_shebang_another_comment() { + let input = "#!/*bin/ami/a/comment*/\n[attribute"; + assert_eq!(strip_shebang(input), None) +} + +#[test] +fn test_shebang_valid_rust_after() { + let input = "#!/*bin/ami/a/comment*/\npub fn main() {}"; + assert_eq!(strip_shebang(input), Some(23)) +} + +#[test] +fn test_shebang_followed_by_attrib() { + let input = "#!/bin/rust-scripts\n#![allow_unused(true)]"; + assert_eq!(strip_shebang(input), Some(19)); } From b20b6f8714ceb39d9214940d9c7d2b8513c030fd Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 21 Aug 2020 13:51:03 +0200 Subject: [PATCH 30/44] Ignore more kind of items for doc examples --- src/librustdoc/passes/calculate_doc_coverage.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index fd3179c13fe22..6b653f87de902 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -241,6 +241,10 @@ impl fold::DocFolder for CoverageCalculator { | clean::TypedefItem(_, _) | clean::StaticItem(_) | clean::ConstantItem(_) + | clean::ExternCrateItem(_, _) + | clean::ImportItem(_) + | clean::PrimitiveItem(_) + | clean::KeywordItem(_) ); find_testable_code( &i.attrs.doc_strings.iter().map(|d| d.as_str()).collect::>().join("\n"), From adeedf52435fe893156f93e2771dc66adf02abc9 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 21 Aug 2020 16:43:04 +0200 Subject: [PATCH 31/44] Show line even if there is no code examples --- src/librustdoc/passes/calculate_doc_coverage.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index 6b653f87de902..457359e7a3806 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -27,7 +27,7 @@ fn calculate_doc_coverage(krate: clean::Crate, ctx: &DocContext<'_>) -> clean::C krate } -#[derive(Default, Copy, Clone, Serialize)] +#[derive(Default, Copy, Clone, Serialize, Debug)] struct ItemCount { total: u64, with_docs: u64, @@ -155,14 +155,12 @@ impl CoverageCalculator { print_table_line(); for (file, &count) in &self.items { - if let (Some(percentage), Some(examples_percentage)) = - (count.percentage(), count.examples_percentage()) - { + if let Some(percentage) = count.percentage() { print_table_record( &limit_filename_len(file.to_string()), count, percentage, - examples_percentage, + count.examples_percentage().unwrap_or(0.), ); total += count; From 0bccd9809eb85096a9818df760e986beed068292 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Fri, 21 Aug 2020 18:35:17 +0200 Subject: [PATCH 32/44] Incorporate suggestions from review --- library/core/src/intrinsics.rs | 690 +++++++++++---------------------- 1 file changed, 233 insertions(+), 457 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 95f4db61d3921..da40e2618112b 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -53,10 +53,19 @@ issue = "none" )] #![allow(missing_docs)] +#![allow(unused_imports)] use crate::marker::DiscriminantKind; use crate::mem; +// These imports are used for simplifying intra-doc links +use crate::sync::atomic; +use crate::sync::atomic::Ordering; +use crate::sync::atomic::AtomicU32; +use crate::sync::atomic::AtomicI32; +use crate::sync::atomic::AtomicBool; +use crate::sync::atomic::AtomicIsize; + #[stable(feature = "drop_in_place", since = "1.8.0")] #[rustc_deprecated( reason = "no longer an intrinsic - use `ptr::drop_in_place` directly", @@ -71,710 +80,510 @@ extern "rust-intrinsic" { /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as both the `success` and `failure` parameters. For example, - /// [`AtomicBool::compare_exchange`][compare_exchange]. - /// - /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange + /// [`atomic`] types via the `compare_exchange` method by passing + /// [`Ordering::SeqCst`] as both the `success` and `failure` parameters. + /// For example, [`AtomicBool::compare_exchange`]. pub fn atomic_cxchg(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as both the `success` and `failure` parameters. For example, - /// [`AtomicBool::compare_exchange`][compare_exchange]. - /// - /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange + /// [`atomic`] types via the `compare_exchange` method by passing + /// [`Ordering::Acquire`] as both the `success` and `failure` parameters. + /// For example, [`AtomicBool::compare_exchange`]. pub fn atomic_cxchg_acq(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `success` and - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange`][compare_exchange]. - /// - /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange + /// [`atomic`] types via the `compare_exchange` method by passing + /// [`Ordering::Release`] as the `success` and [`Ordering::Relaxed`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange`]. pub fn atomic_cxchg_rel(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `success` and - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange`][compare_exchange]. - /// - /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange + /// [`atomic`] types via the `compare_exchange` method by passing + /// [`Ordering::AcqRel`] as the `success` and [`Ordering::Acquire`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange`]. pub fn atomic_cxchg_acqrel(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as both the `success` and `failure` parameters. For example, - /// [`AtomicBool::compare_exchange`][compare_exchange]. - /// - /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange + /// [`atomic`] types via the `compare_exchange` method by passing + /// [`Ordering::Relaxed`] as both the `success` and `failure` parameters. + /// For example, [`AtomicBool::compare_exchange`]. pub fn atomic_cxchg_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `success` and - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange`][compare_exchange]. - /// - /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange + /// [`atomic`] types via the `compare_exchange` method by passing + /// [`Ordering::SeqCst`] as the `success` and [`Ordering::Relaxed`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange`]. pub fn atomic_cxchg_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `success` and - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange`][compare_exchange]. - /// - /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange + /// [`atomic`] types via the `compare_exchange` method by passing + /// [`Ordering::SeqCst`] as the `success` and [`Ordering::Acquire`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange`]. pub fn atomic_cxchg_failacq(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `success` and - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange`][compare_exchange]. - /// - /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange + /// [`atomic`] types via the `compare_exchange` method by passing + /// [`Ordering::Acquire`] as the `success` and [`Ordering::Relaxed`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange`]. pub fn atomic_cxchg_acq_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `success` and - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange`][compare_exchange]. - /// - /// [compare_exchange]: crate::sync::atomic::AtomicBool::compare_exchange + /// [`atomic`] types via the `compare_exchange` method by passing + /// [`Ordering::AcqRel`] as the `success` and [`Ordering::Relaxed`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange`]. pub fn atomic_cxchg_acqrel_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as both the `success` and `failure` parameters. For example, - /// [`AtomicBool::compare_exchange_weak`][cew]. - /// - /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak + /// [`atomic`] types via the `compare_exchange_weak` method by passing + /// [`Ordering::SeqCst`] as both the `success` and `failure` parameters. + /// For example, [`AtomicBool::compare_exchange_weak`]. pub fn atomic_cxchgweak(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as both the `success` and `failure` parameters. For example, - /// [`AtomicBool::compare_exchange_weak`][cew]. - /// - /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak + /// [`atomic`] types via the `compare_exchange_weak` method by passing + /// [`Ordering::Acquire`] as both the `success` and `failure` parameters. + /// For example, [`AtomicBool::compare_exchange_weak`]. pub fn atomic_cxchgweak_acq(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `success` and - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange_weak`][cew]. - /// - /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak + /// [`atomic`] types via the `compare_exchange_weak` method by passing + /// [`Ordering::Release`] as the `success` and [`Ordering::Relaxed`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange_weak`]. pub fn atomic_cxchgweak_rel(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `success` and - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange_weak`][cew]. - /// - /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak + /// [`atomic`] types via the `compare_exchange_weak` method by passing + /// [`Ordering::AcqRel`] as the `success` and [`Ordering::Acquire`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange_weak`]. pub fn atomic_cxchgweak_acqrel(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as both the `success` and `failure` parameters. For example, - /// [`AtomicBool::compare_exchange_weak`][cew]. - /// - /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak + /// [`atomic`] types via the `compare_exchange_weak` method by passing + /// [`Ordering::Relaxed`] as both the `success` and `failure` parameters. + /// For example, [`AtomicBool::compare_exchange_weak`]. pub fn atomic_cxchgweak_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `success` and - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange_weak`][cew]. - /// - /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak + /// [`atomic`] types via the `compare_exchange_weak` method by passing + /// [`Ordering::SeqCst`] as the `success` and [`Ordering::Relaxed`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange_weak`]. pub fn atomic_cxchgweak_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `success` and - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange_weak`][cew]. - /// - /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak + /// [`atomic`] types via the `compare_exchange_weak` method by passing + /// [`Ordering::SeqCst`] as the `success` and [`Ordering::Acquire`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange_weak`]. pub fn atomic_cxchgweak_failacq(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `success` and - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange_weak`][cew]. - /// - /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak + /// [`atomic`] types via the `compare_exchange_weak` method by passing + /// [`Ordering::Acquire`] as the `success` and [`Ordering::Relaxed`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange_weak`]. pub fn atomic_cxchgweak_acq_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `success` and - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `failure` parameters. For example, - /// [`AtomicBool::compare_exchange_weak`][cew]. - /// - /// [cew]: crate::sync::atomic::AtomicBool::compare_exchange_weak + /// [`atomic`] types via the `compare_exchange_weak` method by passing + /// [`Ordering::AcqRel`] as the `success` and [`Ordering::Relaxed`] as the + /// `failure` parameters. For example, [`AtomicBool::compare_exchange_weak`]. pub fn atomic_cxchgweak_acqrel_failrelaxed(dst: *mut T, old: T, src: T) -> (T, bool); /// Loads the current value of the pointer. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `load` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicBool::load`](crate::sync::atomic::AtomicBool::load). + /// [`atomic`] types via the `load` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::load`]. pub fn atomic_load(src: *const T) -> T; /// Loads the current value of the pointer. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `load` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicBool::load`](crate::sync::atomic::AtomicBool::load). + /// [`atomic`] types via the `load` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::load`]. pub fn atomic_load_acq(src: *const T) -> T; /// Loads the current value of the pointer. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `load` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicBool::load`](crate::sync::atomic::AtomicBool::load). + /// [`atomic`] types via the `load` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::load`]. pub fn atomic_load_relaxed(src: *const T) -> T; pub fn atomic_load_unordered(src: *const T) -> T; /// Stores the value at the specified memory location. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `store` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicBool::store`](crate::sync::atomic::AtomicBool::store). + /// [`atomic`] types via the `store` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::store`]. pub fn atomic_store(dst: *mut T, val: T); /// Stores the value at the specified memory location. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `store` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicBool::store`](crate::sync::atomic::AtomicBool::store). + /// [`atomic`] types via the `store` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::store`]. pub fn atomic_store_rel(dst: *mut T, val: T); /// Stores the value at the specified memory location. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `store` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicBool::store`](crate::sync::atomic::AtomicBool::store). + /// [`atomic`] types via the `store` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::store`]. pub fn atomic_store_relaxed(dst: *mut T, val: T); pub fn atomic_store_unordered(dst: *mut T, val: T); /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `swap` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicBool::swap`](crate::sync::atomic::AtomicBool::swap). + /// [`atomic`] types via the `swap` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::swap`]. pub fn atomic_xchg(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `swap` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicBool::swap`](crate::sync::atomic::AtomicBool::swap). + /// [`atomic`] types via the `swap` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::swap`]. pub fn atomic_xchg_acq(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `swap` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicBool::swap`](crate::sync::atomic::AtomicBool::swap). + /// [`atomic`] types via the `swap` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::swap`]. pub fn atomic_xchg_rel(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `swap` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `order`. For example, - /// [`AtomicBool::swap`](crate::sync::atomic::AtomicBool::swap). + /// [`atomic`] types via the `swap` method by passing + /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::swap`]. pub fn atomic_xchg_acqrel(dst: *mut T, src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `swap` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicBool::swap`](crate::sync::atomic::AtomicBool::swap). + /// [`atomic`] types via the `swap` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::swap`]. pub fn atomic_xchg_relaxed(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_add` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicIsize::fetch_add`](crate::sync::atomic::AtomicIsize::fetch_add). + /// [`atomic`] types via the `fetch_add` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicIsize::fetch_add`]. pub fn atomic_xadd(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_add` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicIsize::fetch_add`](crate::sync::atomic::AtomicIsize::fetch_add). + /// [`atomic`] types via the `fetch_add` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicIsize::fetch_add`]. pub fn atomic_xadd_acq(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_add` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicIsize::fetch_add`](crate::sync::atomic::AtomicIsize::fetch_add). + /// [`atomic`] types via the `fetch_add` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicIsize::fetch_add`]. pub fn atomic_xadd_rel(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_add` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `order`. For example, - /// [`AtomicIsize::fetch_add`](crate::sync::atomic::AtomicIsize::fetch_add). + /// [`atomic`] types via the `fetch_add` method by passing + /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicIsize::fetch_add`]. pub fn atomic_xadd_acqrel(dst: *mut T, src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_add` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicIsize::fetch_add`](crate::sync::atomic::AtomicIsize::fetch_add). + /// [`atomic`] types via the `fetch_add` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicIsize::fetch_add`]. pub fn atomic_xadd_relaxed(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_sub` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicIsize::fetch_sub`](crate::sync::atomic::AtomicIsize::fetch_sub). + /// [`atomic`] types via the `fetch_sub` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. pub fn atomic_xsub(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_sub` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicIsize::fetch_sub`](crate::sync::atomic::AtomicIsize::fetch_sub). + /// [`atomic`] types via the `fetch_sub` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. pub fn atomic_xsub_acq(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_sub` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicIsize::fetch_sub`](crate::sync::atomic::AtomicIsize::fetch_sub). + /// [`atomic`] types via the `fetch_sub` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. pub fn atomic_xsub_rel(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_sub` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `order`. For example, - /// [`AtomicIsize::fetch_sub`](crate::sync::atomic::AtomicIsize::fetch_sub). + /// [`atomic`] types via the `fetch_sub` method by passing + /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. pub fn atomic_xsub_acqrel(dst: *mut T, src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_sub` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicIsize::fetch_sub`](crate::sync::atomic::AtomicIsize::fetch_sub). + /// [`atomic`] types via the `fetch_sub` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. pub fn atomic_xsub_relaxed(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_and` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicBool::fetch_and`](crate::sync::atomic::AtomicBool::fetch_and). + /// [`atomic`] types via the `fetch_and` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_and`]. pub fn atomic_and(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_and` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicBool::fetch_and`](crate::sync::atomic::AtomicBool::fetch_and). + /// [`atomic`] types via the `fetch_and` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_and`]. pub fn atomic_and_acq(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_and` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicBool::fetch_and`](crate::sync::atomic::AtomicBool::fetch_and). + /// [`atomic`] types via the `fetch_and` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_and`]. pub fn atomic_and_rel(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_and` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `order`. For example, - /// [`AtomicBool::fetch_and`](crate::sync::atomic::AtomicBool::fetch_and). + /// [`atomic`] types via the `fetch_and` method by passing + /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_and`]. pub fn atomic_and_acqrel(dst: *mut T, src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_and` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicBool::fetch_and`](crate::sync::atomic::AtomicBool::fetch_and). + /// [`atomic`] types via the `fetch_and` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_and`]. pub fn atomic_and_relaxed(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicBool::fetch_nand`](crate::sync::atomic::AtomicBool::fetch_nand). + /// [`AtomicBool`] type via the `fetch_nand` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_nand`]. pub fn atomic_nand(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicBool::fetch_nand`](crate::sync::atomic::AtomicBool::fetch_nand). + /// [`AtomicBool`] type via the `fetch_nand` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_nand`]. pub fn atomic_nand_acq(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicBool::fetch_nand`](crate::sync::atomic::AtomicBool::fetch_nand). + /// [`AtomicBool`] type via the `fetch_nand` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_nand`]. pub fn atomic_nand_rel(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `order`. For example, - /// [`AtomicBool::fetch_nand`](crate::sync::atomic::AtomicBool::fetch_nand). + /// [`AtomicBool`] type via the `fetch_nand` method by passing + /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_nand`]. pub fn atomic_nand_acqrel(dst: *mut T, src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicBool::fetch_nand`](crate::sync::atomic::AtomicBool::fetch_nand). + /// [`AtomicBool`] type via the `fetch_nand` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_nand`]. pub fn atomic_nand_relaxed(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_or` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicBool::fetch_or`](crate::sync::atomic::AtomicBool::fetch_or). + /// [`atomic`] types via the `fetch_or` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_or`]. pub fn atomic_or(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_or` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicBool::fetch_or`](crate::sync::atomic::AtomicBool::fetch_or). + /// [`atomic`] types via the `fetch_or` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_or`]. pub fn atomic_or_acq(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_or` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicBool::fetch_or`](crate::sync::atomic::AtomicBool::fetch_or). + /// [`atomic`] types via the `fetch_or` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_or`]. pub fn atomic_or_rel(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_or` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `order`. For example, - /// [`AtomicBool::fetch_or`](crate::sync::atomic::AtomicBool::fetch_or). + /// [`atomic`] types via the `fetch_or` method by passing + /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_or`]. pub fn atomic_or_acqrel(dst: *mut T, src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_or` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicBool::fetch_or`](crate::sync::atomic::AtomicBool::fetch_or). + /// [`atomic`] types via the `fetch_or` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_or`]. pub fn atomic_or_relaxed(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_xor` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicBool::fetch_xor`](crate::sync::atomic::AtomicBool::fetch_xor). + /// [`atomic`] types via the `fetch_xor` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_xor`]. pub fn atomic_xor(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_xor` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicBool::fetch_xor`](crate::sync::atomic::AtomicBool::fetch_xor). + /// [`atomic`] types via the `fetch_xor` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_xor`]. pub fn atomic_xor_acq(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_xor` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicBool::fetch_xor`](crate::sync::atomic::AtomicBool::fetch_xor). + /// [`atomic`] types via the `fetch_xor` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_xor`]. pub fn atomic_xor_rel(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_xor` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `order`. For example, - /// [`AtomicBool::fetch_xor`](crate::sync::atomic::AtomicBool::fetch_xor). + /// [`atomic`] types via the `fetch_xor` method by passing + /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_xor`]. pub fn atomic_xor_acqrel(dst: *mut T, src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` types via the `fetch_xor` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicBool::fetch_xor`](crate::sync::atomic::AtomicBool::fetch_xor). + /// [`atomic`] types via the `fetch_xor` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_xor`]. pub fn atomic_xor_relaxed(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicI32::fetch_max`](crate::sync::atomic::AtomicI32::fetch_max). + /// [`atomic`] signed integer types via the `fetch_max` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicI32::fetch_max`]. pub fn atomic_max(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicI32::fetch_max`](crate::sync::atomic::AtomicI32::fetch_max). + /// [`atomic`] signed integer types via the `fetch_max` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicI32::fetch_max`]. pub fn atomic_max_acq(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicI32::fetch_max`](crate::sync::atomic::AtomicI32::fetch_max). + /// [`atomic`] signed integer types via the `fetch_max` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicI32::fetch_max`]. pub fn atomic_max_rel(dst: *mut T, src: T) -> T; /// Maximum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `order`. For example, - /// [`AtomicI32::fetch_max`](crate::sync::atomic::AtomicI32::fetch_max). + /// [`atomic`] signed integer types via the `fetch_max` method by passing + /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicI32::fetch_max`]. pub fn atomic_max_acqrel(dst: *mut T, src: T) -> T; /// Maximum with the current value. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicI32::fetch_max`](crate::sync::atomic::AtomicI32::fetch_max). + /// [`atomic`] signed integer types via the `fetch_max` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicI32::fetch_max`]. pub fn atomic_max_relaxed(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicI32::fetch_min`](crate::sync::atomic::AtomicI32::fetch_min). + /// [`atomic`] signed integer types via the `fetch_min` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicI32::fetch_min`]. pub fn atomic_min(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicI32::fetch_min`](crate::sync::atomic::AtomicI32::fetch_min). + /// [`atomic`] signed integer types via the `fetch_min` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicI32::fetch_min`]. pub fn atomic_min_acq(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicI32::fetch_min`](crate::sync::atomic::AtomicI32::fetch_min). + /// [`atomic`] signed integer types via the `fetch_min` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicI32::fetch_min`]. pub fn atomic_min_rel(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `order`. For example, - /// [`AtomicI32::fetch_min`](crate::sync::atomic::AtomicI32::fetch_min). + /// [`atomic`] signed integer types via the `fetch_min` method by passing + /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicI32::fetch_min`]. pub fn atomic_min_acqrel(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicI32::fetch_min`](crate::sync::atomic::AtomicI32::fetch_min). + /// [`atomic`] signed integer types via the `fetch_min` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicI32::fetch_min`]. pub fn atomic_min_relaxed(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicU32::fetch_min`](crate::sync::atomic::AtomicU32::fetch_min). + /// [`atomic`] unsigned integer types via the `fetch_min` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicU32::fetch_min`]. pub fn atomic_umin(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicU32::fetch_min`](crate::sync::atomic::AtomicU32::fetch_min). + /// [`atomic`] unsigned integer types via the `fetch_min` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicU32::fetch_min`]. pub fn atomic_umin_acq(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicU32::fetch_min`](crate::sync::atomic::AtomicU32::fetch_min). + /// [`atomic`] unsigned integer types via the `fetch_min` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicU32::fetch_min`]. pub fn atomic_umin_rel(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `order`. For example, - /// [`AtomicU32::fetch_min`](crate::sync::atomic::AtomicU32::fetch_min). + /// [`atomic`] unsigned integer types via the `fetch_min` method by passing + /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicU32::fetch_min`]. pub fn atomic_umin_acqrel(dst: *mut T, src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicU32::fetch_min`](crate::sync::atomic::AtomicU32::fetch_min). + /// [`atomic`] unsigned integer types via the `fetch_min` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicU32::fetch_min`]. pub fn atomic_umin_relaxed(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) - /// as the `order`. For example, - /// [`AtomicU32::fetch_max`](crate::sync::atomic::AtomicU32::fetch_max). + /// [`atomic`] unsigned integer types via the `fetch_max` method by passing + /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicU32::fetch_max`]. pub fn atomic_umax(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) - /// as the `order`. For example, - /// [`AtomicU32::fetch_max`](crate::sync::atomic::AtomicU32::fetch_max). + /// [`atomic`] unsigned integer types via the `fetch_max` method by passing + /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicU32::fetch_max`]. pub fn atomic_umax_acq(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) - /// as the `order`. For example, - /// [`AtomicU32::fetch_max`](crate::sync::atomic::AtomicU32::fetch_max). + /// [`atomic`] unsigned integer types via the `fetch_max` method by passing + /// [`Ordering::Release`] as the `order`. For example, [`AtomicU32::fetch_max`]. pub fn atomic_umax_rel(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) - /// as the `order`. For example, - /// [`AtomicU32::fetch_max`](crate::sync::atomic::AtomicU32::fetch_max). + /// [`atomic`] unsigned integer types via the `fetch_max` method by passing + /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicU32::fetch_max`]. pub fn atomic_umax_acqrel(dst: *mut T, src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the - /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing - /// [`Ordering::Relaxed`](crate::sync::atomic::Ordering::Relaxed) - /// as the `order`. For example, - /// [`AtomicU32::fetch_max`](crate::sync::atomic::AtomicU32::fetch_max). + /// [`atomic`] unsigned integer types via the `fetch_max` method by passing + /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicU32::fetch_max`]. pub fn atomic_umax_relaxed(dst: *mut T, src: T) -> T; /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction @@ -823,33 +632,25 @@ extern "rust-intrinsic" { /// An atomic fence. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::fence`](crate::sync::atomic::fence) - /// by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) + /// [`atomic::fence`] by passing [`Ordering::SeqCst`] /// as the `order`. pub fn atomic_fence(); /// An atomic fence. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::fence`](crate::sync::atomic::fence) - /// by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) + /// [`atomic::fence`] by passing [`Ordering::Acquire`] /// as the `order`. pub fn atomic_fence_acq(); /// An atomic fence. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::fence`](crate::sync::atomic::fence) - /// by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) + /// [`atomic::fence`] by passing [`Ordering::Release`] /// as the `order`. pub fn atomic_fence_rel(); /// An atomic fence. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::fence`](crate::sync::atomic::fence) - /// by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) + /// [`atomic::fence`] by passing [`Ordering::AcqRel`] /// as the `order`. pub fn atomic_fence_acqrel(); @@ -861,9 +662,7 @@ extern "rust-intrinsic" { /// such as when interacting with signal handlers. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::compiler_fence`](crate::sync::atomic::compiler_fence) - /// by passing - /// [`Ordering::SeqCst`](crate::sync::atomic::Ordering::SeqCst) + /// [`atomic::compiler_fence`] by passing [`Ordering::SeqCst`] /// as the `order`. pub fn atomic_singlethreadfence(); /// A compiler-only memory barrier. @@ -874,9 +673,7 @@ extern "rust-intrinsic" { /// such as when interacting with signal handlers. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::compiler_fence`](crate::sync::atomic::compiler_fence) - /// by passing - /// [`Ordering::Acquire`](crate::sync::atomic::Ordering::Acquire) + /// [`atomic::compiler_fence`] by passing [`Ordering::Acquire`] /// as the `order`. pub fn atomic_singlethreadfence_acq(); /// A compiler-only memory barrier. @@ -887,9 +684,7 @@ extern "rust-intrinsic" { /// such as when interacting with signal handlers. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::compiler_fence`](crate::sync::atomic::compiler_fence) - /// by passing - /// [`Ordering::Release`](crate::sync::atomic::Ordering::Release) + /// [`atomic::compiler_fence`] by passing [`Ordering::Release`] /// as the `order`. pub fn atomic_singlethreadfence_rel(); /// A compiler-only memory barrier. @@ -900,9 +695,7 @@ extern "rust-intrinsic" { /// such as when interacting with signal handlers. /// /// The stabilized version of this intrinsic is available in - /// [`std::sync::atomic::compiler_fence`](crate::sync::atomic::compiler_fence) - /// by passing - /// [`Ordering::AcqRel`](crate::sync::atomic::Ordering::AcqRel) + /// [`atomic::compiler_fence`] by passing [`Ordering::AcqRel`] /// as the `order`. pub fn atomic_singlethreadfence_acqrel(); @@ -930,8 +723,7 @@ extern "rust-intrinsic" { /// macro, which panics when it is executed, it is *undefined behavior* to /// reach code marked with this function. /// - /// The stabilized version of this intrinsic is - /// [`std::hint::unreachable_unchecked`](crate::hint::unreachable_unchecked). + /// The stabilized version of this intrinsic is [`crate::hint::unreachable_unchecked`]. #[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")] pub fn unreachable() -> !; @@ -975,8 +767,7 @@ extern "rust-intrinsic" { /// More specifically, this is the offset in bytes between successive /// items of the same type, including alignment padding. /// - /// The stabilized version of this intrinsic is - /// [`std::mem::size_of`](crate::mem::size_of). + /// The stabilized version of this intrinsic is [`size_of`]. #[rustc_const_stable(feature = "const_size_of", since = "1.40.0")] pub fn size_of() -> usize; @@ -984,14 +775,12 @@ extern "rust-intrinsic" { /// /// Drop glue is not run on the destination. /// - /// The stabilized version of this intrinsic is - /// [`std::ptr::write`](crate::ptr::write). + /// The stabilized version of this intrinsic is [`crate::ptr::write`]. pub fn move_val_init(dst: *mut T, src: T); /// The minimum alignment of a type. /// - /// The stabilized version of this intrinsic is - /// [`std::mem::align_of`](crate::mem::align_of). + /// The stabilized version of this intrinsic is [`crate::mem::align_of`]. #[rustc_const_stable(feature = "const_min_align_of", since = "1.40.0")] pub fn min_align_of() -> usize; /// The preferred alignment of a type. @@ -1002,21 +791,18 @@ extern "rust-intrinsic" { /// The size of the referenced value in bytes. /// - /// The stabilized version of this intrinsic is - /// [`std::mem::size_of_val`](crate::mem::size_of_val). + /// The stabilized version of this intrinsic is [`size_of_val`]. #[rustc_const_unstable(feature = "const_size_of_val", issue = "46571")] pub fn size_of_val(_: *const T) -> usize; /// The required alignment of the referenced value. /// - /// The stabilized version of this intrinsic is - /// [`std::mem::align_of_val`](crate::mem::align_of_val). + /// The stabilized version of this intrinsic is [`crate::mem::align_of_val`]. #[rustc_const_unstable(feature = "const_align_of_val", issue = "46571")] pub fn min_align_of_val(_: *const T) -> usize; /// Gets a static string slice containing the name of a type. /// - /// The stabilized version of this intrinsic is - /// [`std::any::type_name`](crate::any::type_name) + /// The stabilized version of this intrinsic is [`crate::any::type_name`]. #[rustc_const_unstable(feature = "const_type_name", issue = "63084")] pub fn type_name() -> &'static str; @@ -1024,8 +810,7 @@ extern "rust-intrinsic" { /// function will return the same value for a type regardless of whichever /// crate it is invoked in. /// - /// The stabilized version of this intrinsic is - /// [`std::any::TypeId::of`](crate::any::TypeId::of) + /// The stabilized version of this intrinsic is [`crate::any::TypeId::of`]. #[rustc_const_stable(feature = "const_type_id", since = "1.46.0")] pub fn type_id() -> u64; @@ -1049,15 +834,14 @@ extern "rust-intrinsic" { /// Gets a reference to a static `Location` indicating where it was called. /// - /// Consider using [`std::panic::Location::caller`](crate::panic::Location::caller) - /// instead. + /// Consider using [`crate::panic::Location::caller`] instead. #[rustc_const_unstable(feature = "const_caller_location", issue = "47809")] pub fn caller_location() -> &'static crate::panic::Location<'static>; /// Moves a value out of scope without running drop glue. /// - /// This exists solely for [`mem::forget_unsized`](../../std/mem/fn.forget_unsized.html); - /// normal `forget` uses `ManuallyDrop` instead. + /// This exists solely for [`mem::forget_unsized`]; normal `forget` uses + /// `ManuallyDrop` instead. pub fn forget(_: T); /// Reinterprets the bits of a value of one type as another type. @@ -1300,8 +1084,7 @@ extern "rust-intrinsic" { /// If the actual type neither requires drop glue nor implements /// `Copy`, then the return value of this function is unspecified. /// - /// The stabilized version of this intrinsic is - /// [`std::mem::needs_drop`](crate::mem::needs_drop). + /// The stabilized version of this intrinsic is [`needs_drop`]. #[rustc_const_stable(feature = "const_needs_drop", since = "1.40.0")] pub fn needs_drop() -> bool; @@ -1371,13 +1154,11 @@ extern "rust-intrinsic" { /// Performs a volatile load from the `src` pointer. /// - /// The stabilized version of this intrinsic is - /// [`std::ptr::read_volatile`](crate::ptr::read_volatile). + /// The stabilized version of this intrinsic is [`crate::ptr::read_volatile`]. pub fn volatile_load(src: *const T) -> T; /// Performs a volatile store to the `dst` pointer. /// - /// The stabilized version of this intrinsic is - /// [`std::ptr::write_volatile`](crate::ptr::write_volatile). + /// The stabilized version of this intrinsic is [`crate::ptr::write_volatile`]. pub fn volatile_store(dst: *mut T, val: T); /// Performs a volatile load from the `src` pointer @@ -1526,22 +1307,22 @@ extern "rust-intrinsic" { /// Returns the minimum of two `f32` values. /// /// The stabilized version of this intrinsic is - /// [`std::f32::min`](f32::min) + /// [`f32::min`] pub fn minnumf32(x: f32, y: f32) -> f32; /// Returns the minimum of two `f64` values. /// /// The stabilized version of this intrinsic is - /// [`std::f64::min`](f64::min) + /// [`f64::min`] pub fn minnumf64(x: f64, y: f64) -> f64; /// Returns the maximum of two `f32` values. /// /// The stabilized version of this intrinsic is - /// [`std::f32::max`](f32::max) + /// [`f32::max`] pub fn maxnumf32(x: f32, y: f32) -> f32; /// Returns the maximum of two `f64` values. /// /// The stabilized version of this intrinsic is - /// [`std::f64::max`](f64::max) + /// [`f64::max`] pub fn maxnumf64(x: f64, y: f64) -> f64; /// Copies the sign from `y` to `x` for `f32` values. @@ -1648,15 +1429,14 @@ extern "rust-intrinsic" { /// Convert with LLVM’s fptoui/fptosi, which may return undef for values out of range /// () /// - /// Stabilized as [`f32::to_int_unchecked`](../../std/primitive.f32.html#method.to_int_unchecked) - /// and [`f64::to_int_unchecked`](../../std/primitive.f64.html#method.to_int_unchecked). + /// Stabilized as [`f32::to_int_unchecked`] and [`f64::to_int_unchecked`]. pub fn float_to_int_unchecked(value: Float) -> Int; /// Returns the number of bits set in an integer type `T` /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `count_ones` method. For example, - /// [`std::u32::count_ones`](u32::count_ones) + /// [`u32::count_ones`] #[rustc_const_stable(feature = "const_ctpop", since = "1.40.0")] pub fn ctpop(x: T) -> T; @@ -1664,7 +1444,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `leading_zeros` method. For example, - /// [`std::u32::leading_zeros`](u32::leading_zeros) + /// [`u32::leading_zeros`] /// /// # Examples /// @@ -1715,7 +1495,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `trailing_zeros` method. For example, - /// [`std::u32::trailing_zeros`](u32::trailing_zeros) + /// [`u32::trailing_zeros`] /// /// # Examples /// @@ -1766,7 +1546,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `swap_bytes` method. For example, - /// [`std::u32::swap_bytes`](u32::swap_bytes) + /// [`u32::swap_bytes`] #[rustc_const_stable(feature = "const_bswap", since = "1.40.0")] pub fn bswap(x: T) -> T; @@ -1774,7 +1554,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `reverse_bits` method. For example, - /// [`std::u32::reverse_bits`](u32::reverse_bits) + /// [`u32::reverse_bits`] #[rustc_const_stable(feature = "const_bitreverse", since = "1.40.0")] pub fn bitreverse(x: T) -> T; @@ -1782,7 +1562,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `overflowing_add` method. For example, - /// [`std::u32::overflowing_add`](u32::overflowing_add) + /// [`u32::overflowing_add`] #[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")] pub fn add_with_overflow(x: T, y: T) -> (T, bool); @@ -1790,7 +1570,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `overflowing_sub` method. For example, - /// [`std::u32::overflowing_sub`](u32::overflowing_sub) + /// [`u32::overflowing_sub`] #[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")] pub fn sub_with_overflow(x: T, y: T) -> (T, bool); @@ -1798,7 +1578,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `overflowing_mul` method. For example, - /// [`std::u32::overflowing_mul`](u32::overflowing_mul) + /// [`u32::overflowing_mul`] #[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")] pub fn mul_with_overflow(x: T, y: T) -> (T, bool); @@ -1813,7 +1593,7 @@ extern "rust-intrinsic" { /// /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_div` method. For example, - /// [`std::u32::checked_div`](u32::checked_div) + /// [`u32::checked_div`] #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")] pub fn unchecked_div(x: T, y: T) -> T; /// Returns the remainder of an unchecked division, resulting in @@ -1821,7 +1601,7 @@ extern "rust-intrinsic" { /// /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_rem` method. For example, - /// [`std::u32::checked_rem`](u32::checked_rem) + /// [`u32::checked_rem`] #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")] pub fn unchecked_rem(x: T, y: T) -> T; @@ -1830,7 +1610,7 @@ extern "rust-intrinsic" { /// /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_shl` method. For example, - /// [`std::u32::checked_shl`](u32::checked_shl) + /// [`u32::checked_shl`] #[rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0")] pub fn unchecked_shl(x: T, y: T) -> T; /// Performs an unchecked right shift, resulting in undefined behavior when @@ -1838,7 +1618,7 @@ extern "rust-intrinsic" { /// /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_shr` method. For example, - /// [`std::u32::checked_shr`](u32::checked_shr) + /// [`u32::checked_shr`] #[rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0")] pub fn unchecked_shr(x: T, y: T) -> T; @@ -1867,7 +1647,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `rotate_left` method. For example, - /// [`std::u32::rotate_left`](u32::rotate_left) + /// [`u32::rotate_left`] #[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")] pub fn rotate_left(x: T, y: T) -> T; @@ -1875,7 +1655,7 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `rotate_right` method. For example, - /// [`std::u32::rotate_right`](u32::rotate_right) + /// [`u32::rotate_right`] #[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")] pub fn rotate_right(x: T, y: T) -> T; @@ -1883,21 +1663,21 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `checked_add` method. For example, - /// [`std::u32::checked_add`](u32::checked_add) + /// [`u32::checked_add`] #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")] pub fn wrapping_add(a: T, b: T) -> T; /// Returns (a - b) mod 2N, where N is the width of T in bits. /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `checked_sub` method. For example, - /// [`std::u32::checked_sub`](u32::checked_sub) + /// [`u32::checked_sub`] #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")] pub fn wrapping_sub(a: T, b: T) -> T; /// Returns (a * b) mod 2N, where N is the width of T in bits. /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `checked_mul` method. For example, - /// [`std::u32::checked_mul`](u32::checked_mul) + /// [`u32::checked_mul`] #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")] pub fn wrapping_mul(a: T, b: T) -> T; @@ -1905,30 +1685,28 @@ extern "rust-intrinsic" { /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `saturating_add` method. For example, - /// [`std::u32::saturating_add`](u32::saturating_add) + /// [`u32::saturating_add`] #[rustc_const_stable(feature = "const_int_saturating", since = "1.40.0")] pub fn saturating_add(a: T, b: T) -> T; /// Computes `a - b`, while saturating at numeric bounds. /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `saturating_sub` method. For example, - /// [`std::u32::saturating_sub`](u32::saturating_sub) + /// [`u32::saturating_sub`] #[rustc_const_stable(feature = "const_int_saturating", since = "1.40.0")] pub fn saturating_sub(a: T, b: T) -> T; /// Returns the value of the discriminant for the variant in 'v', /// cast to a `u64`; if `T` has no discriminant, returns 0. /// - /// The stabilized version of this intrinsic is - /// [`std::mem::discriminant`](crate::mem::discriminant) + /// The stabilized version of this intrinsic is [`crate::mem::discriminant`]. #[rustc_const_unstable(feature = "const_discriminant", issue = "69821")] pub fn discriminant_value(v: &T) -> ::Discriminant; /// Returns the number of variants of the type `T` cast to a `usize`; /// if `T` has no variants, returns 0. Uninhabited variants will be counted. /// - /// The to-be-stabilized version of this intrinsic is - /// [`std::mem::variant_count`](crate::mem::variant_count) + /// The to-be-stabilized version of this intrinsic is [`variant_count`]. #[rustc_const_unstable(feature = "variant_count", issue = "73662")] pub fn variant_count() -> usize; @@ -2077,7 +1855,6 @@ pub(crate) fn is_nonoverlapping(src: *const T, dst: *const T, count: usize) - /// Note that even if the effectively copied size (`count * size_of::()`) is /// `0`, the pointers must be non-NULL and properly aligned. /// -/// [`Copy`]: crate::marker::Copy /// [`read`]: crate::ptr::read /// [read-ownership]: crate::ptr::read#ownership-of-the-returned-value /// [valid]: crate::ptr#safety @@ -2179,7 +1956,6 @@ pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { /// Note that even if the effectively copied size (`count * size_of::()`) is /// `0`, the pointers must be non-NULL and properly aligned. /// -/// [`Copy`]: crate::marker::Copy /// [`read`]: crate::ptr::read /// [read-ownership]: crate::ptr::read#ownership-of-the-returned-value /// [valid]: crate::ptr#safety From 0f6d95d1ebc62d07c3b83bd2b6685ca0c4709aff Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Fri, 21 Aug 2020 18:50:09 +0200 Subject: [PATCH 33/44] Apply auto-formatter --- library/core/src/intrinsics.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index da40e2618112b..67cb411effbe6 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -60,11 +60,11 @@ use crate::mem; // These imports are used for simplifying intra-doc links use crate::sync::atomic; -use crate::sync::atomic::Ordering; -use crate::sync::atomic::AtomicU32; -use crate::sync::atomic::AtomicI32; use crate::sync::atomic::AtomicBool; +use crate::sync::atomic::AtomicI32; use crate::sync::atomic::AtomicIsize; +use crate::sync::atomic::AtomicU32; +use crate::sync::atomic::Ordering; #[stable(feature = "drop_in_place", since = "1.8.0")] #[rustc_deprecated( From 37b6c249ede0f141a2fcf0332ef11d7cbf68e350 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Fri, 21 Aug 2020 19:19:58 +0200 Subject: [PATCH 34/44] Rework imports used solely for docs --- library/core/src/intrinsics.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 67cb411effbe6..eac63bf85c0e7 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -53,18 +53,13 @@ issue = "none" )] #![allow(missing_docs)] -#![allow(unused_imports)] use crate::marker::DiscriminantKind; use crate::mem; // These imports are used for simplifying intra-doc links -use crate::sync::atomic; -use crate::sync::atomic::AtomicBool; -use crate::sync::atomic::AtomicI32; -use crate::sync::atomic::AtomicIsize; -use crate::sync::atomic::AtomicU32; -use crate::sync::atomic::Ordering; +#[cfg(doc)] +use crate::sync::atomic::{self, AtomicBool, AtomicI32, AtomicIsize, AtomicU32, Ordering}; #[stable(feature = "drop_in_place", since = "1.8.0")] #[rustc_deprecated( From 97072c6b9054bbab09fa731948d504a26a1f8377 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Fri, 21 Aug 2020 13:09:32 +0200 Subject: [PATCH 35/44] Apply suggestions from code review Co-authored-by: Joshua Nelson --- library/alloc/src/collections/linked_list.rs | 8 ++------ library/alloc/src/fmt.rs | 3 --- library/alloc/src/rc.rs | 3 +-- library/alloc/src/string.rs | 2 +- library/alloc/src/sync.rs | 4 ++-- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index 74155ea66d020..5390b57a1d98d 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -50,10 +50,8 @@ struct Node { /// An iterator over the elements of a `LinkedList`. /// -/// This `struct` is created by the [`iter`] method on [`LinkedList`]. See its +/// This `struct` is created by [`LinkedList::iter()`]. See its /// documentation for more. -/// -/// [`iter`]: LinkedList::iter #[stable(feature = "rust1", since = "1.0.0")] pub struct Iter<'a, T: 'a> { head: Option>>, @@ -79,10 +77,8 @@ impl Clone for Iter<'_, T> { /// A mutable iterator over the elements of a `LinkedList`. /// -/// This `struct` is created by the [`iter_mut`] method on [`LinkedList`]. See its +/// This `struct` is created by [`LinkedList::iter_mut()`]. See its /// documentation for more. -/// -/// [`iter_mut`]: LinkedList::iter_mut #[stable(feature = "rust1", since = "1.0.0")] pub struct IterMut<'a, T: 'a> { // We do *not* exclusively own the entire list here, references to node's `element` diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index 016b5446f4ddb..a886e17f5a9c3 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -501,9 +501,6 @@ //! it would internally pass around this structure until it has been determined //! where output should go to. //! -//! [`usize`]: core::usize -//! [`isize`]: core::isize -//! [`i8`]: core::i8 //! [`fmt::Result`]: Result //! [`Result`]: core::result::Result //! [`std::fmt::Error`]: Error diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index a41592a45b890..f8b1c21e9771c 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -393,7 +393,7 @@ impl Rc { /// Returns the inner value, if the `Rc` has exactly one strong reference. /// - /// Otherwise, an [`Err`][Result] is returned with the same `Rc` that was + /// Otherwise, an [`Err`] is returned with the same `Rc` that was /// passed in. /// /// This will succeed even if there are outstanding weak references. @@ -1743,7 +1743,6 @@ impl Weak { /// [`into_raw`]: Weak::into_raw /// [`upgrade`]: Weak::upgrade /// [`new`]: Weak::new - /// [`forget`]: std::mem::forget #[stable(feature = "weak_into_raw", since = "1.45.0")] pub unsafe fn from_raw(ptr: *const T) -> Self { if ptr.is_null() { diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 223d6755e26f4..d7d7b6bd157bc 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -492,7 +492,7 @@ impl String { /// `from_utf8_lossy()` will replace any invalid UTF-8 sequences with /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], which looks like this: � /// - /// [byteslice]: core::slice + /// [byteslice]: ../../std/primitive.slice.html /// [U+FFFD]: core::char::REPLACEMENT_CHARACTER /// /// If you are sure that the byte slice is valid UTF-8, and you don't want diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 6234f6cc32142..4444a7a313298 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -387,7 +387,7 @@ impl Arc { /// Returns the inner value, if the `Arc` has exactly one strong reference. /// - /// Otherwise, an [`Err`][Result] is returned with the same `Arc` that was + /// Otherwise, an [`Err`] is returned with the same `Arc` that was /// passed in. /// /// This will succeed even if there are outstanding weak references. @@ -1168,7 +1168,7 @@ impl Arc { /// Returns a mutable reference into the given `Arc`, if there are /// no other `Arc` or [`Weak`] pointers to the same allocation. /// - /// Returns [`None`][Option] otherwise, because it is not safe to + /// Returns [`None`] otherwise, because it is not safe to /// mutate a shared value. /// /// See also [`make_mut`][make_mut], which will [`clone`][clone] From 60b7c2aaefebe2ea6819414ebaf6e374031fc76d Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Fri, 21 Aug 2020 18:42:06 +0100 Subject: [PATCH 36/44] More inline asm register name fixups for LLVM Fixes #75761 --- src/librustc_codegen_llvm/asm.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/librustc_codegen_llvm/asm.rs b/src/librustc_codegen_llvm/asm.rs index a6062de6bf8af..4fef94dde5f7a 100644 --- a/src/librustc_codegen_llvm/asm.rs +++ b/src/librustc_codegen_llvm/asm.rs @@ -479,10 +479,13 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'tcx>>) _ => unreachable!(), } } else { - // We use i32 as the type for discarded outputs - 's' + // We use i64x2 as the type for discarded outputs + 'q' }; format!("{{{}{}}}", class, idx) + } else if reg == InlineAsmReg::AArch64(AArch64InlineAsmReg::x30) { + // LLVM doesn't recognize x30 + "lr".to_string() } else { format!("{{{}}}", reg.name()) } From a3b45f3e54b9497af864f8fa3cb8a334c5de02b4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 21 Aug 2020 20:28:57 +0200 Subject: [PATCH 37/44] Convert links to intra-doc links format --- library/core/src/str/pattern.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/library/core/src/str/pattern.rs b/library/core/src/str/pattern.rs index 14f1f293d40d6..0e53d72b393b4 100644 --- a/library/core/src/str/pattern.rs +++ b/library/core/src/str/pattern.rs @@ -12,7 +12,7 @@ //! # Examples //! //! [`Pattern`] is [implemented][pattern-impls] in the stable API for -//! [`&str`], [`char`], slices of [`char`], and functions and closures +//! [`&str`][`str`], [`char`], slices of [`char`], and functions and closures //! implementing `FnMut(char) -> bool`. //! //! ``` @@ -28,13 +28,6 @@ //! assert_eq!(s.find(|c: char| c.is_ascii_punctuation()), Some(35)); //! ``` //! -//! [`&str`]: ../../../std/primitive.str.html -//! [`char`]: ../../../std/primitive.char.html -//! [`str`]: ../../../std/primitive.str.html -//! [`DoubleEndedSearcher`]: trait.DoubleEndedSearcher.html -//! [`Pattern`]: trait.Pattern.html -//! [`ReverseSearcher`]: trait.ReverseSearcher.html -//! [`Searcher`]: trait.Searcher.html //! [pattern-impls]: trait.Pattern.html#implementors #![unstable( @@ -75,6 +68,7 @@ use crate::slice::memchr; /// | `&String` | is substring | /// /// # Examples +/// /// ``` /// // &str /// assert_eq!("abaaa".find("ba"), Some(1)); @@ -94,9 +88,6 @@ use crate::slice::memchr; /// assert_eq!("abcdef_z".find(|ch| ch > 'd' && ch < 'y'), Some(4)); /// assert_eq!("abcddd_z".find(|ch| ch > 'd' && ch < 'y'), None); /// ``` -/// -/// [`str::find`]: ../../../std/primitive.str.html#method.find -/// [`str::contains`]: ../../../std/primitive.str.html#method.contains pub trait Pattern<'a>: Sized { /// Associated searcher for this pattern type Searcher: Searcher<'a>; From ec9657aec6e0d341e2e32f2ca3cc1d8a508a5415 Mon Sep 17 00:00:00 2001 From: "Dr. Koutheir Attouchi" Date: Fri, 21 Aug 2020 14:47:18 -0400 Subject: [PATCH 38/44] Fixed a typo --- src/doc/unstable-book/src/compiler-flags/control-flow-guard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md b/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md index 901c053877d56..03065f5a90723 100644 --- a/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md +++ b/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md @@ -21,7 +21,7 @@ CFG functionality is completely implemented in the LLVM backend and is supported The primary motivation for enabling CFG in Rust is to enhance security when linking against non-Rust code, especially C/C++ code. To achieve full CFG protection, all indirect calls (including any from Rust code) must have the appropriate CFG checks, as added by this flag. CFG can also improve security for Rust code that uses the `unsafe` keyword. -Another motivation behind CFG is to harden programs against [return-oriented programming (ROP)](https://en.wikipedia.org/wiki/Return-oriented_programming) attacks. CFG disallows an attacker from taking advantage of the programs own instructions while redirecting control flow in unexpected ways. +Another motivation behind CFG is to harden programs against [return-oriented programming (ROP)](https://en.wikipedia.org/wiki/Return-oriented_programming) attacks. CFG disallows an attacker from taking advantage of the program's own instructions while redirecting control flow in unexpected ways. ## Overhead of Control Flow Guard From 8ae3384bf7208387237b67636b8632d4707d3ec1 Mon Sep 17 00:00:00 2001 From: "Dr. Koutheir Attouchi" Date: Fri, 21 Aug 2020 14:52:30 -0400 Subject: [PATCH 39/44] Added link to Microsoft's documentation of CFG --- src/doc/unstable-book/src/compiler-flags/control-flow-guard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md b/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md index 03065f5a90723..c43d91bf070ed 100644 --- a/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md +++ b/src/doc/unstable-book/src/compiler-flags/control-flow-guard.md @@ -6,7 +6,7 @@ The tracking issue for this feature is: [#68793](https://github.com/rust-lang/ru The rustc flag `-Z control-flow-guard` enables the Windows [Control Flow Guard](https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard) (CFG) platform security feature. -CFG is an exploit mitigation designed to enforce control-flow integrity for software running on supported Windows platforms (Windows 8.1 onwards). Specifically, CFG uses runtime checks to validate the target address of every indirect call/jump before allowing the call to complete. +CFG is an exploit mitigation designed to enforce control-flow integrity for software running on supported [Windows platforms (Windows 8.1 onwards)](https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard). Specifically, CFG uses runtime checks to validate the target address of every indirect call/jump before allowing the call to complete. During compilation, the compiler identifies all indirect calls/jumps and adds CFG checks. It also emits metadata containing the relative addresses of all address-taken functions. At runtime, if the binary is run on a CFG-aware operating system, the loader uses the CFG metadata to generate a bitmap of the address space and marks those addresses that contain valid targets. On each indirect call, the inserted check determines whether the target address is marked in this bitmap. If the target is not valid, the process is terminated. From 4fe4c3b7e3668c525bec91be33a29852b2c68a4d Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Fri, 21 Aug 2020 19:52:48 +0100 Subject: [PATCH 40/44] Add regression test --- src/test/assembly/asm/aarch64-types.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/assembly/asm/aarch64-types.rs b/src/test/assembly/asm/aarch64-types.rs index a8df350ef60b2..e39f74c916c4a 100644 --- a/src/test/assembly/asm/aarch64-types.rs +++ b/src/test/assembly/asm/aarch64-types.rs @@ -553,3 +553,8 @@ check_reg!(v0_f32x4 f32x4 "s0" "fmov"); // CHECK: fmov s0, s0 // CHECK: //NO_APP check_reg!(v0_f64x2 f64x2 "s0" "fmov"); + +// Regression test for #75761 +pub unsafe fn issue_75761() { + asm!("", out("v0") _, out("x30") _); +} From 215822a32ee4ff3fc8b8cade9f6e31debe57df18 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Sat, 22 Aug 2020 00:11:52 +0300 Subject: [PATCH 41/44] MIR call terminator represents diverging calls too --- src/librustc_middle/mir/terminator/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_middle/mir/terminator/mod.rs b/src/librustc_middle/mir/terminator/mod.rs index e8fe3a97a10c7..fcfd648c2b7aa 100644 --- a/src/librustc_middle/mir/terminator/mod.rs +++ b/src/librustc_middle/mir/terminator/mod.rs @@ -103,7 +103,7 @@ pub enum TerminatorKind<'tcx> { unwind: Option, }, - /// Block ends with a call of a converging function. + /// Block ends with a call of a function. Call { /// The function that’s being called. func: Operand<'tcx>, From 8e009bc4f06dcc4350802089d1cb0a2d62d5f684 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Fri, 21 Aug 2020 22:34:21 +0200 Subject: [PATCH 42/44] Use intra-doc-links in `core::ops::*` --- library/core/src/ops/deref.rs | 2 -- library/core/src/ops/drop.rs | 16 ++++++++-------- library/core/src/ops/function.rs | 6 ------ library/core/src/ops/index.rs | 6 +----- library/core/src/ops/mod.rs | 8 +------- library/core/src/ops/range.rs | 32 ++++++++++++++++---------------- library/core/src/ops/unsize.rs | 2 +- 7 files changed, 27 insertions(+), 45 deletions(-) diff --git a/library/core/src/ops/deref.rs b/library/core/src/ops/deref.rs index 3faeb170b0637..d6c097eee17bf 100644 --- a/library/core/src/ops/deref.rs +++ b/library/core/src/ops/deref.rs @@ -28,7 +28,6 @@ /// [method resolution] and [type coercions]. /// /// [book]: ../../book/ch15-02-deref.html -/// [`DerefMut`]: trait.DerefMut.html /// [more]: #more-on-deref-coercion /// [ref-deref-op]: ../../reference/expressions/operator-expr.html#the-dereference-operator /// [method resolution]: ../../reference/expressions/method-call-expr.html @@ -125,7 +124,6 @@ impl Deref for &mut T { /// [method resolution] and [type coercions]. /// /// [book]: ../../book/ch15-02-deref.html -/// [`Deref`]: trait.Deref.html /// [more]: #more-on-deref-coercion /// [ref-deref-op]: ../../reference/expressions/operator-expr.html#the-dereference-operator /// [method resolution]: ../../reference/expressions/method-call-expr.html diff --git a/library/core/src/ops/drop.rs b/library/core/src/ops/drop.rs index 06cfc36363615..0824753db7580 100644 --- a/library/core/src/ops/drop.rs +++ b/library/core/src/ops/drop.rs @@ -78,9 +78,9 @@ /// /// In other words, if you tried to explicitly call `Drop::drop` in the above example, you'd get a compiler error. /// -/// If you'd like explicitly call the destructor of a value, [`std::mem::drop`] can be used instead. +/// If you'd like explicitly call the destructor of a value, [`mem::drop`] can be used instead. /// -/// [`std::mem::drop`]: ../../std/mem/fn.drop.html +/// [`mem::drop`]: crate::mem::drop /// /// ## Drop order /// @@ -133,7 +133,7 @@ /// hard to predict when, and how often destructors will be executed. As such, /// these types cannot have destructors. /// -/// [`Copy`]: ../../std/marker/trait.Copy.html +/// [`Copy`]: crate::marker::Copy #[lang = "drop"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Drop { @@ -141,7 +141,7 @@ pub trait Drop { /// /// This method is called implicitly when the value goes out of scope, /// and cannot be called explicitly (this is compiler error [E0040]). - /// However, the [`std::mem::drop`] function in the prelude can be + /// However, the [`mem::drop`] function in the prelude can be /// used to call the argument's `Drop` implementation. /// /// When this method has been called, `self` has not yet been deallocated. @@ -156,12 +156,12 @@ pub trait Drop { /// Note that even if this panics, the value is considered to be dropped; /// you must not cause `drop` to be called again. This is normally automatically /// handled by the compiler, but when using unsafe code, can sometimes occur - /// unintentionally, particularly when using [`std::ptr::drop_in_place`]. + /// unintentionally, particularly when using [`ptr::drop_in_place`]. /// /// [E0040]: ../../error-index.html#E0040 - /// [`panic!`]: ../macro.panic.html - /// [`std::mem::drop`]: ../../std/mem/fn.drop.html - /// [`std::ptr::drop_in_place`]: ../../std/ptr/fn.drop_in_place.html + /// [`panic!`]: crate::panic! + /// [`mem::drop`]: crate::mem::drop + /// [`ptr::drop_in_place`]: crate::ptr::drop_in_place #[stable(feature = "rust1", since = "1.0.0")] fn drop(&mut self); } diff --git a/library/core/src/ops/function.rs b/library/core/src/ops/function.rs index 3e5cad2b185a1..bfdec43f7d80b 100644 --- a/library/core/src/ops/function.rs +++ b/library/core/src/ops/function.rs @@ -28,8 +28,6 @@ /// this can refer to [the relevant section in the *Rustonomicon*][nomicon]. /// /// [book]: ../../book/ch13-01-closures.html -/// [`FnMut`]: trait.FnMut.html -/// [`FnOnce`]: trait.FnOnce.html /// [function pointers]: ../../std/primitive.fn.html /// [nomicon]: ../../nomicon/hrtb.html /// @@ -99,8 +97,6 @@ pub trait Fn: FnMut { /// this can refer to [the relevant section in the *Rustonomicon*][nomicon]. /// /// [book]: ../../book/ch13-01-closures.html -/// [`Fn`]: trait.Fn.html -/// [`FnOnce`]: trait.FnOnce.html /// [function pointers]: ../../std/primitive.fn.html /// [nomicon]: ../../nomicon/hrtb.html /// @@ -180,8 +176,6 @@ pub trait FnMut: FnOnce { /// this can refer to [the relevant section in the *Rustonomicon*][nomicon]. /// /// [book]: ../../book/ch13-01-closures.html -/// [`Fn`]: trait.Fn.html -/// [`FnMut`]: trait.FnMut.html /// [function pointers]: ../../std/primitive.fn.html /// [nomicon]: ../../nomicon/hrtb.html /// diff --git a/library/core/src/ops/index.rs b/library/core/src/ops/index.rs index 763b33606fe88..9c2da00ae2f85 100644 --- a/library/core/src/ops/index.rs +++ b/library/core/src/ops/index.rs @@ -4,9 +4,7 @@ /// but only when used as an immutable value. If a mutable value is requested, /// [`IndexMut`] is used instead. This allows nice things such as /// `let value = v[index]` if the type of `value` implements [`Copy`]. -/// -/// [`IndexMut`]: ../../std/ops/trait.IndexMut.html -/// [`Copy`]: ../../std/marker/trait.Copy.html +/// [`Copy`]: crate::marker::Copy /// /// # Examples /// @@ -76,8 +74,6 @@ pub trait Index { /// an immutable value is requested, the [`Index`] trait is used instead. This /// allows nice things such as `v[index] = value`. /// -/// [`Index`]: ../../std/ops/trait.Index.html -/// /// # Examples /// /// A very simple implementation of a `Balance` struct that has two sides, where diff --git a/library/core/src/ops/mod.rs b/library/core/src/ops/mod.rs index e3e5934b44be1..ddcea46a552bb 100644 --- a/library/core/src/ops/mod.rs +++ b/library/core/src/ops/mod.rs @@ -133,13 +133,7 @@ //! // `consume_and_return_x` can no longer be invoked at this point //! ``` //! -//! [`Fn`]: trait.Fn.html -//! [`FnMut`]: trait.FnMut.html -//! [`FnOnce`]: trait.FnOnce.html -//! [`Add`]: trait.Add.html -//! [`Sub`]: trait.Sub.html -//! [`Mul`]: trait.Mul.html -//! [`clone`]: ../clone/trait.Clone.html#tymethod.clone +//! [`clone`]: crate::clone::Clone::clone //! [operator precedence]: ../../reference/expressions.html#expression-precedence #![stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs index e9ab82b539849..5614c30b43e02 100644 --- a/library/core/src/ops/range.rs +++ b/library/core/src/ops/range.rs @@ -35,9 +35,9 @@ use crate::hash::Hash; /// assert_eq!(arr[1..=3], [ 1,2,3 ]); /// ``` /// -/// [`IntoIterator`]: ../iter/trait.Iterator.html -/// [`Iterator`]: ../iter/trait.IntoIterator.html -/// [slicing index]: ../slice/trait.SliceIndex.html +/// [`IntoIterator`]: crate::iter::IntoIterator +/// [`Iterator`]: crate::iter::Iterator +/// [slicing index]: crate::slice::SliceIndex #[cfg_attr(not(bootstrap), lang = "RangeFull")] #[doc(alias = "..")] #[derive(Copy, Clone, Default, PartialEq, Eq, Hash)] @@ -179,7 +179,7 @@ impl> Range { /// assert_eq!(arr[1..=3], [ 1,2,3 ]); /// ``` /// -/// [`Iterator`]: ../iter/trait.IntoIterator.html +/// [`Iterator`]: crate::iter::IntoIterator #[cfg_attr(not(bootstrap), lang = "RangeFrom")] #[doc(alias = "..")] #[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186 @@ -260,9 +260,9 @@ impl> RangeFrom { /// assert_eq!(arr[1..=3], [ 1,2,3 ]); /// ``` /// -/// [`IntoIterator`]: ../iter/trait.Iterator.html -/// [`Iterator`]: ../iter/trait.IntoIterator.html -/// [slicing index]: ../slice/trait.SliceIndex.html +/// [`IntoIterator`]: crate::iter::IntoIterator +/// [`Iterator`]: crate::iter::Iterator +/// [slicing index]: crate::slice::SliceIndex #[cfg_attr(not(bootstrap), lang = "RangeTo")] #[doc(alias = "..")] #[derive(Copy, Clone, PartialEq, Eq, Hash)] @@ -315,8 +315,8 @@ impl> RangeTo { /// iteration has finished are **unspecified** other than that [`.is_empty()`] /// will return `true` once no more values will be produced. /// -/// [fused]: ../iter/trait.FusedIterator.html -/// [`.is_empty()`]: #method.is_empty +/// [fused]: crate::iter::FusedIterator +/// [`.is_empty()`]: RangeInclusive::is_empty /// /// # Examples /// @@ -383,8 +383,8 @@ impl RangeInclusive { /// Note: the value returned by this method is unspecified after the range /// has been iterated to exhaustion. /// - /// [`end()`]: #method.end - /// [`is_empty()`]: #method.is_empty + /// [`end()`]: RangeInclusive::end + /// [`is_empty()`]: RangeInclusive::is_empty /// /// # Examples /// @@ -408,8 +408,8 @@ impl RangeInclusive { /// Note: the value returned by this method is unspecified after the range /// has been iterated to exhaustion. /// - /// [`start()`]: #method.start - /// [`is_empty()`]: #method.is_empty + /// [`start()`]: RangeInclusive::start + /// [`is_empty()`]: RangeInclusive::is_empty /// /// # Examples /// @@ -558,9 +558,9 @@ impl> RangeInclusive { /// assert_eq!(arr[1..=3], [ 1,2,3 ]); /// ``` /// -/// [`IntoIterator`]: ../iter/trait.Iterator.html -/// [`Iterator`]: ../iter/trait.IntoIterator.html -/// [slicing index]: ../slice/trait.SliceIndex.html +/// [`IntoIterator`]: crate::iter::IntoIterator +/// [`Iterator`]: crate::iter::Iterator +/// [slicing index]: crate::slice::SliceIndex #[cfg_attr(not(bootstrap), lang = "RangeToInclusive")] #[doc(alias = "..=")] #[derive(Copy, Clone, PartialEq, Eq, Hash)] diff --git a/library/core/src/ops/unsize.rs b/library/core/src/ops/unsize.rs index 95a4393592be9..483362023b22c 100644 --- a/library/core/src/ops/unsize.rs +++ b/library/core/src/ops/unsize.rs @@ -29,7 +29,7 @@ use crate::marker::Unsize; /// pointers. It is implemented automatically by the compiler. /// /// [dst-coerce]: https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md -/// [unsize]: ../marker/trait.Unsize.html +/// [unsize]: crate::marker::Unsize /// [nomicon-coerce]: ../../nomicon/coercions.html #[unstable(feature = "coerce_unsized", issue = "27732")] #[lang = "coerce_unsized"] From 9424ac79b24a498f93b3a915dad3993edc6006ca Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Fri, 21 Aug 2020 23:25:07 +0200 Subject: [PATCH 43/44] Remove links that get imported from the prelude --- library/core/src/ops/drop.rs | 6 ++---- library/core/src/ops/index.rs | 1 - library/core/src/ops/mod.rs | 2 +- library/core/src/ops/range.rs | 8 -------- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/library/core/src/ops/drop.rs b/library/core/src/ops/drop.rs index 0824753db7580..ce7d1c3d06ddc 100644 --- a/library/core/src/ops/drop.rs +++ b/library/core/src/ops/drop.rs @@ -80,7 +80,7 @@ /// /// If you'd like explicitly call the destructor of a value, [`mem::drop`] can be used instead. /// -/// [`mem::drop`]: crate::mem::drop +/// [`mem::drop`]: drop /// /// ## Drop order /// @@ -132,8 +132,6 @@ /// are `Copy` get implicitly duplicated by the compiler, making it very /// hard to predict when, and how often destructors will be executed. As such, /// these types cannot have destructors. -/// -/// [`Copy`]: crate::marker::Copy #[lang = "drop"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Drop { @@ -160,7 +158,7 @@ pub trait Drop { /// /// [E0040]: ../../error-index.html#E0040 /// [`panic!`]: crate::panic! - /// [`mem::drop`]: crate::mem::drop + /// [`mem::drop`]: drop /// [`ptr::drop_in_place`]: crate::ptr::drop_in_place #[stable(feature = "rust1", since = "1.0.0")] fn drop(&mut self); diff --git a/library/core/src/ops/index.rs b/library/core/src/ops/index.rs index 9c2da00ae2f85..3c2ada5761233 100644 --- a/library/core/src/ops/index.rs +++ b/library/core/src/ops/index.rs @@ -4,7 +4,6 @@ /// but only when used as an immutable value. If a mutable value is requested, /// [`IndexMut`] is used instead. This allows nice things such as /// `let value = v[index]` if the type of `value` implements [`Copy`]. -/// [`Copy`]: crate::marker::Copy /// /// # Examples /// diff --git a/library/core/src/ops/mod.rs b/library/core/src/ops/mod.rs index ddcea46a552bb..c19bd6e441e69 100644 --- a/library/core/src/ops/mod.rs +++ b/library/core/src/ops/mod.rs @@ -133,7 +133,7 @@ //! // `consume_and_return_x` can no longer be invoked at this point //! ``` //! -//! [`clone`]: crate::clone::Clone::clone +//! [`clone`]: Clone::clone //! [operator precedence]: ../../reference/expressions.html#expression-precedence #![stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs index 5614c30b43e02..ccabd66aaf6eb 100644 --- a/library/core/src/ops/range.rs +++ b/library/core/src/ops/range.rs @@ -35,8 +35,6 @@ use crate::hash::Hash; /// assert_eq!(arr[1..=3], [ 1,2,3 ]); /// ``` /// -/// [`IntoIterator`]: crate::iter::IntoIterator -/// [`Iterator`]: crate::iter::Iterator /// [slicing index]: crate::slice::SliceIndex #[cfg_attr(not(bootstrap), lang = "RangeFull")] #[doc(alias = "..")] @@ -178,8 +176,6 @@ impl> Range { /// assert_eq!(arr[1.. 3], [ 1,2 ]); /// assert_eq!(arr[1..=3], [ 1,2,3 ]); /// ``` -/// -/// [`Iterator`]: crate::iter::IntoIterator #[cfg_attr(not(bootstrap), lang = "RangeFrom")] #[doc(alias = "..")] #[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186 @@ -260,8 +256,6 @@ impl> RangeFrom { /// assert_eq!(arr[1..=3], [ 1,2,3 ]); /// ``` /// -/// [`IntoIterator`]: crate::iter::IntoIterator -/// [`Iterator`]: crate::iter::Iterator /// [slicing index]: crate::slice::SliceIndex #[cfg_attr(not(bootstrap), lang = "RangeTo")] #[doc(alias = "..")] @@ -558,8 +552,6 @@ impl> RangeInclusive { /// assert_eq!(arr[1..=3], [ 1,2,3 ]); /// ``` /// -/// [`IntoIterator`]: crate::iter::IntoIterator -/// [`Iterator`]: crate::iter::Iterator /// [slicing index]: crate::slice::SliceIndex #[cfg_attr(not(bootstrap), lang = "RangeToInclusive")] #[doc(alias = "..=")] From 385a1b247663a487e681bf522dac99c656209782 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 21 Aug 2020 20:43:36 +0200 Subject: [PATCH 44/44] Add more links --- library/core/src/str/pattern.rs | 101 +++++++++++++++++--------------- 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/library/core/src/str/pattern.rs b/library/core/src/str/pattern.rs index 0e53d72b393b4..1cc2de5b8756a 100644 --- a/library/core/src/str/pattern.rs +++ b/library/core/src/str/pattern.rs @@ -45,13 +45,13 @@ use crate::slice::memchr; /// A string pattern. /// /// A `Pattern<'a>` expresses that the implementing type -/// can be used as a string pattern for searching in a `&'a str`. +/// can be used as a string pattern for searching in a [`&'a str`][str]. /// /// For example, both `'a'` and `"aa"` are patterns that /// would match at index `1` in the string `"baaaab"`. /// /// The trait itself acts as a builder for an associated -/// `Searcher` type, which does the actual work of finding +/// [`Searcher`] type, which does the actual work of finding /// occurrences of the pattern in a string. /// /// Depending on the type of the pattern, the behaviour of methods like @@ -156,7 +156,7 @@ pub trait Pattern<'a>: Sized { // Searcher -/// Result of calling `Searcher::next()` or `ReverseSearcher::next_back()`. +/// Result of calling [`Searcher::next()`] or [`ReverseSearcher::next_back()`]. #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum SearchStep { /// Expresses that a match of the pattern has been found at @@ -179,44 +179,47 @@ pub enum SearchStep { /// matches of a pattern starting from the front (left) of a string. /// /// It will be implemented by associated `Searcher` -/// types of the `Pattern` trait. +/// types of the [`Pattern`] trait. /// /// The trait is marked unsafe because the indices returned by the -/// `next()` methods are required to lie on valid utf8 boundaries in -/// the haystack. This enables consumers of this trait to +/// [`next()`][Searcher::next] methods are required to lie on valid utf8 +/// boundaries in the haystack. This enables consumers of this trait to /// slice the haystack without additional runtime checks. pub unsafe trait Searcher<'a> { /// Getter for the underlying string to be searched in /// - /// Will always return the same `&str` + /// Will always return the same [`&str`][str]. fn haystack(&self) -> &'a str; /// Performs the next search step starting from the front. /// - /// - Returns `Match(a, b)` if `haystack[a..b]` matches the pattern. - /// - Returns `Reject(a, b)` if `haystack[a..b]` can not match the - /// pattern, even partially. - /// - Returns `Done` if every byte of the haystack has been visited + /// - Returns [`Match(a, b)`][SearchStep::Match] if `haystack[a..b]` matches + /// the pattern. + /// - Returns [`Reject(a, b)`][SearchStep::Reject] if `haystack[a..b]` can + /// not match the pattern, even partially. + /// - Returns [`Done`][SearchStep::Done] if every byte of the haystack has + /// been visited. /// - /// The stream of `Match` and `Reject` values up to a `Done` + /// The stream of [`Match`][SearchStep::Match] and + /// [`Reject`][SearchStep::Reject] values up to a [`Done`][SearchStep::Done] /// will contain index ranges that are adjacent, non-overlapping, /// covering the whole haystack, and laying on utf8 boundaries. /// - /// A `Match` result needs to contain the whole matched pattern, - /// however `Reject` results may be split up into arbitrary - /// many adjacent fragments. Both ranges may have zero length. + /// A [`Match`][SearchStep::Match] result needs to contain the whole matched + /// pattern, however [`Reject`][SearchStep::Reject] results may be split up + /// into arbitrary many adjacent fragments. Both ranges may have zero length. /// /// As an example, the pattern `"aaa"` and the haystack `"cbaaaaab"` /// might produce the stream /// `[Reject(0, 1), Reject(1, 2), Match(2, 5), Reject(5, 8)]` fn next(&mut self) -> SearchStep; - /// Finds the next `Match` result. See `next()` + /// Finds the next [`Match`][SearchStep::Match] result. See [`next()`][Searcher::next]. /// - /// Unlike next(), there is no guarantee that the returned ranges - /// of this and next_reject will overlap. This will return (start_match, end_match), - /// where start_match is the index of where the match begins, and end_match is - /// the index after the end of the match. + /// Unlike [`next()`][Searcher::next], there is no guarantee that the returned ranges + /// of this and [`next_reject`][Searcher::next_reject] will overlap. This will return + /// `(start_match, end_match)`, where start_match is the index of where + /// the match begins, and end_match is the index after the end of the match. #[inline] fn next_match(&mut self) -> Option<(usize, usize)> { loop { @@ -228,10 +231,11 @@ pub unsafe trait Searcher<'a> { } } - /// Finds the next `Reject` result. See `next()` and `next_match()` + /// Finds the next [`Reject`][SearchStep::Reject] result. See [`next()`][Searcher::next] + /// and [`next_match()`][Searcher::next_match]. /// - /// Unlike next(), there is no guarantee that the returned ranges - /// of this and next_match will overlap. + /// Unlike [`next()`][Searcher::next], there is no guarantee that the returned ranges + /// of this and [`next_match`][Searcher::next_match] will overlap. #[inline] fn next_reject(&mut self) -> Option<(usize, usize)> { loop { @@ -249,37 +253,41 @@ pub unsafe trait Searcher<'a> { /// This trait provides methods for searching for non-overlapping /// matches of a pattern starting from the back (right) of a string. /// -/// It will be implemented by associated `Searcher` -/// types of the `Pattern` trait if the pattern supports searching +/// It will be implemented by associated [`Searcher`] +/// types of the [`Pattern`] trait if the pattern supports searching /// for it from the back. /// /// The index ranges returned by this trait are not required /// to exactly match those of the forward search in reverse. /// /// For the reason why this trait is marked unsafe, see them -/// parent trait `Searcher`. +/// parent trait [`Searcher`]. pub unsafe trait ReverseSearcher<'a>: Searcher<'a> { /// Performs the next search step starting from the back. /// - /// - Returns `Match(a, b)` if `haystack[a..b]` matches the pattern. - /// - Returns `Reject(a, b)` if `haystack[a..b]` can not match the - /// pattern, even partially. - /// - Returns `Done` if every byte of the haystack has been visited + /// - Returns [`Match(a, b)`][SearchStep::Match] if `haystack[a..b]` + /// matches the pattern. + /// - Returns [`Reject(a, b)`][SearchStep::Reject] if `haystack[a..b]` + /// can not match the pattern, even partially. + /// - Returns [`Done`][SearchStep::Done] if every byte of the haystack + /// has been visited /// - /// The stream of `Match` and `Reject` values up to a `Done` + /// The stream of [`Match`][SearchStep::Match] and + /// [`Reject`][SearchStep::Reject] values up to a [`Done`][SearchStep::Done] /// will contain index ranges that are adjacent, non-overlapping, /// covering the whole haystack, and laying on utf8 boundaries. /// - /// A `Match` result needs to contain the whole matched pattern, - /// however `Reject` results may be split up into arbitrary - /// many adjacent fragments. Both ranges may have zero length. + /// A [`Match`][SearchStep::Match] result needs to contain the whole matched + /// pattern, however [`Reject`][SearchStep::Reject] results may be split up + /// into arbitrary many adjacent fragments. Both ranges may have zero length. /// /// As an example, the pattern `"aaa"` and the haystack `"cbaaaaab"` /// might produce the stream - /// `[Reject(7, 8), Match(4, 7), Reject(1, 4), Reject(0, 1)]` + /// `[Reject(7, 8), Match(4, 7), Reject(1, 4), Reject(0, 1)]`. fn next_back(&mut self) -> SearchStep; - /// Finds the next `Match` result. See `next_back()` + /// Finds the next [`Match`][SearchStep::Match] result. + /// See [`next_back()`][ReverseSearcher::next_back]. #[inline] fn next_match_back(&mut self) -> Option<(usize, usize)> { loop { @@ -291,7 +299,8 @@ pub unsafe trait ReverseSearcher<'a>: Searcher<'a> { } } - /// Finds the next `Reject` result. See `next_back()` + /// Finds the next [`Reject`][SearchStep::Reject] result. + /// See [`next_back()`][ReverseSearcher::next_back]. #[inline] fn next_reject_back(&mut self) -> Option<(usize, usize)> { loop { @@ -304,10 +313,10 @@ pub unsafe trait ReverseSearcher<'a>: Searcher<'a> { } } -/// A marker trait to express that a `ReverseSearcher` -/// can be used for a `DoubleEndedIterator` implementation. +/// A marker trait to express that a [`ReverseSearcher`] +/// can be used for a [`DoubleEndedIterator`] implementation. /// -/// For this, the impl of `Searcher` and `ReverseSearcher` need +/// For this, the impl of [`Searcher`] and [`ReverseSearcher`] need /// to follow these conditions: /// /// - All results of `next()` need to be identical @@ -319,7 +328,7 @@ pub unsafe trait ReverseSearcher<'a>: Searcher<'a> { /// # Examples /// /// `char::Searcher` is a `DoubleEndedSearcher` because searching for a -/// `char` only requires looking at one at a time, which behaves the same +/// [`char`] only requires looking at one at a time, which behaves the same /// from both ends. /// /// `(&str)::Searcher` is not a `DoubleEndedSearcher` because @@ -346,13 +355,13 @@ pub struct CharSearcher<'a> { /// `finger_back` is the current byte index of the reverse search. /// Imagine that it exists after the byte at its index, i.e. /// haystack[finger_back - 1] is the last byte of the slice we must inspect during - /// forward searching (and thus the first byte to be inspected when calling next_back()) + /// forward searching (and thus the first byte to be inspected when calling next_back()). finger_back: usize, /// The character being searched for needle: char, // safety invariant: `utf8_size` must be less than 5 - /// The number of bytes `needle` takes up when encoded in utf8 + /// The number of bytes `needle` takes up when encoded in utf8. utf8_size: usize, /// A utf8 encoded copy of the `needle` utf8_encoded: [u8; 4], @@ -512,7 +521,7 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> { impl<'a> DoubleEndedSearcher<'a> for CharSearcher<'a> {} -/// Searches for chars that are equal to a given `char`. +/// Searches for chars that are equal to a given [`char`]. /// /// # Examples /// @@ -763,7 +772,7 @@ unsafe impl<'a, 'b> ReverseSearcher<'a> for CharSliceSearcher<'a, 'b> { impl<'a, 'b> DoubleEndedSearcher<'a> for CharSliceSearcher<'a, 'b> {} -/// Searches for chars that are equal to any of the chars in the slice. +/// Searches for chars that are equal to any of the [`char`]s in the slice. /// /// # Examples /// @@ -812,7 +821,7 @@ where impl<'a, F> DoubleEndedSearcher<'a> for CharPredicateSearcher<'a, F> where F: FnMut(char) -> bool {} -/// Searches for chars that match the given predicate. +/// Searches for [`char`]s that match the given predicate. /// /// # Examples ///