Skip to content

Commit d7efb3c

Browse files
authored
Merge pull request #279 from dtolnay/doccfg
Render doc(cfg) notices on docs.rs
2 parents 5da3686 + e2e6f71 commit d7efb3c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ token-based libraries from the procedural macro use case.
1616

1717
[package.metadata.docs.rs]
1818
rustc-args = ["--cfg", "procmacro2_semver_exempt"]
19-
rustdoc-args = ["--cfg", "procmacro2_semver_exempt"]
19+
rustdoc-args = ["--cfg", "procmacro2_semver_exempt", "--cfg", "doc_cfg"]
2020
targets = ["x86_64-unknown-linux-gnu"]
2121

2222
[package.metadata.playground]

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.24")]
8282
#![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))]
8383
#![cfg_attr(super_unstable, feature(proc_macro_raw_ident, proc_macro_def_site))]
84+
#![cfg_attr(doc_cfg, feature(doc_cfg))]
8485
#![allow(clippy::needless_doctest_main, clippy::vec_init_then_push)]
8586

8687
#[cfg(use_proc_macro)]
@@ -267,6 +268,7 @@ impl Error for LexError {}
267268
///
268269
/// This type is semver exempt and not exposed by default.
269270
#[cfg(procmacro2_semver_exempt)]
271+
#[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
270272
#[derive(Clone, PartialEq, Eq)]
271273
pub struct SourceFile {
272274
inner: imp::SourceFile,
@@ -317,6 +319,7 @@ impl Debug for SourceFile {
317319
///
318320
/// This type is semver exempt and not exposed by default.
319321
#[cfg(span_locations)]
322+
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
320323
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
321324
pub struct LineColumn {
322325
/// The 1-indexed line in the source file on which the span starts or ends
@@ -388,6 +391,7 @@ impl Span {
388391
///
389392
/// This method is semver exempt and not exposed by default.
390393
#[cfg(procmacro2_semver_exempt)]
394+
#[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
391395
pub fn def_site() -> Span {
392396
Span::_new(imp::Span::def_site())
393397
}
@@ -430,6 +434,7 @@ impl Span {
430434
///
431435
/// This method is semver exempt and not exposed by default.
432436
#[cfg(procmacro2_semver_exempt)]
437+
#[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
433438
pub fn source_file(&self) -> SourceFile {
434439
SourceFile::_new(self.inner.source_file())
435440
}
@@ -444,6 +449,7 @@ impl Span {
444449
/// outside of a procedural macro, such as main.rs or build.rs, the
445450
/// line/column are always meaningful regardless of toolchain.
446451
#[cfg(span_locations)]
452+
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
447453
pub fn start(&self) -> LineColumn {
448454
let imp::LineColumn { line, column } = self.inner.start();
449455
LineColumn { line, column }
@@ -459,6 +465,7 @@ impl Span {
459465
/// outside of a procedural macro, such as main.rs or build.rs, the
460466
/// line/column are always meaningful regardless of toolchain.
461467
#[cfg(span_locations)]
468+
#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
462469
pub fn end(&self) -> LineColumn {
463470
let imp::LineColumn { line, column } = self.inner.end();
464471
LineColumn { line, column }
@@ -481,6 +488,7 @@ impl Span {
481488
///
482489
/// This method is semver exempt and not exposed by default.
483490
#[cfg(procmacro2_semver_exempt)]
491+
#[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
484492
pub fn eq(&self, other: &Span) -> bool {
485493
self.inner.eq(&other.inner)
486494
}
@@ -911,6 +919,7 @@ impl Ident {
911919
///
912920
/// This method is semver exempt and not exposed by default.
913921
#[cfg(procmacro2_semver_exempt)]
922+
#[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
914923
pub fn new_raw(string: &str, span: Span) -> Ident {
915924
Ident::_new_raw(string, span)
916925
}

0 commit comments

Comments
 (0)