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§
sourcetype LayoutOfResult: MaybeResult<TyAndLayout<'tcx>>
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§
sourcefn handle_layout_err(
&self,
err: LayoutError<'tcx>,
span: Span,
ty: Ty<'tcx>,
) -> <Self::LayoutOfResult as MaybeResult<TyAndLayout<'tcx, Ty<'tcx>>>>::Error
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 impl
s, which propagate LayoutError
s, 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 LayoutError
s are turned into fatal errors or ICEs).
Provided Methods§
sourcefn layout_tcx_at_span(&self) -> Span
fn layout_tcx_at_span(&self) -> Span
Span
to use for tcx.at(span)
, from layout_of
.