1
Fork 0

ty::layout: implement layout_of automatically as a default method.

This commit is contained in:
Eduard-Mihai Burtescu 2021-08-30 18:01:58 +03:00
parent 4ce933f13f
commit 1e02262dcc
8 changed files with 105 additions and 54 deletions

View file

@ -15,7 +15,7 @@ use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::MemFlags;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
use rustc_middle::ty::layout::{LayoutError, LayoutOf, TyAndLayout};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::Span;
use rustc_target::abi::{self, Align, Size};
@ -91,8 +91,9 @@ impl HasTargetSpec for Builder<'_, '_, 'tcx> {
impl LayoutOf<'tcx> for Builder<'_, '_, 'tcx> {
type LayoutOfResult = TyAndLayout<'tcx>;
fn layout_of(&self, ty: Ty<'tcx>) -> Self::LayoutOfResult {
self.cx.layout_of(ty)
#[inline]
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
self.cx.handle_layout_err(err, span, ty)
}
}