pub(crate) struct LifetimeContext<'a, 'tcx> {
    pub(crate) tcx: TyCtxt<'tcx>,
    map: &'a mut NamedRegionMap,
    scope: &'a Scope<'a>,
    trait_definition_only: bool,
}

Fields

tcx: TyCtxt<'tcx>map: &'a mut NamedRegionMapscope: &'a Scope<'a>trait_definition_only: bool

Indicates that we only care about the definition of a trait. This should be false if the Item we are resolving lifetimes for is not a trait or we eventually need lifetimes resolve for trait items.

Implementations

Returns the binders in scope and the type of Binder that should be created for a poly trait ref.

Visits self by adding a scope and handling recursive walk over the contents with walk.

Handles visiting fns and methods. These are a bit complicated because we must distinguish early- vs late-bound lifetime parameters. We do this by checking which lifetimes appear within type bounds; those are early bound lifetimes, and the rest are late bound.

For example:

fn foo<’a,’b,’c,T:Trait<’b>>(…)

Here 'a and 'c are late bound but 'b is early bound. Note that early- and late-bound lifetimes may be interspersed together.

If early bound lifetimes are present, we separate them into their own list (and likewise for late bound). They will be numbered sequentially, starting from the lowest index that is already in scope (for a fn item, that will be 0, but for a method it might not be). Late bound lifetimes are resolved by name and associated with a binder ID (binder_id), so the ordering is not important there.

Returns all the late-bound vars that come into scope from supertrait HRTBs, based on the associated type name and starting trait. For example, imagine we have

trait Foo<'a, 'b> {
  type As;
}
trait Bar<'b>: for<'a> Foo<'a, 'b> {}
trait Bar: for<'b> Bar<'b> {}

In this case, if we wanted to the supertrait HRTB lifetimes for As on the starting trait Bar, we would return Some(['b, 'a]).

Sometimes we resolve a lifetime, but later find that it is an error (esp. around impl trait). In that case, we remove the entry into map.defs so as not to confuse later code.

Trait Implementations

Override this type to control which nested HIR are visited; see NestedFilter for details. If you override this type, you must also override nested_visit_map. Read more
If type NestedFilter is set to visit nested items, this method must also be overridden to provide a map to retrieve nested items. Read more
Invoked when a nested item is encountered. By default, when Self::NestedFilter is nested_filter::None, this method does nothing. You probably don’t want to override this method – instead, override Self::NestedFilter or use the “shallow” or “deep” visit patterns described on itemlikevisit::ItemLikeVisitor. The only reason to override this method is if you want a nested pattern but cannot supply a Map; see nested_visit_map for advice. Read more
Invoked to visit the body of a function, method or closure. Like visit_nested_item, does nothing by default unless you override Self::NestedFilter. Read more
Visits the top-level item and (optionally) nested items / impl items. See visit_nested_item for details. Read more
Like visit_nested_item(), but for trait items. See visit_nested_item() for advice on when to override this method. Read more
Like visit_nested_item(), but for impl items. See visit_nested_item() for advice on when to override this method. Read more
Like visit_nested_item(), but for foreign items. See visit_nested_item() for advice on when to override this method. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 32 bytes