mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
rustc_target: require TyAbiInterface
in LayoutOf
.
This commit is contained in:
parent
8486571a10
commit
87d1fb747f
@ -41,7 +41,7 @@ use rustc_session::Session;
|
||||
use rustc_session::SessionLintStore;
|
||||
use rustc_span::lev_distance::find_best_match_for_name;
|
||||
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
|
||||
use rustc_target::abi::LayoutOf;
|
||||
use rustc_target::abi::{self, LayoutOf};
|
||||
use tracing::debug;
|
||||
|
||||
use std::cell::Cell;
|
||||
@ -1059,6 +1059,27 @@ impl<'tcx> LateContext<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> abi::HasDataLayout for LateContext<'tcx> {
|
||||
#[inline]
|
||||
fn data_layout(&self) -> &abi::TargetDataLayout {
|
||||
&self.tcx.data_layout
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ty::layout::HasTyCtxt<'tcx> for LateContext<'tcx> {
|
||||
#[inline]
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ty::layout::HasParamEnv<'tcx> for LateContext<'tcx> {
|
||||
#[inline]
|
||||
fn param_env(&self) -> ty::ParamEnv<'tcx> {
|
||||
self.param_env
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> LayoutOf<'tcx> for LateContext<'tcx> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>;
|
||||
|
@ -2034,6 +2034,20 @@ impl<'tcx> HasTyCtxt<'tcx> for TyCtxt<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> HasDataLayout for ty::query::TyCtxtAt<'tcx> {
|
||||
#[inline]
|
||||
fn data_layout(&self) -> &TargetDataLayout {
|
||||
&self.data_layout
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> HasTyCtxt<'tcx> for ty::query::TyCtxtAt<'tcx> {
|
||||
#[inline]
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
**self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, C> HasParamEnv<'tcx> for LayoutCx<'tcx, C> {
|
||||
fn param_env(&self) -> ty::ParamEnv<'tcx> {
|
||||
self.param_env
|
||||
|
@ -17,7 +17,7 @@ use rustc_middle::mir::{
|
||||
Location, Operand, Place, Rvalue, SourceInfo, SourceScope, SourceScopeData, Statement,
|
||||
StatementKind, Terminator, TerminatorKind, UnOp, RETURN_PLACE,
|
||||
};
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutError, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{LayoutError, TyAndLayout};
|
||||
use rustc_middle::ty::subst::{InternalSubsts, Subst};
|
||||
use rustc_middle::ty::{
|
||||
self, ConstInt, ConstKind, Instance, ParamEnv, ScalarInt, Ty, TyCtxt, TypeFoldable,
|
||||
@ -346,13 +346,20 @@ impl<'mir, 'tcx> HasDataLayout for ConstPropagator<'mir, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'mir, 'tcx> HasTyCtxt<'tcx> for ConstPropagator<'mir, 'tcx> {
|
||||
impl<'mir, 'tcx> ty::layout::HasTyCtxt<'tcx> for ConstPropagator<'mir, 'tcx> {
|
||||
#[inline]
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
}
|
||||
|
||||
impl<'mir, 'tcx> ty::layout::HasParamEnv<'tcx> for ConstPropagator<'mir, 'tcx> {
|
||||
#[inline]
|
||||
fn param_env(&self) -> ty::ParamEnv<'tcx> {
|
||||
self.param_env
|
||||
}
|
||||
}
|
||||
|
||||
impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
fn new(
|
||||
body: &Body<'tcx>,
|
||||
|
@ -1174,8 +1174,8 @@ impl<'a, Ty> Deref for TyAndLayout<'a, Ty> {
|
||||
}
|
||||
|
||||
/// Trait for context types that can compute layouts of things.
|
||||
pub trait LayoutOf<'a> {
|
||||
type Ty;
|
||||
pub trait LayoutOf<'a>: Sized {
|
||||
type Ty: TyAbiInterface<'a, Self>;
|
||||
type TyAndLayout: MaybeResult<TyAndLayout<'a, Self::Ty>>;
|
||||
|
||||
fn layout_of(&self, ty: Self::Ty) -> Self::TyAndLayout;
|
||||
|
Loading…
Reference in New Issue
Block a user