Skip to content

Awesome "help" message suggesting turbofish doesn't always appear #40396

Closed
@jorendorff

Description

@jorendorff

Actual behavior: When you compile this program,

fn main() {
    println!("{:?}", (0..13).collect<Vec<i32>>());
}

this is the error message:

error: chained comparison operators require parentheses
 --> collect_err.rs:2:37
  |
2 |     println!("{:?}", (0..13).collect<Vec<i32>>());
  |                                     ^^^^^^^^

Expected behavior: If you trigger this error in a slightly different way,

fn main() {
    println!("{:?}", Vec<i32>::new());
}

you get a lovely "help" message at the end:

error: chained comparison operators require parentheses
 --> collect_err.rs:2:25
  |
2 |     println!("{:?}", Vec<i32>::new());
  |                         ^^^^^^^
  |
  = help: use `::<...>` instead of `<...>` if you meant to specify type arguments

The bug is that the first program does not trigger this help message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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