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

Recover from C++-style "pub enum struct X" #99625

Closed
lopopolo opened this issue Jul 22, 2022 · 1 comment · Fixed by #99786
Closed

Recover from C++-style "pub enum struct X" #99625

lopopolo opened this issue Jul 22, 2022 · 1 comment · Fixed by #99786
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lopopolo
Copy link
Contributor

lopopolo commented Jul 22, 2022

Given the following code:

pub enum struct Range {
    Valid {
        begin: u32,
        len: u32,
    }
    Out,
}

fn main() {
    println!("Hello, world!");
}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: expected identifier, found keyword `struct`
 --> src/main.rs:1:10
  |
1 | pub enum struct Range {
  |          ^^^^^^ expected identifier, found keyword

error: expected one of `<`, `where`, or `{`, found `Range`
 --> src/main.rs:1:17
  |
1 | pub enum struct Range {
  |                 ^^^^^ expected one of `<`, `where`, or `{`

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

Ideally the output should look like:

Highlight to the user that the keywords enum and struct are mutually exclusive. Replace enum struct with enum.

@lopopolo lopopolo added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 22, 2022
@compiler-errors compiler-errors added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Jul 23, 2022
@obeis
Copy link
Contributor

obeis commented Jul 23, 2022

@rustbot claim

obeis added a commit to obeis/rust that referenced this issue Jul 29, 2022
@bors bors closed this as completed in 9c18fdc Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants