Skip to content

Commit abc7dff

Browse files
authored
Merge pull request #460 from dtolnay/docsrs
Rely on docs.rs to define --cfg=docsrs by default
2 parents 8dc63f3 + f8d88f3 commit abc7dff

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rust-version = "1.56"
1414

1515
[package.metadata.docs.rs]
1616
rustc-args = ["--cfg", "procmacro2_semver_exempt"]
17-
rustdoc-args = ["--cfg", "procmacro2_semver_exempt", "--cfg", "doc_cfg", "--generate-link-to-definition"]
17+
rustdoc-args = ["--cfg", "procmacro2_semver_exempt", "--generate-link-to-definition"]
1818
targets = ["x86_64-unknown-linux-gnu"]
1919

2020
[package.metadata.playground]

build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ fn main() {
4848
let rustc = rustc_minor_version().unwrap_or(u32::MAX);
4949

5050
if rustc >= 80 {
51-
println!("cargo:rustc-check-cfg=cfg(doc_cfg)");
5251
println!("cargo:rustc-check-cfg=cfg(fuzzing)");
5352
println!("cargo:rustc-check-cfg=cfg(no_is_available)");
5453
println!("cargo:rustc-check-cfg=cfg(no_literal_byte_character)");

src/extra.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ use core::fmt::{self, Debug};
6969
/// This function is not applicable to and will panic if called from a
7070
/// procedural macro.
7171
#[cfg(span_locations)]
72-
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
72+
#[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
7373
pub fn invalidate_current_thread_spans() {
7474
crate::imp::invalidate_current_thread_spans();
7575
}

src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.82")]
9090
#![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))]
9191
#![cfg_attr(super_unstable, feature(proc_macro_def_site))]
92-
#![cfg_attr(doc_cfg, feature(doc_cfg))]
92+
#![cfg_attr(docsrs, feature(doc_cfg))]
9393
#![deny(unsafe_op_in_unsafe_fn)]
9494
#![allow(
9595
clippy::cast_lossless,
@@ -175,7 +175,7 @@ use std::ffi::CStr;
175175
use std::path::PathBuf;
176176

177177
#[cfg(span_locations)]
178-
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
178+
#[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
179179
pub use crate::location::LineColumn;
180180

181181
/// An abstract stream of tokens, or more concretely a sequence of token trees.
@@ -252,15 +252,15 @@ impl FromStr for TokenStream {
252252
}
253253

254254
#[cfg(feature = "proc-macro")]
255-
#[cfg_attr(doc_cfg, doc(cfg(feature = "proc-macro")))]
255+
#[cfg_attr(docsrs, doc(cfg(feature = "proc-macro")))]
256256
impl From<proc_macro::TokenStream> for TokenStream {
257257
fn from(inner: proc_macro::TokenStream) -> Self {
258258
TokenStream::_new(inner.into())
259259
}
260260
}
261261

262262
#[cfg(feature = "proc-macro")]
263-
#[cfg_attr(doc_cfg, doc(cfg(feature = "proc-macro")))]
263+
#[cfg_attr(docsrs, doc(cfg(feature = "proc-macro")))]
264264
impl From<TokenStream> for proc_macro::TokenStream {
265265
fn from(inner: TokenStream) -> Self {
266266
inner.inner.into()
@@ -339,7 +339,7 @@ impl Error for LexError {}
339339
///
340340
/// This type is semver exempt and not exposed by default.
341341
#[cfg(all(procmacro2_semver_exempt, any(not(wrap_proc_macro), super_unstable)))]
342-
#[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
342+
#[cfg_attr(docsrs, doc(cfg(procmacro2_semver_exempt)))]
343343
#[derive(Clone, PartialEq, Eq)]
344344
pub struct SourceFile {
345345
inner: imp::SourceFile,
@@ -428,7 +428,7 @@ impl Span {
428428
///
429429
/// This method is semver exempt and not exposed by default.
430430
#[cfg(procmacro2_semver_exempt)]
431-
#[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
431+
#[cfg_attr(docsrs, doc(cfg(procmacro2_semver_exempt)))]
432432
pub fn def_site() -> Self {
433433
Span::_new(imp::Span::def_site())
434434
}
@@ -471,7 +471,7 @@ impl Span {
471471
///
472472
/// This method is semver exempt and not exposed by default.
473473
#[cfg(all(procmacro2_semver_exempt, any(not(wrap_proc_macro), super_unstable)))]
474-
#[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
474+
#[cfg_attr(docsrs, doc(cfg(procmacro2_semver_exempt)))]
475475
pub fn source_file(&self) -> SourceFile {
476476
SourceFile::_new(self.inner.source_file())
477477
}
@@ -486,7 +486,7 @@ impl Span {
486486
/// procedural macro, such as main.rs or build.rs, the byte range is always
487487
/// accurate regardless of toolchain.
488488
#[cfg(span_locations)]
489-
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
489+
#[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
490490
pub fn byte_range(&self) -> Range<usize> {
491491
self.inner.byte_range()
492492
}
@@ -501,7 +501,7 @@ impl Span {
501501
/// outside of a procedural macro, such as main.rs or build.rs, the
502502
/// line/column are always meaningful regardless of toolchain.
503503
#[cfg(span_locations)]
504-
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
504+
#[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
505505
pub fn start(&self) -> LineColumn {
506506
self.inner.start()
507507
}
@@ -516,7 +516,7 @@ impl Span {
516516
/// outside of a procedural macro, such as main.rs or build.rs, the
517517
/// line/column are always meaningful regardless of toolchain.
518518
#[cfg(span_locations)]
519-
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
519+
#[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
520520
pub fn end(&self) -> LineColumn {
521521
self.inner.end()
522522
}
@@ -538,7 +538,7 @@ impl Span {
538538
///
539539
/// This method is semver exempt and not exposed by default.
540540
#[cfg(procmacro2_semver_exempt)]
541-
#[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
541+
#[cfg_attr(docsrs, doc(cfg(procmacro2_semver_exempt)))]
542542
pub fn eq(&self, other: &Span) -> bool {
543543
self.inner.eq(&other.inner)
544544
}

src/location.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::cmp::Ordering;
33
/// A line-column pair representing the start or end of a `Span`.
44
///
55
/// This type is semver exempt and not exposed by default.
6-
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
6+
#[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
77
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
88
pub struct LineColumn {
99
/// The 1-indexed line in the source file on which the span starts or ends

0 commit comments

Comments
 (0)