Skip to content

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

Closed
@QuietMisdreavus

Description

@QuietMisdreavus

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-stabilityArea: `#[stable]`, `#[unstable]` etc.C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions