Skip to content

Cannot parse disabled default const #2667

Open
@P-E-P

Description

@P-E-P

Compiler is emitting an error even if the code is disabled.

I tried this code:

fn main() {}

#[cfg(FALSE)]
trait T {
    default const X: u8;
}

I expected to see this happen: Compiles correctly.

Instead, this happened:

./test.rs:5:13: error: expecting ‘!’ but ‘const’ found
    5 |     default const X: u8;
      |             ^~~~~
./test.rs:5:13: error: failed to parse trait item in trait
./test.rs:5:13: error: failed to parse item in crate

https://godbolt.org/z/eP38brEKn

Meta

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions