rustc_middle::ty

Type Alias RegionKind

Source
pub type RegionKind<'tcx> = RegionKind<TyCtxt<'tcx>>;

Aliased Type§

enum RegionKind<'tcx> {
    ReEarlyParam(EarlyParamRegion),
    ReBound(DebruijnIndex, BoundRegion),
    ReLateParam(LateParamRegion),
    ReStatic,
    ReVar(RegionVid),
    RePlaceholder(Placeholder<BoundRegion>),
    ReErased,
    ReError(ErrorGuaranteed),
}

Variants§

§

ReEarlyParam(EarlyParamRegion)

A region parameter; for example 'a in impl<'a> Trait for &'a ().

There are some important differences between region and type parameters. Not all region parameters in the source are represented via ReEarlyParam: late-bound function parameters are instead lowered to a ReBound. Late-bound regions get eagerly replaced with ReLateParam which behaves in the same way as ReEarlyParam. Region parameters are also sometimes implicit, e.g. in impl Trait for &().

§

ReBound(DebruijnIndex, BoundRegion)

A higher-ranked region. These represent either late-bound function parameters or bound variables from a for<'a>-binder.

While inside of a function, e.g. during typeck, the late-bound function parameters can be converted to ReLateParam by calling tcx.liberate_late_bound_regions.

Bound regions inside of types must not be erased, as they impact trait selection and the TypeId of that type. for<'a> fn(&'a ()) and fn(&'static ()) are different types and have to be treated as such.

§

ReLateParam(LateParamRegion)

Late-bound function parameters are represented using a ReBound. When inside of a function, we convert these bound variables to placeholder parameters via tcx.liberate_late_bound_regions. They are then treated the same way as ReEarlyParam while inside of the function.

See https://rustc-dev-guide.rust-lang.org/early-late-bound-params/early-late-bound-summary.html for more info about early and late bound lifetime parameters.

§

ReStatic

Static data that has an “infinite” lifetime. Top in the region lattice.

§

ReVar(RegionVid)

A region variable. Should not exist outside of type inference.

§

RePlaceholder(Placeholder<BoundRegion>)

A placeholder region – the higher-ranked version of ReLateParam. Should not exist outside of type inference.

Used when instantiating a forall binder via infcx.enter_forall.

§

ReErased

Erased region, used by trait selection, in MIR and during codegen.

§

ReError(ErrorGuaranteed)

A region that resulted from some other error. Used exclusively for diagnostics.

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: 24 bytes

Size for each variant:

  • ReEarlyParam: 8 bytes
  • ReBound: 20 bytes
  • ReLateParam: 20 bytes
  • ReStatic: 0 bytes
  • ReVar: 4 bytes
  • RePlaceholder: 20 bytes
  • ReErased: 0 bytes
  • ReError: 0 bytes