Skip to content

Add note that struct declaration within a struct is not allowed #101540

Closed
@Rageking8

Description

@Rageking8

Given the following code: link

struct S1 {
    struct S2 {

    }
}

fn main() {

}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: expected identifier, found keyword `struct`
 --> src/main.rs:2:5
  |
2 |     struct S2 {
  |     ^^^^^^ expected identifier, found keyword

error: could not compile `playground` due to previous error

Ideally the output should include a note informing the user that the declaration of another struct within a struct is not allowed and they should use separate declarations. (Wording might need a bit of tweaking).

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.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