Skip to content

Suggest impl<T: Bound> Trait<T> for Foo when finding impl Trait<T: Bound> for Foo #113073

Closed
@TheOnlyMrCat

Description

@TheOnlyMrCat

Code

trait Foo<T> {}
impl Foo<T: Default> for u32 {}

Current output

error[E0658]: associated type bounds are unstable
 --> src/lib.rs:2:10
  |
2 | impl Foo<T: Default> for u32 {}
  |          ^^^^^^^^^^
  |
  = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information

error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied
 --> src/lib.rs:2:6
  |
2 | impl Foo<T: Default> for u32 {}
  |      ^^^ expected 1 generic argument
  |
note: trait defined here, with 1 generic parameter: `T`
 --> src/lib.rs:1:7
  |
1 | trait Foo<T> {}
  |       ^^^ -
help: add missing generic argument
  |
2 | impl Foo<T, T: Default> for u32 {}
  |          ++

error[E0229]: associated type bindings are not allowed here
 --> src/lib.rs:2:10
  |
2 | impl Foo<T: Default> for u32 {}
  |          ^^^^^^^^^^ associated type not allowed here

Desired output

error[E0658]: associated type bounds are unstable
 --> src/lib.rs:2:10
  |
2 | impl Foo<T: Default> for u32 {}
  |          ^^^^^^^^^^
  |
  = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information

error[E0229]: associated type bindings are not allowed here
 --> src/lib.rs:2:10
  |
2 | impl Foo<T: Default> for u32 {}
  |          ^^^^^^^^^^ associated type not allowed here
help: declare the type parameter first
  |
2 | impl<T: Default> Foo<T> for u32 {}
  |     ++++++++++++

Rationale and extra context

No response

Other cases

No response

Anything else?

No response

### Tasks

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