pub trait LayoutOfHelpers<'tcx>: HasDataLayout + HasTyCtxt<'tcx> + HasParamEnv<'tcx> {
    type LayoutOfResult: MaybeResult<TyAndLayout<'tcx>>;

    fn handle_layout_err(
        err: LayoutError<'tcx>,
        span: Span,
        ty: Ty<'tcx>
    ) -> <Self::LayoutOfResult as MaybeResult<TyAndLayout<'tcx, Ty<'tcx>>>>::Error; fn layout_tcx_at_span(&self) -> Span { ... } }
Expand description

Trait for contexts that want to be able to compute layouts of types. This automatically gives access to LayoutOf, through a blanket impl.

Required Associated Types

The TyAndLayout-wrapping type (or TyAndLayout itself), which will be returned from layout_of (see also handle_layout_err).

Required Methods

Helper used for layout_of, to adapt tcx.layout_of(...) into a Self::LayoutOfResult (which does not need to be a Result<...>).

Most impls, which propagate LayoutErrors, should simply return err, but this hook allows e.g. codegen to return only TyAndLayout from its cx.layout_of(...), without any Result<...> around it to deal with (and any LayoutErrors are turned into fatal errors or ICEs).

Provided Methods

Span to use for, from layout_of.