Skip to content

Rustdoc and rustc accept different cfg syntax #84437

Closed
@jyn514

Description

@jyn514

I tried this code:

#![feature(doc_cfg)]
#[doc(cfg(x, y))]
fn bar() {}

I expected to see this happen: An error, to match the behavior on #[cfg(x, y)]:

error: multiple `cfg` predicates are specified
 --> cfg2.rs:1:10
  |
1 | #[cfg(x, y)]
  |          ^

Instead, this happened: Rustdoc silently accepts the code.

Relevant code:

crate fn parse(cfg: &MetaItem) -> Result<Cfg, InvalidCfgError> {

I think the relevant rustc code is
fn in_cfg(&self, attrs: &[Attribute]) -> bool {

Meta

rustdoc --version: rustdoc 1.53.0-nightly (392ba2b 2021-04-17)

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-doc_cfg`#![feature(doc_cfg)]`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