Skip to content

Poor diagnostics for [T, N] turbofish instead of [T; N] #81097

Open
@clarfonthey

Description

@clarfonthey

Minimal example:

fn main() {
    drop::<[(), 0]>([]);
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error: unmatched angle bracket
 --> src/main.rs:2:11
  |
2 |     drop::<[(), 0]>([]);
  |           ^ help: remove extra angle bracket

error: expected one of `;` or `]`, found `,`
 --> src/main.rs:2:15
  |
2 |     drop::<[(), 0]>([]);
  |               ^ expected one of `;` or `]`

error: aborting due to 2 previous errors

error: could not compile `playground`

To learn more, run the command again with --verbose.

Here, there actually isn't an unmatched angle bracket; the issue is that [(), 0] isn't a type, and that it should be [(); 0]. There might be other cases where this mistake causes awkward errors that might need fixing too, but this is just what I found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.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