Skip to content
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

Cannot parse StructExprField attributes #3018

Open
P-E-P opened this issue May 20, 2024 · 0 comments · May be fixed by #3017
Open

Cannot parse StructExprField attributes #3018

P-E-P opened this issue May 20, 2024 · 0 comments · May be fixed by #3017
Assignees

Comments

@P-E-P
Copy link
Member

P-E-P commented May 20, 2024

The following code does not parse.

I tried this code:

pub struct Test {
    #[cfg(not(any(
        target_os = "solaris",
        target_os = "illumos",
        target_os = "fuchsia",
        target_os = "redox",
    )))]
    _value: bool,
}

pub fn test() -> Test {
    Test {
        #[cfg(not(any(
            target_os = "solaris",
            target_os = "illumos",
            target_os = "fuchsia",
            target_os = "redox",
        )))]
        _value: false,
    }
}

https://godbolt.org/z/drr3j13Kc

I expected to see this happen: Compiles.

Instead, this happened: Compiler parsing error

<source>:13:9: error: unrecognised token '#' in struct (or enum) expression - expected '}', identifier, integer literal, or '..'
   13 |         #[cfg(not(any(
      |         ^
<source>:12:5: error: failed to parse statement or expression in block expression
   12 |     Test {
      |     ^~~~
<source>:19:9: error: unrecognised token 'identifier' for start of item
   19 |         _value: false,
      |         ^~~~~~
<source>:19:9: error: failed to parse item in crate
Compiler returned: 1

Meta

@P-E-P P-E-P self-assigned this May 20, 2024
@P-E-P P-E-P linked a pull request May 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

1 participant