rustc_hir_analysis::outlives::implicit_infer

Function check_inferred_predicates

Source
fn check_inferred_predicates<'tcx>(
    tcx: TyCtxt<'tcx>,
    def_id: DefId,
    args: GenericArgsRef<'tcx>,
    global_inferred_outlives: &FxIndexMap<DefId, EarlyBinder<'tcx, FxIndexMap<OutlivesPredicate<'tcx, GenericArg<'tcx>>, Span>>>,
    required_predicates: &mut FxIndexMap<OutlivesPredicate<'tcx, GenericArg<'tcx>>, Span>,
)
Expand description

Check the inferred predicates declared on the type.

§Example

struct Outer<'a, T> {
    outer: Inner<'a, T>,
}

struct Inner<'b, U> {
    inner: &'b U,
}

Here, when processing the type of field outer, we would request the set of implicit predicates computed for Inner thus far. This will initially come back empty, but in next round we will get U: 'b. We then apply the instantiation ['b => 'a, U => T] and thus get the requirement that T: 'a holds for Outer.