Trait rustc_middle::ty::layout::LayoutOfHelpers

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

    // Required method
    fn handle_layout_err(
        &self,
        err: LayoutError<'tcx>,
        span: Span,
        ty: Ty<'tcx>
    ) -> <Self::LayoutOfResult as MaybeResult<TyAndLayout<'tcx, Ty<'tcx>>>>::Error;

    // Provided method
    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§

source

type LayoutOfResult: MaybeResult<TyAndLayout<'tcx>>

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

Required Methods§

source

fn handle_layout_err( &self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx> ) -> <Self::LayoutOfResult as MaybeResult<TyAndLayout<'tcx, Ty<'tcx>>>>::Error

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§

source

fn layout_tcx_at_span(&self) -> Span

Span to use for tcx.at(span), from layout_of.

Implementors§

source§

impl<'tcx> LayoutOfHelpers<'tcx> for LayoutCx<'tcx, TyCtxtAt<'tcx>>

§

type LayoutOfResult = Result<TyAndLayout<'tcx, Ty<'tcx>>, &'tcx LayoutError<'tcx>>

source§

impl<'tcx> LayoutOfHelpers<'tcx> for LayoutCx<'tcx, TyCtxt<'tcx>>

§

type LayoutOfResult = Result<TyAndLayout<'tcx, Ty<'tcx>>, &'tcx LayoutError<'tcx>>