Skip to content

Incorrect help suggestion on a syntax error in the where part of an enum #143023

Open
@Dylan-DPC

Description

@Dylan-DPC

Code

pub enum Foo<T>
where:
    T: Debug,
    {
        
    }

Current output

Compiling playground v0.0.1 (/playground)
error: expected one of `#`, `{`, lifetime, or type, found `:`
 --> src/lib.rs:2:6
  |
1 | pub enum Foo<T>
  |          --- while parsing this enum
2 | where:
  |      ^ expected one of `#`, `{`, lifetime, or type
  |
help: perhaps you meant to use `struct` here
  |
1 - pub enum Foo<T>
1 + pub struct Foo<T>
  |

error: could not compile `playground` (lib) due to 1 previous error

Rationale and extra context

I found this error by trying out some code which accidentally had a where: in the code and it results in this incorrect help suggestion.

This doesn't occur if you have a struct instead of an enum (there's no help suggestion in that case )

Rust Version

tested on playground (1.87.0 stable and 1.90.0 nightly )

Anything else?

Playground link

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.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