Skip to content

unconstrained type parameter makes no suggestions as to how to fix #107295

@gilescope

Description

@gilescope

Code

trait MyTrait {}

struct S;

impl <U> MyTrait for S {}

Current output

error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
 --> src/lib.rs:5:7
  |
5 | impl <U> MyTrait for S {}
  |       ^ unconstrained type parameter

For more information about this error, try `rustc --explain E0207`.
error: could not compile `playground` due to previous error

Desired output

error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
 --> src/lib.rs:5:7
  |
5 | impl <U> MyTrait for S {}
  |       ^ unconstrained type parameter

Either remove the type parameter (<U>) or make use of it, for example ` for S<U>`.

For more information about this error, try `rustc --explain E0207`.
error: could not compile `playground` due to previous error

Rationale and extra context

If we have an unconstrained type parameter, we get an error stating that it is unconstrained, but no suggestions on what to do about it and force the user to google.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3ca555fca7f8220aaab497f87c26225b

Is there room to reduce the learning curve here with better diagnostics?

Other cases

No response

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.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