Skip to content

Commit a8f1484

Browse files
committed
Rely on docs.rs to define --cfg=docsrs by default
1 parent 9e32a40 commit a8f1484

File tree

7 files changed

+84
-85
lines changed

7 files changed

+84
-85
lines changed

serde/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ features = ["derive", "rc"]
2929
[package.metadata.docs.rs]
3030
features = ["derive", "rc", "unstable"]
3131
targets = ["x86_64-unknown-linux-gnu"]
32-
rustdoc-args = ["--cfg", "doc_cfg", "--generate-link-to-definition"]
32+
rustdoc-args = ["--generate-link-to-definition"]
3333

3434
# This cfg cannot be enabled, but it still forces Cargo to keep serde_derive's
3535
# version in lockstep with serde's, even if someone depends on the two crates

serde/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ fn main() {
1414
};
1515

1616
if minor >= 77 {
17-
println!("cargo:rustc-check-cfg=cfg(doc_cfg)");
1817
println!("cargo:rustc-check-cfg=cfg(no_core_cstr)");
1918
println!("cargo:rustc-check-cfg=cfg(no_core_num_saturating)");
2019
println!("cargo:rustc-check-cfg=cfg(no_core_try_from)");

serde/src/de/impls.rs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'de> Deserialize<'de> for () {
3939
}
4040

4141
#[cfg(feature = "unstable")]
42-
#[cfg_attr(doc_cfg, doc(cfg(feature = "unstable")))]
42+
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
4343
impl<'de> Deserialize<'de> for ! {
4444
fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
4545
where
@@ -695,7 +695,7 @@ impl<'a, 'de> Visitor<'de> for StringInPlaceVisitor<'a> {
695695
}
696696

697697
#[cfg(any(feature = "std", feature = "alloc"))]
698-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
698+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
699699
impl<'de> Deserialize<'de> for String {
700700
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
701701
where
@@ -839,7 +839,7 @@ impl<'de> Visitor<'de> for CStringVisitor {
839839
}
840840

841841
#[cfg(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))]
842-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
842+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
843843
impl<'de> Deserialize<'de> for CString {
844844
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
845845
where
@@ -868,7 +868,7 @@ macro_rules! forwarded_impl {
868868

869869
forwarded_impl! {
870870
#[cfg(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))]
871-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
871+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
872872
(), Box<CStr>, CString::into_boxed_c_str
873873
}
874874

@@ -1086,7 +1086,7 @@ fn nop_reserve<T>(_seq: T, _n: usize) {}
10861086

10871087
seq_impl!(
10881088
#[cfg(any(feature = "std", feature = "alloc"))]
1089-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1089+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
10901090
BinaryHeap<T: Ord>,
10911091
seq,
10921092
BinaryHeap::clear,
@@ -1097,7 +1097,7 @@ seq_impl!(
10971097

10981098
seq_impl!(
10991099
#[cfg(any(feature = "std", feature = "alloc"))]
1100-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1100+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
11011101
BTreeSet<T: Eq + Ord>,
11021102
seq,
11031103
BTreeSet::clear,
@@ -1108,7 +1108,7 @@ seq_impl!(
11081108

11091109
seq_impl!(
11101110
#[cfg(any(feature = "std", feature = "alloc"))]
1111-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1111+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
11121112
LinkedList<T>,
11131113
seq,
11141114
LinkedList::clear,
@@ -1119,7 +1119,7 @@ seq_impl!(
11191119

11201120
seq_impl!(
11211121
#[cfg(feature = "std")]
1122-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
1122+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
11231123
HashSet<T: Eq + Hash, S: BuildHasher + Default>,
11241124
seq,
11251125
HashSet::clear,
@@ -1130,7 +1130,7 @@ seq_impl!(
11301130

11311131
seq_impl!(
11321132
#[cfg(any(feature = "std", feature = "alloc"))]
1133-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1133+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
11341134
VecDeque<T>,
11351135
seq,
11361136
VecDeque::clear,
@@ -1142,7 +1142,7 @@ seq_impl!(
11421142
////////////////////////////////////////////////////////////////////////////////
11431143

11441144
#[cfg(any(feature = "std", feature = "alloc"))]
1145-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1145+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
11461146
impl<'de, T> Deserialize<'de> for Vec<T>
11471147
where
11481148
T: Deserialize<'de>,
@@ -1546,15 +1546,15 @@ macro_rules! map_impl {
15461546

15471547
map_impl! {
15481548
#[cfg(any(feature = "std", feature = "alloc"))]
1549-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1549+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
15501550
BTreeMap<K: Ord, V>,
15511551
map,
15521552
BTreeMap::new(),
15531553
}
15541554

15551555
map_impl! {
15561556
#[cfg(feature = "std")]
1557-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
1557+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
15581558
HashMap<K: Eq + Hash, V, S: BuildHasher + Default>,
15591559
map,
15601560
HashMap::with_capacity_and_hasher(size_hint::cautious::<(K, V)>(map.size_hint()), S::default()),
@@ -1696,7 +1696,7 @@ macro_rules! deserialize_enum {
16961696
}
16971697

16981698
#[cfg(feature = "std")]
1699-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
1699+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
17001700
impl<'de> Deserialize<'de> for net::IpAddr {
17011701
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
17021702
where
@@ -1717,13 +1717,13 @@ impl<'de> Deserialize<'de> for net::IpAddr {
17171717

17181718
parse_ip_impl! {
17191719
#[cfg(feature = "std")]
1720-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
1720+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
17211721
net::Ipv4Addr, "IPv4 address", 4
17221722
}
17231723

17241724
parse_ip_impl! {
17251725
#[cfg(feature = "std")]
1726-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
1726+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
17271727
net::Ipv6Addr, "IPv6 address", 16
17281728
}
17291729

@@ -1750,7 +1750,7 @@ macro_rules! parse_socket_impl {
17501750
}
17511751

17521752
#[cfg(feature = "std")]
1753-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
1753+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
17541754
impl<'de> Deserialize<'de> for net::SocketAddr {
17551755
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
17561756
where
@@ -1771,14 +1771,14 @@ impl<'de> Deserialize<'de> for net::SocketAddr {
17711771

17721772
parse_socket_impl! {
17731773
#[cfg(feature = "std")]
1774-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
1774+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
17751775
net::SocketAddrV4, "IPv4 socket address",
17761776
|(ip, port)| net::SocketAddrV4::new(ip, port),
17771777
}
17781778

17791779
parse_socket_impl! {
17801780
#[cfg(feature = "std")]
1781-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
1781+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
17821782
net::SocketAddrV6, "IPv6 socket address",
17831783
|(ip, port)| net::SocketAddrV6::new(ip, port, 0, 0),
17841784
}
@@ -1814,7 +1814,7 @@ impl<'a> Visitor<'a> for PathVisitor {
18141814
}
18151815

18161816
#[cfg(feature = "std")]
1817-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
1817+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
18181818
impl<'de: 'a, 'a> Deserialize<'de> for &'a Path {
18191819
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
18201820
where
@@ -1869,7 +1869,7 @@ impl<'de> Visitor<'de> for PathBufVisitor {
18691869
}
18701870

18711871
#[cfg(feature = "std")]
1872-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
1872+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
18731873
impl<'de> Deserialize<'de> for PathBuf {
18741874
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
18751875
where
@@ -1881,7 +1881,7 @@ impl<'de> Deserialize<'de> for PathBuf {
18811881

18821882
forwarded_impl! {
18831883
#[cfg(feature = "std")]
1884-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
1884+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
18851885
(), Box<Path>, PathBuf::into_boxed_path
18861886
}
18871887

@@ -1943,7 +1943,7 @@ impl<'de> Visitor<'de> for OsStringVisitor {
19431943
}
19441944

19451945
#[cfg(all(feature = "std", any(unix, windows)))]
1946-
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "std", any(unix, windows)))))]
1946+
#[cfg_attr(docsrs, doc(cfg(all(feature = "std", any(unix, windows)))))]
19471947
impl<'de> Deserialize<'de> for OsString {
19481948
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
19491949
where
@@ -1957,30 +1957,30 @@ impl<'de> Deserialize<'de> for OsString {
19571957

19581958
forwarded_impl! {
19591959
#[cfg(any(feature = "std", feature = "alloc"))]
1960-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1960+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
19611961
(T), Box<T>, Box::new
19621962
}
19631963

19641964
forwarded_impl! {
19651965
#[cfg(any(feature = "std", feature = "alloc"))]
1966-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1966+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
19671967
(T), Box<[T]>, Vec::into_boxed_slice
19681968
}
19691969

19701970
forwarded_impl! {
19711971
#[cfg(any(feature = "std", feature = "alloc"))]
1972-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1972+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
19731973
(), Box<str>, String::into_boxed_str
19741974
}
19751975

19761976
forwarded_impl! {
19771977
#[cfg(all(feature = "std", any(unix, windows)))]
1978-
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "std", any(unix, windows)))))]
1978+
#[cfg_attr(docsrs, doc(cfg(all(feature = "std", any(unix, windows)))))]
19791979
(), Box<OsStr>, OsString::into_boxed_os_str
19801980
}
19811981

19821982
#[cfg(any(feature = "std", feature = "alloc"))]
1983-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1983+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
19841984
impl<'de, 'a, T> Deserialize<'de> for Cow<'a, T>
19851985
where
19861986
T: ?Sized + ToOwned,
@@ -2003,7 +2003,7 @@ where
20032003
/// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
20042004
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
20052005
#[cfg_attr(
2006-
doc_cfg,
2006+
docsrs,
20072007
doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc"))))
20082008
)]
20092009
impl<'de, T> Deserialize<'de> for RcWeak<T>
@@ -2025,7 +2025,7 @@ where
20252025
/// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
20262026
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
20272027
#[cfg_attr(
2028-
doc_cfg,
2028+
docsrs,
20292029
doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc"))))
20302030
)]
20312031
impl<'de, T> Deserialize<'de> for ArcWeak<T>
@@ -2073,7 +2073,7 @@ box_forwarded_impl! {
20732073
///
20742074
/// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
20752075
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
2076-
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))))]
2076+
#[cfg_attr(docsrs, doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))))]
20772077
Rc
20782078
}
20792079

@@ -2086,7 +2086,7 @@ box_forwarded_impl! {
20862086
///
20872087
/// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
20882088
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
2089-
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))))]
2089+
#[cfg_attr(docsrs, doc(cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))))]
20902090
Arc
20912091
}
20922092

@@ -2110,13 +2110,13 @@ forwarded_impl! {
21102110

21112111
forwarded_impl! {
21122112
#[cfg(feature = "std")]
2113-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
2113+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
21142114
(T), Mutex<T>, Mutex::new
21152115
}
21162116

21172117
forwarded_impl! {
21182118
#[cfg(feature = "std")]
2119-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
2119+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
21202120
(T), RwLock<T>, RwLock::new
21212121
}
21222122

@@ -2271,7 +2271,7 @@ impl<'de> Deserialize<'de> for Duration {
22712271
////////////////////////////////////////////////////////////////////////////////
22722272

22732273
#[cfg(feature = "std")]
2274-
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
2274+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
22752275
impl<'de> Deserialize<'de> for SystemTime {
22762276
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
22772277
where
@@ -3107,7 +3107,7 @@ macro_rules! atomic_impl {
31073107
($($ty:ident $size:expr)*) => {
31083108
$(
31093109
#[cfg(any(no_target_has_atomic, target_has_atomic = $size))]
3110-
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "std", target_has_atomic = $size))))]
3110+
#[cfg_attr(docsrs, doc(cfg(all(feature = "std", target_has_atomic = $size))))]
31113111
impl<'de> Deserialize<'de> for $ty {
31123112
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
31133113
where

serde/src/de/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ pub trait Visitor<'de>: Sized {
15251525
/// `String`.
15261526
#[inline]
15271527
#[cfg(any(feature = "std", feature = "alloc"))]
1528-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1528+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
15291529
fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
15301530
where
15311531
E: Error,
@@ -1584,7 +1584,7 @@ pub trait Visitor<'de>: Sized {
15841584
/// The default implementation forwards to `visit_bytes` and then drops the
15851585
/// `Vec<u8>`.
15861586
#[cfg(any(feature = "std", feature = "alloc"))]
1587-
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "std", feature = "alloc"))))]
1587+
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
15881588
fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
15891589
where
15901590
E: Error,

0 commit comments

Comments
 (0)