Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

#[cfg] on struct field permits empty unusable struct #16819

Copy link
Copy link
@klutzy

Description

@klutzy
Issue body actions
struct S {
    #[cfg(untrue)]
    a: int,
}

fn main() {
    let s = S;
}
<anon>:7:13: 7:14 error: `S` is a structure name, but this expression uses it like a function name
<anon>:7     let s = S;
                     ^
<anon>:7:13: 7:14 note: Did you mean to write: `S { /* fields */ }`?
<anon>:7     let s = S;
                     ^

Here S { } is suggested but it is also not allowed:

<anon>:7:14: 7:15 error: structure literal must either have at least one field or use functional structure update syntax
<anon>:7     let s = S{};
                      ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-grammarArea: The grammar of RustArea: The grammar of Rust

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.