Skip to content

Commit 18679cd

Browse files
committed
adding HasParamEnv trait
1 parent 8802dc0 commit 18679cd

File tree

8 files changed

+49
-22
lines changed

8 files changed

+49
-22
lines changed

src/librustc/ty/layout.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1662,9 +1662,20 @@ impl ty::query::TyCtxtAt<'a, 'tcx, '_> {
16621662
}
16631663
}
16641664

1665+
pub trait HasParamEnv<'tcx> {
1666+
fn param_env(&self) -> ty::ParamEnv<'tcx>;
1667+
}
1668+
1669+
impl<'tcx, C> HasParamEnv<'tcx> for LayoutCx<'tcx, C> {
1670+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
1671+
self.param_env
1672+
}
1673+
}
1674+
16651675
impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
16661676
where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
1667-
C::TyLayout: MaybeResult<TyLayout<'tcx>>
1677+
C::TyLayout: MaybeResult<TyLayout<'tcx>>,
1678+
C: HasParamEnv<'tcx>
16681679
{
16691680
type ParamEnv = ty::ParamEnv<'tcx>;
16701681

@@ -1960,15 +1971,6 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
19601971
}
19611972
}
19621973
}
1963-
1964-
fn is_freeze(
1965-
this: TyLayout<'tcx>,
1966-
cx: &C,
1967-
param_env: Self::ParamEnv,
1968-
)-> bool {
1969-
this.ty.is_freeze(cx.tcx(), param_env, DUMMY_SP)
1970-
}
1971-
19721974
}
19731975

19741976
struct Niche {

src/librustc_codegen_llvm/builder.rs

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ impl ty::layout::HasTyCtxt<'tcx> for Builder<'_, '_, 'tcx> {
6666
}
6767
}
6868

69+
impl ty::layout::HasParamEnv<'tcx> for Builder<'_, '_, 'tcx> {
70+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
71+
self.cx.param_env()
72+
}
73+
}
74+
6975
impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> {
7076
type Ty = Ty<'tcx>;
7177
type TyLayout = TyLayout<'tcx>;

src/librustc_codegen_llvm/context.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_data_structures::small_c_str::SmallCStr;
1515
use rustc::mir::mono::Stats;
1616
use rustc::session::config::{self, DebugInfo};
1717
use rustc::session::Session;
18-
use rustc::ty::layout::{LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx};
18+
use rustc::ty::layout::{LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx, HasParamEnv};
1919
use rustc::ty::{self, Ty, TyCtxt};
2020
use rustc::util::nodemap::FxHashMap;
2121
use rustc_target::spec::{HasTargetSpec, Target};
@@ -861,3 +861,9 @@ impl LayoutOf for CodegenCx<'ll, 'tcx> {
861861
})
862862
}
863863
}
864+
865+
impl<'tcx, 'll> HasParamEnv<'tcx> for CodegenCx<'ll, 'tcx> {
866+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
867+
panic!("asd")
868+
}
869+
}

src/librustc_codegen_ssa/traits/builder.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::mir::operand::OperandRef;
1010
use crate::mir::place::PlaceRef;
1111
use crate::MemFlags;
1212
use rustc::ty::Ty;
13-
use rustc::ty::layout::{Align, Size};
13+
use rustc::ty::layout::{Align, Size, HasParamEnv};
1414
use std::ops::Range;
1515
use std::iter::TrustedLen;
1616

@@ -29,6 +29,8 @@ pub trait BuilderMethods<'a, 'tcx: 'a>:
2929
+ IntrinsicCallMethods<'tcx>
3030
+ AsmBuilderMethods<'tcx>
3131
+ StaticBuilderMethods<'tcx>
32+
+ HasParamEnv<'tcx>
33+
3234
{
3335
fn new_block<'b>(cx: &'a Self::CodegenCx, llfn: Self::Value, name: &'b str) -> Self;
3436
fn with_cx(cx: &'a Self::CodegenCx) -> Self;

src/librustc_codegen_ssa/traits/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ pub use self::type_::{
4141
ArgTypeMethods, BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods, TypeMethods,
4242
};
4343
pub use self::write::{ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods};
44+
use rustc::ty::layout::{HasParamEnv};
45+
4446

4547
use std::fmt;
4648

@@ -58,6 +60,7 @@ pub trait CodegenMethods<'tcx>:
5860
+ DeclareMethods<'tcx>
5961
+ AsmMethods<'tcx>
6062
+ PreDefineMethods<'tcx>
63+
+ HasParamEnv<'tcx>
6164
{
6265
}
6366

@@ -72,6 +75,7 @@ impl<'tcx, T> CodegenMethods<'tcx> for T where
7275
+ DeclareMethods<'tcx>
7376
+ AsmMethods<'tcx>
7477
+ PreDefineMethods<'tcx>
78+
+ HasParamEnv<'tcx>
7579
{
7680
}
7781

@@ -85,5 +89,6 @@ pub trait HasCodegen<'tcx>:
8589
Type = Self::Type,
8690
Funclet = Self::Funclet,
8791
DIScope = Self::DIScope,
88-
>;
92+
>
93+
+ HasParamEnv<'tcx>;
8994
}

src/librustc_mir/interpret/eval_context.rs

+8
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ impl<'a, 'mir, 'tcx, M> layout::HasTyCtxt<'tcx> for InterpretCx<'a, 'mir, 'tcx,
175175
}
176176
}
177177

178+
impl<'a, 'mir, 'tcx, M> layout::HasParamEnv<'tcx> for InterpretCx<'a, 'mir, 'tcx, M>
179+
where M: Machine<'a, 'mir, 'tcx>
180+
{
181+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
182+
self.param_env
183+
}
184+
}
185+
178186
impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> LayoutOf
179187
for InterpretCx<'a, 'mir, 'tcx, M>
180188
{

src/librustc_passes/layout_test.rs

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc::ty::layout::HasTyCtxt;
77
use rustc::ty::layout::LayoutOf;
88
use rustc::ty::layout::TargetDataLayout;
99
use rustc::ty::layout::TyLayout;
10+
use rustc::ty::layout::HasParamEnv;
1011
use rustc::ty::ParamEnv;
1112
use rustc::ty::Ty;
1213
use rustc::ty::TyCtxt;
@@ -122,6 +123,12 @@ impl<'me, 'tcx> HasTyCtxt<'tcx> for UnwrapLayoutCx<'me, 'tcx> {
122123
}
123124
}
124125

126+
impl<'me, 'tcx> HasParamEnv<'tcx> for UnwrapLayoutCx<'me, 'tcx> {
127+
fn param_env(&self) -> ParamEnv<'tcx> {
128+
self.param_env
129+
}
130+
}
131+
125132
impl<'me, 'tcx> HasDataLayout for UnwrapLayoutCx<'me, 'tcx> {
126133
fn data_layout(&self) -> &TargetDataLayout {
127134
self.tcx.data_layout()

src/librustc_target/abi/mod.rs

-9
Original file line numberDiff line numberDiff line change
@@ -947,11 +947,6 @@ pub trait TyLayoutMethods<'a, C: LayoutOf<Ty = Self>>: Sized {
947947
offset: Size,
948948
param_env: Self::ParamEnv,
949949
) -> Option<PointeeInfo>;
950-
fn is_freeze(
951-
this: TyLayout<'a, Self>,
952-
cx: &C,
953-
param_env: Self::ParamEnv,
954-
)-> bool;
955950
}
956951

957952
impl<'a, Ty> TyLayout<'a, Ty> {
@@ -969,10 +964,6 @@ impl<'a, Ty> TyLayout<'a, Ty> {
969964
where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> {
970965
Ty::pointee_info_at(self, cx, offset, param_env)
971966
}
972-
pub fn is_freeze<C>(self, cx: &C, param_env: Ty::ParamEnv) -> bool
973-
where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> {
974-
Ty::is_freeze(self, cx, param_env)
975-
}
976967
}
977968

978969
impl<'a, Ty> TyLayout<'a, Ty> {

0 commit comments

Comments
 (0)