Skip to content

erroneous behavior with #[cfg] #43494

Closed
Closed
@joshlf

Description

@joshlf

The following code results in a parsing error where the 0 character is unexpected.

fn get_usize() -> usize {
        #[cfg(not(debug_assertions))]
        0
        
        #[cfg(debug_assertions)]
        1
}

However, the following code works fine:

fn get_usize_return() -> usize {
        #[cfg(not(debug_assertions))]
        return 0;
        
        #[cfg(debug_assertions)]
        1
}

I think this is a bug in the parser?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.I-needs-decisionIssue: In need of a decision.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