Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc doesn't handle #![feature] attributes #55938

Closed
QuietMisdreavus opened this issue Nov 13, 2018 · 5 comments
Closed

rustdoc doesn't handle #![feature] attributes #55938

QuietMisdreavus opened this issue Nov 13, 2018 · 5 comments
Labels
A-stability Area: `#[stable]`, `#[unstable]` etc. C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@QuietMisdreavus
Copy link
Member

With the following crate:

#![feature(doc_cfg)]

#[doc(cfg(unix))]
pub struct SomeStruct;

Attempting to build it on stable will fail as expected, but generating docs will pass, no problem:

$ cargo +stable build
   Compiling asdf v0.1.0 (/home/misdreavus/git/asdf)
error[E0554]: #![feature] may not be used on the stable release channel
 --> src/lib.rs:1:1
  |
1 | #![feature(doc_cfg)]
  | ^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0554`.
error: Could not compile `asdf`.

To learn more, run the command again with --verbose.

$ cargo +stable doc
 Documenting asdf v0.1.0 (/home/misdreavus/git/asdf)
    Finished dev [unoptimized + debuginfo] target(s) in 0.79s

The output docs also happily use the feature in question:

image

I would expect rustdoc to also choke on the #![feature] attribute, but it turns out that it doesn't. This is probably not an issue in practice, but this doesn't seem intended?

@QuietMisdreavus QuietMisdreavus added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Nov 13, 2018
@abonander
Copy link
Contributor

It would actually be neat if rustdoc rendered information about the nightly features a crate uses in the root docs.

@najamelan
Copy link
Contributor

I think this is broken as of stable 1.41 (haven't double checked version exactly), which is a regression. It broke my CI on stable... It is a little annoying to work around. You must not use a cargo feature to turn this on, lest --all-features now doesn't work anymore on stable and you must always run rustdoc with cargo +nightly doc.

@yandros posted a workaround for avoiding enabling with a feature on the user forum.

@najamelan
Copy link
Contributor

Further breakage comes with cargo test. If using the workaround posted by @yandros, rustdocflags will be enabled for doc tests, so cargo test will no longer work on stable.

@jyn514 jyn514 added A-stability Area: `#[stable]`, `#[unstable]` etc. C-bug Category: This is a bug. labels Aug 27, 2020
@jyn514
Copy link
Member

jyn514 commented Feb 20, 2021

I would expect rustdoc to also choke on the #![feature] attribute, but it turns out that it doesn't. This is probably not an issue in practice, but this doesn't seem intended?

This was fixed at some point, stable now correctly gives an error:

$ rustdoc +stable --version
rustdoc 1.50.0 (cb75ad5db 2021-02-10)
$ rustdoc +stable feature.rs 
error[E0554]: `#![feature]` may not be used on the stable release channel
 --> feature.rs:1:1
  |
1 | #![feature(doc_cfg)]
  | ^^^^^^^^^^^^^^^^^^^^

error: Compilation failed, aborting rustdoc

@jyn514 jyn514 closed this as completed Feb 20, 2021
@jyn514
Copy link
Member

jyn514 commented Feb 20, 2021

It would actually be neat if rustdoc rendered information about the nightly features a crate uses in the root docs.

This seems useful - could you open a separate issue for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stability Area: `#[stable]`, `#[unstable]` etc. C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants