Skip to content

type parameters followed by ? are recovered incorrectly #111327

Closed
@BoxyUwU

Description

@BoxyUwU

Code

trait Trait {}

impl<T ?Sized> Trait for T {}

Current output

error: invalid `?` in type
 --> src/lib.rs:3:8
  |
3 | impl<T ?Sized> Trait for T {}
  |        ^ `?` is only allowed on expressions, not types
  |
help: if you meant to express that the type might not contain a value, use the `Option` wrapper type
  |
3 | impl<Option<T >Sized> Trait for T {}
  |      +++++++  ~

error: expected one of `>` or `as`, found `Sized`
 --> src/lib.rs:3:9
  |
3 | impl<T ?Sized> Trait for T {}
  |         ^^^^^ expected one of `>` or `as`

Desired output

It should suggest adding a `:` and not emit the two current errors, explaining that you forgot to write `:` before the `?Sized` bound.

Rationale and extra context

No response

Other cases

No response

Anything else?

No response

Metadata

Metadata

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