Expand description
Check if it’s even possible to satisfy the ‘where’ clauses for this item.
It’s possible to #!feature(trivial_bounds)]
to write
a function with impossible to satisfy clauses, e.g.:
fn foo() where String: Copy {}
.
We don’t usually need to worry about this kind of case, since we would get a compilation error if the user tried to call it. However, since we optimize even without any calls to the function, we need to make sure that it even makes sense to try to evaluate the body.
If there are unsatisfiable where clauses, then all bets are off, and we just give up.
We manually filter the predicates, skipping anything that’s not “global”. We are in a potentially generic context (e.g. we are evaluating a function without instantiating generic parameters, so this filtering serves two purposes:
- We skip evaluating any predicates that we would
never be able prove are unsatisfiable (e.g.
<T as Foo>
- We avoid trying to normalize predicates involving generic
parameters (e.g.
<T as Foo>::MyItem
). This can confuse the normalization code (leading to cycle errors), since it’s usually never invoked in this way.