You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
In impl trait, E0229 "associated type bindings are not allowed here" could suggest a solution or at least be less confusing #122162
structS;structT;// error[E0229]: associated type bindings are not allowed here// --> src/lib.rs:9:26// |//9 | impl std::cmp::PartialEq<Rhs = T> for S {// | ^^^^^^^ associated type not allowed hereimpl std::cmp::PartialEq<Rhs = T>forS{fneq(&self,_other:&T) -> bool{true}}// Works/*impl std::cmp::PartialEq<T> for S { fn eq(&self, _other: &T) -> bool { true }}*/
Current output
error[E0229]: associated type bindings are not allowed here
9 | impl std::cmp::PartialEq<Rhs = T>for S {
| ^^^^^^^ associated type not allowed here
Desired output
error[E0229]: associated type bindings are not allowed here
9 | impl std::cmp::PartialEq<Rhs = T>for S {
| ^^^^^^^ associated type not allowed here,
|`std::cmp::PartialEq` has a generic parameter, not an associated type, so the `Rhs =` syntax is not appropriate to use here.
| Did you mean `impl std::cmp::PartialEq<T>`?
Rationale and extra context
I have been writing Rust for years and still get the syntax for trait generic type params and trait associated types mixed up. In this case, I copy-and-pasted the trait signature from the documentation and put impl in front of it.
In my mind, I never had any intent to bind an associated type. My goal was to impl PartialEq.
I now see my mistake, but in this case the error messages did not help me get there and perhaps could be improved.
Activity
Rollup merge of rust-lang#122591 - gurry:122162-impl-type-binding-sug…
Unrolled build for rust-lang#122591