Skip to main content

args_known_to_outlive_opaque_params

Function args_known_to_outlive_opaque_params 

Source
pub(crate) fn args_known_to_outlive_opaque_params<'tcx>(
    tcx: TyCtxt<'tcx>,
    def_id: LocalDefId,
) -> EarlyBinder<'tcx, Vec<(Region<'tcx>, Vec<GenericArg<'tcx>>)>>
Expand description

For each captured region of this alias, compute the captured identity args that are known to outlive it, given the definition of the opaque type in the the parent context.

Some examples:

// Returns `[('a, ['a]), ('b, ['b])]`
fn foo<'a, 'b>() -> impl Sized + use<'a, 'b> {}

// Returns `[('a, ['a]), ('b, ['b])]`
fn foo<'a: 'a, 'b>() -> impl Sized + use<'a, 'b> {}

// Returns `[('a, ['a])]`
fn foo<'a, 'b>() -> impl Sized + use<'a> {}

// Returns `[('a, ['a, 'b]), ('b, ['b])]`
fn foo<'a, 'b: 'a>() -> impl Sized + use<'a, 'b> {}

// Returns `[('a, ['a, 'b]), ('b, ['b])]`
fn foo<'a, 'b>(_: &'a &'b ()) -> impl Sized + use<'a, 'b> {}

Importantly:

  • All captured regions are considered (not just those in outlives bounds)
  • It doesn’t matter if the captured region is early-bound or late-bound