Skip to content

Surprising whitespace sensitivity in type parameters #47856

Closed
@matklad

Description

@matklad

Consider this code:

struct Ok <T: Clone + = ()> { t: T }

struct Err<T: Clone +=  ()> { t: T }

The Ok struct compiles just right, but the Err one fails with

error: expected one of `(`, `+`, `,`, `::`, `<`, `=`, or `>`, found `+=`
 --> main.rs:2:21
  |
2 | struct Err<T: Clone +=  ()> { t: T }
  |                     ^^ expected one of 7 possible tokens here

error: aborting due to previous error

I think this behavior is wrong: for tokens like >> or || use use "context sensitive" lexing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions