reference icon indicating copy to clipboard operation
reference copied to clipboard

Type paremters constraints in generic implementations description is inaccurate

Open ChayimFriedman2 opened this issue 3 years ago • 0 comments

https://doc.rust-lang.org/reference/items/implementations.html#generic-implementations

Generic parameters constrain an implementation if the parameter appears at least once in one of:

  • ...
  • As an associated type in the bounds of a type that contains another parameter that constrains the implementation

However, RFC 447 says that all parameters should be constrained:

Type parameters are legal if they are "constrained" according to the following inference rules:

  • ...
  • If <T0 as Trait<T1...Tn>>::U == V appears in the impl predicates, and T0...Tn are constrained and T0 as Trait<T1...Tn> is not the impl trait reference then V is constrained.

This is also what implemented by the compiler.

See also Why does Fn() -> T constrain T but Fn(T) -> T does not.

ChayimFriedman2 avatar Mar 22 '22 17:03 ChayimFriedman2