From fc5c98dba460b3ec2a6175e84e0dd4497d32ef30 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 18 May 2024 21:30:43 -0700 Subject: [PATCH] Rely on docs.rs to define --cfg=docsrs by default --- Cargo.toml | 2 +- build.rs | 1 - src/error.rs | 2 +- src/lib.rs | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 703fc1b2..12b7404f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,4 +23,4 @@ doc-scrape-examples = false [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] -rustdoc-args = ["--cfg", "doc_cfg", "--generate-link-to-definition"] +rustdoc-args = ["--generate-link-to-definition"] diff --git a/build.rs b/build.rs index 6a7b67e2..ae0aae9d 100644 --- a/build.rs +++ b/build.rs @@ -11,7 +11,6 @@ fn main() { }; if compiler >= 80 { - println!("cargo:rustc-check-cfg=cfg(doc_cfg)"); println!("cargo:rustc-check-cfg=cfg(no_alloc_crate)"); println!("cargo:rustc-check-cfg=cfg(no_const_vec_new)"); println!("cargo:rustc-check-cfg=cfg(no_exhaustive_int_match)"); diff --git a/src/error.rs b/src/error.rs index 93b05ee8..44c3b587 100644 --- a/src/error.rs +++ b/src/error.rs @@ -26,7 +26,7 @@ pub(crate) enum Position { } #[cfg(feature = "std")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl std::error::Error for Error {} impl Display for Error { diff --git a/src/lib.rs b/src/lib.rs index cc1296a5..64ceee46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,7 +61,7 @@ //! [Specifying Dependencies]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html #![doc(html_root_url = "https://docs.rs/semver/1.0.23")] -#![cfg_attr(doc_cfg, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(all(not(feature = "std"), not(no_alloc_crate)), no_std)] #![cfg_attr(not(no_unsafe_op_in_unsafe_fn_lint), deny(unsafe_op_in_unsafe_fn))] #![cfg_attr(no_unsafe_op_in_unsafe_fn_lint, allow(unused_unsafe))]