mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 21:15:18 +03:00
adding HasParamEnv trait
This commit is contained in:
+12
-10
@@ -1662,9 +1662,20 @@ pub fn layout_of(self, param_env_and_ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait HasParamEnv<'tcx> {
|
||||
fn param_env(&self) -> ty::ParamEnv<'tcx>;
|
||||
}
|
||||
|
||||
impl<'tcx, C> HasParamEnv<'tcx> for LayoutCx<'tcx, C> {
|
||||
fn param_env(&self) -> ty::ParamEnv<'tcx> {
|
||||
self.param_env
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
||||
where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
|
||||
C::TyLayout: MaybeResult<TyLayout<'tcx>>
|
||||
C::TyLayout: MaybeResult<TyLayout<'tcx>>,
|
||||
C: HasParamEnv<'tcx>
|
||||
{
|
||||
type ParamEnv = ty::ParamEnv<'tcx>;
|
||||
|
||||
@@ -1960,15 +1971,6 @@ fn pointee_info_at(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_freeze(
|
||||
this: TyLayout<'tcx>,
|
||||
cx: &C,
|
||||
param_env: Self::ParamEnv,
|
||||
)-> bool {
|
||||
this.ty.is_freeze(cx.tcx(), param_env, DUMMY_SP)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct Niche {
|
||||
|
||||
@@ -66,6 +66,12 @@ fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl ty::layout::HasParamEnv<'tcx> for Builder<'_, '_, 'tcx> {
|
||||
fn param_env(&self) -> ty::ParamEnv<'tcx> {
|
||||
self.cx.param_env()
|
||||
}
|
||||
}
|
||||
|
||||
impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyLayout = TyLayout<'tcx>;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
use rustc::mir::mono::Stats;
|
||||
use rustc::session::config::{self, DebugInfo};
|
||||
use rustc::session::Session;
|
||||
use rustc::ty::layout::{LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx};
|
||||
use rustc::ty::layout::{LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx, HasParamEnv};
|
||||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
use rustc::util::nodemap::FxHashMap;
|
||||
use rustc_target::spec::{HasTargetSpec, Target};
|
||||
@@ -861,3 +861,9 @@ fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, 'll> HasParamEnv<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
fn param_env(&self) -> ty::ParamEnv<'tcx> {
|
||||
panic!("asd")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
use crate::mir::place::PlaceRef;
|
||||
use crate::MemFlags;
|
||||
use rustc::ty::Ty;
|
||||
use rustc::ty::layout::{Align, Size};
|
||||
use rustc::ty::layout::{Align, Size, HasParamEnv};
|
||||
use std::ops::Range;
|
||||
use std::iter::TrustedLen;
|
||||
|
||||
@@ -29,6 +29,8 @@ pub trait BuilderMethods<'a, 'tcx: 'a>:
|
||||
+ IntrinsicCallMethods<'tcx>
|
||||
+ AsmBuilderMethods<'tcx>
|
||||
+ StaticBuilderMethods<'tcx>
|
||||
+ HasParamEnv<'tcx>
|
||||
|
||||
{
|
||||
fn new_block<'b>(cx: &'a Self::CodegenCx, llfn: Self::Value, name: &'b str) -> Self;
|
||||
fn with_cx(cx: &'a Self::CodegenCx) -> Self;
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
ArgTypeMethods, BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods, TypeMethods,
|
||||
};
|
||||
pub use self::write::{ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods};
|
||||
use rustc::ty::layout::{HasParamEnv};
|
||||
|
||||
|
||||
use std::fmt;
|
||||
|
||||
@@ -58,6 +60,7 @@ pub trait CodegenMethods<'tcx>:
|
||||
+ DeclareMethods<'tcx>
|
||||
+ AsmMethods<'tcx>
|
||||
+ PreDefineMethods<'tcx>
|
||||
+ HasParamEnv<'tcx>
|
||||
{
|
||||
}
|
||||
|
||||
@@ -72,6 +75,7 @@ impl<'tcx, T> CodegenMethods<'tcx> for T where
|
||||
+ DeclareMethods<'tcx>
|
||||
+ AsmMethods<'tcx>
|
||||
+ PreDefineMethods<'tcx>
|
||||
+ HasParamEnv<'tcx>
|
||||
{
|
||||
}
|
||||
|
||||
@@ -85,5 +89,6 @@ pub trait HasCodegen<'tcx>:
|
||||
Type = Self::Type,
|
||||
Funclet = Self::Funclet,
|
||||
DIScope = Self::DIScope,
|
||||
>;
|
||||
>
|
||||
+ HasParamEnv<'tcx>;
|
||||
}
|
||||
|
||||
@@ -175,6 +175,14 @@ fn tcx<'d>(&'d self) -> TyCtxt<'d, 'tcx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'mir, 'tcx, M> layout::HasParamEnv<'tcx> for InterpretCx<'a, 'mir, 'tcx, M>
|
||||
where M: Machine<'a, 'mir, 'tcx>
|
||||
{
|
||||
fn param_env(&self) -> ty::ParamEnv<'tcx> {
|
||||
self.param_env
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> LayoutOf
|
||||
for InterpretCx<'a, 'mir, 'tcx, M>
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use rustc::ty::layout::LayoutOf;
|
||||
use rustc::ty::layout::TargetDataLayout;
|
||||
use rustc::ty::layout::TyLayout;
|
||||
use rustc::ty::layout::HasParamEnv;
|
||||
use rustc::ty::ParamEnv;
|
||||
use rustc::ty::Ty;
|
||||
use rustc::ty::TyCtxt;
|
||||
@@ -122,6 +123,12 @@ fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'me, 'tcx> HasParamEnv<'tcx> for UnwrapLayoutCx<'me, 'tcx> {
|
||||
fn param_env(&self) -> ParamEnv<'tcx> {
|
||||
self.param_env
|
||||
}
|
||||
}
|
||||
|
||||
impl<'me, 'tcx> HasDataLayout for UnwrapLayoutCx<'me, 'tcx> {
|
||||
fn data_layout(&self) -> &TargetDataLayout {
|
||||
self.tcx.data_layout()
|
||||
|
||||
@@ -947,11 +947,6 @@ fn pointee_info_at(
|
||||
offset: Size,
|
||||
param_env: Self::ParamEnv,
|
||||
) -> Option<PointeeInfo>;
|
||||
fn is_freeze(
|
||||
this: TyLayout<'a, Self>,
|
||||
cx: &C,
|
||||
param_env: Self::ParamEnv,
|
||||
)-> bool;
|
||||
}
|
||||
|
||||
impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
@@ -969,10 +964,6 @@ pub fn pointee_info_at<C>(
|
||||
where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> {
|
||||
Ty::pointee_info_at(self, cx, offset, param_env)
|
||||
}
|
||||
pub fn is_freeze<C>(self, cx: &C, param_env: Ty::ParamEnv) -> bool
|
||||
where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> {
|
||||
Ty::is_freeze(self, cx, param_env)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
|
||||
Reference in New Issue
Block a user