Expand description
Each item can involve three kinds of predicates:
- input aka required predicates: the predicates required to mention the item. These are usually
where
clauses (or equivalent) on the item:
ⓘ
struct Foo<T: Clone> { ... }
trait Foo<T> where T: Clone { ... }
fn function<I>() where I: Iterator, I::Item: Clone { ... }
- output aka implied predicates: the predicates that are implied by the presence of this item in a signature. This is mostly trait parent predicates:
ⓘ
trait Foo: Clone { ... }
fn bar<T: Foo>() {
// from `T: Foo` we can deduce `T: Clone`
}
This could also include implied predicates such as &'a T
implying T: 'a
but we don’t
consider these.
- “self” predicate: that’s the special
Self: Trait
predicate in scope within a trait declaration or implementation for traitTrait
.
Note that within a given item the polarity is reversed: input predicates are the ones that can be assumed to hold and output predicates must be proven to hold. The “self” predicate is both assumed and proven within an impl block, and just assumed within a trait declaration block.
The current implementation considers all predicates on traits to be outputs, which has the benefit of reducing the size of signatures. Moreover, the rules on which bounds are required vs implied are subtle. We may change this if this proves to be a problem.
Functions§
- Erase all regions. Largely copied from
tcx.erase_regions
. - The predicates that can be deduced from the presence of this item in a signature. We only consider predicates implied by traits here, not implied bounds such as
&'a T
implyingT: 'a
. - Returns a list of type predicates for the definition with ID
def_id
, including inferred lifetime constraints. This is the basic list of predicates we use for essentially all items. - The predicates that must hold to mention this item.
- The special “self” predicate on a trait.