Skip to content

Commit 890ad8b

Browse files
authored
Rename doc_cfg to docsrs and use doc_auto_cfg (#1450)
1 parent 1b762b2 commit 890ad8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+19
-106
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"]
1919

2020
[package.metadata.docs.rs]
2121
# To build locally:
22-
# RUSTDOCFLAGS="--cfg doc_cfg -Zunstable-options --generate-link-to-definition" cargo +nightly doc --all --all-features --no-deps --open
22+
# RUSTDOCFLAGS="--cfg docsrs -Zunstable-options --generate-link-to-definition" cargo +nightly doc --all --all-features --no-deps --open
2323
all-features = true
24-
rustdoc-args = ["--cfg", "doc_cfg", "-Zunstable-options", "--generate-link-to-definition"]
24+
rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"]
2525

2626
[package.metadata.playground]
2727
features = ["small_rng", "serde1"]

rand_core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ rust-version = "1.61"
1717

1818
[package.metadata.docs.rs]
1919
# To build locally:
20-
# RUSTDOCFLAGS="--cfg doc_cfg" cargo +nightly doc --all-features --no-deps --open
20+
# RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features --no-deps --open
2121
all-features = true
22-
rustdoc-args = ["--cfg", "doc_cfg", "--generate-link-to-definition"]
22+
rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"]
2323

2424
[package.metadata.playground]
2525
all-features = true

rand_core/src/blanket_impls.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ impl<'a, R: TryRngCore + ?Sized> TryRngCore for &'a mut R {
4444
impl<'a, R: TryCryptoRng + ?Sized> TryCryptoRng for &'a mut R {}
4545

4646
#[cfg(feature = "alloc")]
47-
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
4847
impl<R: RngCore + ?Sized> RngCore for Box<R> {
4948
#[inline(always)]
5049
fn next_u32(&mut self) -> u32 {
@@ -63,11 +62,9 @@ impl<R: RngCore + ?Sized> RngCore for Box<R> {
6362
}
6463

6564
#[cfg(feature = "alloc")]
66-
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
6765
impl<R: CryptoRng + ?Sized> CryptoRng for Box<R> {}
6866

6967
#[cfg(feature = "alloc")]
70-
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
7168
impl<R: TryRngCore + ?Sized> TryRngCore for Box<R> {
7269
type Error = R::Error;
7370

@@ -88,5 +85,4 @@ impl<R: TryRngCore + ?Sized> TryRngCore for Box<R> {
8885
}
8986

9087
#[cfg(feature = "alloc")]
91-
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
9288
impl<R: TryCryptoRng + ?Sized> TryCryptoRng for Box<R> {}

rand_core/src/impls.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub fn next_u64_via_fill<R: RngCore + ?Sized>(rng: &mut R) -> u64 {
160160
u64::from_le_bytes(buf)
161161
}
162162

163-
/// Implement [`TryRngCore`] for a type implementing [`RngCore`].
163+
/// Implement [`TryRngCore`][crate::TryRngCore] for a type implementing [`RngCore`].
164164
///
165165
/// Ideally, `rand_core` would define blanket impls for this, but they conflict with blanket impls
166166
/// for `&mut R` and `Box<R>`, so until specialziation is stabilized, implementer crates
@@ -195,6 +195,10 @@ macro_rules! impl_try_rng_from_rng_core {
195195
/// Ideally, `rand_core` would define blanket impls for this, but they conflict with blanket impls
196196
/// for `&mut R` and `Box<R>`, so until specialziation is stabilized, implementer crates
197197
/// have to implement `TryRngCore` and `TryCryptoRng` directly.
198+
///
199+
/// [`TryCryptoRng`]: crate::TryCryptoRng
200+
/// [`TryRngCore`]: crate::TryRngCore
201+
/// [`CryptoRng`]: crate::CryptoRng
198202
#[macro_export]
199203
macro_rules! impl_try_crypto_rng_from_crypto_rng {
200204
($t:ty) => {

rand_core/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
#![deny(missing_docs)]
3333
#![deny(missing_debug_implementations)]
3434
#![doc(test(attr(allow(unused_variables), deny(warnings))))]
35-
#![allow(unexpected_cfgs)]
36-
#![cfg_attr(doc_cfg, feature(doc_cfg))]
35+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
3736
#![no_std]
3837

3938
#[cfg(feature = "alloc")]
@@ -446,7 +445,6 @@ pub trait SeedableRng: Sized {
446445
/// [`getrandom`]: https://docs.rs/getrandom
447446
/// [`try_from_os_rng`]: SeedableRng::try_from_os_rng
448447
#[cfg(feature = "getrandom")]
449-
#[cfg_attr(doc_cfg, doc(cfg(feature = "getrandom")))]
450448
fn from_os_rng() -> Self {
451449
match Self::try_from_os_rng() {
452450
Ok(res) => res,
@@ -463,7 +461,6 @@ pub trait SeedableRng: Sized {
463461
///
464462
/// [`getrandom`]: https://docs.rs/getrandom
465463
#[cfg(feature = "getrandom")]
466-
#[cfg_attr(doc_cfg, doc(cfg(feature = "getrandom")))]
467464
fn try_from_os_rng() -> Result<Self, getrandom::Error> {
468465
let mut seed = Self::Seed::default();
469466
getrandom::getrandom(seed.as_mut())?;

rand_core/src/os.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use getrandom::getrandom;
4444
/// ```
4545
///
4646
/// [getrandom]: https://crates.io/crates/getrandom
47-
#[cfg_attr(doc_cfg, doc(cfg(feature = "getrandom")))]
4847
#[derive(Clone, Copy, Debug, Default)]
4948
pub struct OsRng;
5049

rand_distr/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ rust-version = "1.61"
1717
include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"]
1818

1919
[package.metadata.docs.rs]
20-
rustdoc-args = ["--generate-link-to-definition"]
20+
rustdoc-args = ["--cfg docsrs", "--generate-link-to-definition"]
2121

2222
[features]
2323
default = ["std"]

rand_distr/src/binomial.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ impl fmt::Display for Error {
5858
}
5959

6060
#[cfg(feature = "std")]
61-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
6261
impl std::error::Error for Error {}
6362

6463
impl Binomial {

rand_distr/src/cauchy.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ impl fmt::Display for Error {
5858
}
5959

6060
#[cfg(feature = "std")]
61-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
6261
impl std::error::Error for Error {}
6362

6463
impl<F> Cauchy<F>

rand_distr/src/dirichlet.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ where
3131
}
3232

3333
/// Error type returned from `DirchletFromGamma::new`.
34-
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
3534
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
3635
enum DirichletFromGammaError {
3736
/// Gamma::new(a, 1) failed.
@@ -104,7 +103,6 @@ where
104103
}
105104

106105
/// Error type returned from `DirchletFromBeta::new`.
107-
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
108106
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
109107
enum DirichletFromBetaError {
110108
/// Beta::new(a, b) failed.
@@ -203,7 +201,6 @@ where
203201
/// let samples = dirichlet.sample(&mut rand::thread_rng());
204202
/// println!("{:?} is from a Dirichlet([1.0, 2.0, 3.0]) distribution", samples);
205203
/// ```
206-
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
207204
#[cfg_attr(feature = "serde_with", serde_as)]
208205
#[derive(Clone, Debug, PartialEq)]
209206
pub struct Dirichlet<F, const N: usize>
@@ -217,7 +214,6 @@ where
217214
}
218215

219216
/// Error type returned from `Dirchlet::new`.
220-
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
221217
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
222218
pub enum Error {
223219
/// `alpha.len() < 2`.
@@ -257,7 +253,6 @@ impl fmt::Display for Error {
257253
}
258254

259255
#[cfg(feature = "std")]
260-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
261256
impl std::error::Error for Error {}
262257

263258
impl<F, const N: usize> Dirichlet<F, N>

0 commit comments

Comments
 (0)