Closed
Description
Currently we check that the where clauses on an impl are consistent with a trait by examining the TypeParameterDefs
, and also with some specialized code around regions. This is not consistent with generalized where clauses. Probably the right approach is to:
- Create a
ParameterEnvironment
that contains the bounds from the trait method, substituted appropriately so that they are in the namespace of the impl. - Create a fresh inference and fulfillment context.
- Register each bound in the impl method in that fulfillment context and then run
select_all_or_error()
. If any errors result, that indicates a bound in the impl that does not appear in the trait. - We have to remember to also run
resolve_regions_and_report_errors()
as well to check for region obligations that are not satisfiable.
We may want to take some care here with respect to error messages; we probably want to print something more helpful about how there is a mismatch between the trait and impl.