Skip to content

extended_key_value_attributes cannot be enabled conditionally #82768

Closed
@jyn514

Description

@jyn514

I tried this code:

#![cfg_attr(
    any(),
    feature(extended_key_value_attributes),
    doc = include_str!("../README.md")
)]

I expected to see this happen: The compiler gives no error, because doc = include_str! should only be compiled if the predicate is true.

Instead, this happened: The compiler gives an error that extended_key_value_attributes is unstable.

I guess this happens because the compiler has to parse the attribute even if the cfg is false? @petrochenkov is giving an error here intentional?

Meta

rustc --version: 1.52.0-nightly (2021-03-01 4f20caa)

cc #78835
Originally posted by @daxpedda in #82539 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-stabilityArea: `#[stable]`, `#[unstable]` etc.F-extended_key_value_attributes`#![feature(extended_key_value_attributes)]T-compilerRelevant to the compiler 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