Skip to content

Commit

Permalink
Work around docs.rs issue (rust-lang/docs.rs#2374)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylni committed Dec 30, 2023
1 parent de241ba commit fc3fa08
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
// Only require a nightly compiler when building documentation for docs.rs.
// This is a private option that should not be used.
// https://github.com/rust-lang/docs.rs/issues/147#issuecomment-389544407
#![cfg_attr(attr_alias_docs_rs, feature(doc_cfg))]
#![cfg_attr(feature = "nightly", feature(doc_cfg))]
#![cfg_attr(feature = "nightly", feature(track_path))]
#![forbid(unsafe_code)]
#![warn(unused_results)]
Expand Down Expand Up @@ -259,6 +259,8 @@ fn eval_item(item: TokenStream, resolved: &mut bool) -> Result<TokenStream> {
/// *Compiled using the [example alias file].*
///
/// ```
/// # #![cfg_attr(feature = "nightly", feature(doc_cfg))]
/// #
/// use std::process::Command;
///
/// use attr_alias::attr_alias;
Expand All @@ -268,7 +270,7 @@ fn eval_item(item: TokenStream, resolved: &mut bool) -> Result<TokenStream> {
/// impl ProcessBuilder {
/// #[attr_alias(macos_or_windows)]
#[cfg_attr(
attr_alias_docs_rs,
feature = "nightly",
doc = " #[attr_alias(macos_or_windows, doc(cfg(*)))]"
)]
/// fn name(&mut self, name: &str) -> &mut Self {
Expand All @@ -280,7 +282,7 @@ fn eval_item(item: TokenStream, resolved: &mut bool) -> Result<TokenStream> {
/// [example alias file]: self#example
/// [Rust identifier]: https://doc.rust-lang.org/reference/identifiers.html
#[cfg(feature = "nightly")]
#[cfg_attr(attr_alias_docs_rs, doc(cfg(feature = "nightly")))]
#[cfg_attr(feature = "nightly", doc(cfg(feature = "nightly")))]
#[proc_macro_attribute]
pub fn attr_alias(args: TokenStream, item: TokenStream) -> TokenStream {
tracked_path::path(Aliases::FILE);
Expand Down Expand Up @@ -376,6 +378,8 @@ pub fn eval_block(item: TokenStream) -> TokenStream {
/// **Conditionally Defining a Method:**
///
/// ```
/// # #![cfg_attr(feature = "nightly", feature(doc_cfg))]
/// #
/// use std::process::Command;
///
/// struct ProcessBuilder(Command);
Expand All @@ -384,7 +388,7 @@ pub fn eval_block(item: TokenStream) -> TokenStream {
/// impl ProcessBuilder {
/// #[attr_alias(macos_or_windows)]
#[cfg_attr(
attr_alias_docs_rs,
feature = "nightly",
doc = " #[attr_alias(macos_or_windows, doc(cfg(*)))]"
)]
/// fn name(&mut self, name: &str) -> &mut Self {
Expand Down

0 comments on commit fc3fa08

Please sign in to comment.