Skip to content

Underscore-named parameter makes hint point at invalid token #66802

Closed
@Patryk27

Description

@Patryk27

Hi,

I've got following code:

fn foo1<T: ?Sized>(_: T) {
    // here be dragons
}

fn foo2<T>(_: T) where T: ?Sized {
    // here be dragons
}

... that returns:

error[E0277]: the size for values of type `T` cannot be known at compilation time
 --> src/lib.rs:1:26
  |
1 | fn foo1<T: ?Sized>(_: T) {
  |         --               ^ doesn't have a size known at compile-time

error[E0277]: the size for values of type `T` cannot be known at compilation time
 --> src/lib.rs:5:18
  |
5 | fn foo2<T>(_: T) where T: ?Sized {
  |                  ^              - help: consider further restricting type parameter `T`: `, T: std::marker::Sized`
  |                  |
  |                  doesn't have a size known at compile-time

(playground)

In both cases the tip points at the very next token after the parameter list, instead of the underscore. Additionally, the foo2's help message (consider further restricting ...) has broken formatting.

I'd like to fix this myself, if only you'd give me a hint where to look :-)

Thanks;

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.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