Skip to content

erroneous behavior with #[cfg] #43494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joshlf opened this issue Jul 26, 2017 · 2 comments
Closed

erroneous behavior with #[cfg] #43494

joshlf opened this issue Jul 26, 2017 · 2 comments
Labels
A-parser Area: The lexing & parsing of Rust source code to an AST C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@joshlf
Copy link
Contributor

joshlf commented Jul 26, 2017

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?

@Mark-Simulacrum Mark-Simulacrum added A-parser Area: The lexing & parsing of Rust source code to an AST C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 26, 2017
@sinkuu
Copy link
Contributor

sinkuu commented Nov 3, 2017

Duplication of #38337.

@Mark-Simulacrum
Copy link
Member

Yes, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The lexing & parsing of Rust source code to an AST C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants