Skip to content

Rustdoc allows multiple declarations of a feature #82588

Closed
@Nemo157

Description

@Nemo157

I tried this code:

#![feature(doc_cfg)]
#![feature(doc_cfg)]

fn main() {
    println!("Hello, world!");
}

I expected to see this happen: Both cargo build and cargo doc to fail because of multiple declarations of the doc_cfg feature.

Instead, this happened: cargo build failed while cargo doc succeeded:

> cargo build
   Compiling foo v0.1.0 (/tmp/tmp.NidTpZ70xE/foo)
error[E0636]: the feature `doc_cfg` has already been declared
 --> src/main.rs:2:12
  |
2 | #![feature(doc_cfg)]
  |            ^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0636`.
error: could not compile `foo`

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

> cargo doc
 Documenting foo v0.1.0 (/tmp/tmp.NidTpZ70xE/foo)
    Finished dev [unoptimized + debuginfo] target(s) in 0.48s

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (07194ffcd 2021-02-10)
binary: rustc
commit-hash: 07194ffcd25b0871ce560b9f702e52db27ac9f77
commit-date: 2021-02-10
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1

Metadata

Metadata

Labels

C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions