Skip to content

Removing empty type parameter list results in invalid Rust code #4621

Open
@steffahn

Description

@steffahn
pub fn foo() {
    let x: u32 = 100;
    if x as i32<> < 0 {
        // ...
    }
}

(playground)

gets formatted into

pub fn foo() {
    let x: u32 = 100;
    if x as i32 < 0 {
        // ...
    }
}
   Compiling playground v0.0.1 (/playground)
error: `<` is interpreted as a start of generic arguments for `i32`, not a comparison
 --> src/lib.rs:3:17
  |
3 |     if x as i32 < 0 {
  |        -------- ^ --- interpreted as generic arguments
  |        |        |
  |        |        not interpreted as comparison
  |        help: try comparing the cast value: `(x as i32)`

error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions