rustc: Remove the TyCtxt field from ParameterEnvironment.

This commit is contained in:
Eduard Burtescu 2016-03-25 05:22:52 +02:00
parent 0053b442f8
commit 8a704f6dc7
20 changed files with 82 additions and 84 deletions

View File

@ -92,7 +92,7 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
// For region variables.
region_vars: RegionVarBindings<'a, 'tcx>,
pub parameter_environment: ty::ParameterEnvironment<'a, 'tcx>,
pub parameter_environment: ty::ParameterEnvironment<'gcx>,
// the set of predicates on which errors have been reported, to
// avoid reporting the same error twice.
@ -387,7 +387,7 @@ impl fmt::Display for FixupError {
impl<'a, 'tcx> InferCtxt<'a, 'tcx, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
tables: &'a RefCell<ty::Tables<'tcx>>,
param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>,
param_env: Option<ty::ParameterEnvironment<'tcx>>,
projection_mode: ProjectionMode)
-> Self {
InferCtxt {
@ -1440,7 +1440,7 @@ pub fn drain_fulfillment_cx<T>(&self,
// cases.
!traits::type_known_to_meet_builtin_bound(self, ty, ty::BoundCopy, span)
} else {
ty.moves_by_default(&self.parameter_environment, span)
ty.moves_by_default(self.tcx, &self.parameter_environment, span)
}
}
@ -1484,7 +1484,7 @@ pub fn drain_fulfillment_cx<T>(&self,
self.tables.borrow().upvar_capture_map.get(&upvar_id).cloned()
}
pub fn param_env<'b>(&'b self) -> &'b ty::ParameterEnvironment<'b,'tcx> {
pub fn param_env(&self) -> &ty::ParameterEnvironment<'tcx> {
&self.parameter_environment
}

View File

@ -18,7 +18,7 @@ pub use self::ObligationCauseCode::*;
use hir::def_id::DefId;
use middle::free_region::FreeRegionMap;
use ty::subst;
use ty::{self, Ty, TypeFoldable};
use ty::{self, Ty, TyCtxt, TypeFoldable};
use infer::InferCtxt;
use std::rc::Rc;
@ -378,9 +378,10 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx, 'tcx
// FIXME: this is gonna need to be removed ...
/// Normalizes the parameter environment, reporting errors if they occur.
pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvironment<'a,'tcx>,
cause: ObligationCause<'tcx>)
-> ty::ParameterEnvironment<'a,'tcx>
pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
unnormalized_env: ty::ParameterEnvironment<'tcx>,
cause: ObligationCause<'tcx>)
-> ty::ParameterEnvironment<'tcx>
{
// I'm not wild about reporting errors here; I'd prefer to
// have the errors get reported at a defined place (e.g.,
@ -397,7 +398,6 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
// and errors will get reported then; so after typeck we
// can be sure that no errors should occur.
let tcx = unnormalized_env.tcx;
let span = cause.span;
let body_id = cause.body_id;

View File

@ -287,7 +287,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx, 'tcx> {
self.infcx.tcx
}
pub fn param_env(&self) -> &'cx ty::ParameterEnvironment<'cx, 'tcx> {
pub fn param_env(&self) -> &'cx ty::ParameterEnvironment<'tcx> {
self.infcx.param_env()
}

View File

@ -790,7 +790,7 @@ impl<'a, 'tcx> Layout {
ty::TyRef(_, ty::TypeAndMut { ty: pointee, .. }) |
ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
let non_zero = !ty.is_unsafe_ptr();
if pointee.is_sized(&infcx.parameter_environment, DUMMY_SP) {
if pointee.is_sized(tcx, &infcx.parameter_environment, DUMMY_SP) {
Scalar { value: Pointer, non_zero: non_zero }
} else {
let unsized_part = tcx.struct_tail(pointee);
@ -883,7 +883,7 @@ impl<'a, 'tcx> Layout {
// the unsized field. Several other pieces of code assume that the unsized
// field is definitely the last one.
if def.dtor_kind().has_drop_flag() &&
ty.is_sized(&infcx.parameter_environment, DUMMY_SP) {
ty.is_sized(tcx, &infcx.parameter_environment, DUMMY_SP) {
st.extend(dl, Some(Ok(&Scalar {
value: Int(I8),
non_zero: false

View File

@ -1209,9 +1209,7 @@ impl<'tcx> TraitRef<'tcx> {
/// future I hope to refine the representation of types so as to make
/// more distinctions clearer.
#[derive(Clone)]
pub struct ParameterEnvironment<'a, 'tcx:'a> {
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
pub struct ParameterEnvironment<'tcx> {
/// See `construct_free_substs` for details.
pub free_substs: Substs<'tcx>,
@ -1243,13 +1241,12 @@ pub struct ParameterEnvironment<'a, 'tcx:'a> {
pub free_id_outlive: CodeExtent,
}
impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
impl<'a, 'tcx> ParameterEnvironment<'tcx> {
pub fn with_caller_bounds(&self,
caller_bounds: Vec<ty::Predicate<'tcx>>)
-> ParameterEnvironment<'a,'tcx>
-> ParameterEnvironment<'tcx>
{
ParameterEnvironment {
tcx: self.tcx,
free_substs: self.free_substs.clone(),
implicit_region_bound: self.implicit_region_bound,
caller_bounds: caller_bounds,
@ -1260,7 +1257,8 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
}
/// Construct a parameter environment given an item, impl item, or trait item
pub fn for_item(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId) -> ParameterEnvironment<'a, 'tcx> {
pub fn for_item(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId)
-> ParameterEnvironment<'tcx> {
match tcx.map.find(id) {
Some(ast_map::NodeImplItem(ref impl_item)) => {
match impl_item.node {
@ -2546,14 +2544,14 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
///
/// (Note that this implies that if `ty` has a destructor attached,
/// then `type_needs_drop` will definitely return `true` for `ty`.)
pub fn type_needs_drop_given_env<'b>(self,
ty: Ty<'tcx>,
param_env: &ty::ParameterEnvironment<'b,'tcx>) -> bool {
pub fn type_needs_drop_given_env(self,
ty: Ty<'tcx>,
param_env: &ty::ParameterEnvironment<'tcx>) -> bool {
// Issue #22536: We first query type_moves_by_default. It sees a
// normalized version of the type, and therefore will definitely
// know whether the type implements Copy (and thus needs no
// cleanup/drop/zeroing) ...
let implements_copy = !ty.moves_by_default(param_env, DUMMY_SP);
let implements_copy = !ty.moves_by_default(self, param_env, DUMMY_SP);
if implements_copy { return false; }
@ -2803,13 +2801,12 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
/// Construct a parameter environment suitable for static contexts or other contexts where there
/// are no free type/lifetime parameters in scope.
pub fn empty_parameter_environment(self) -> ParameterEnvironment<'a,'tcx> {
pub fn empty_parameter_environment(self) -> ParameterEnvironment<'tcx> {
// for an empty parameter environment, there ARE no free
// regions, so it shouldn't matter what we use for the free id
let free_id_outlive = self.region_maps.node_extent(ast::DUMMY_NODE_ID);
ty::ParameterEnvironment { tcx: self,
free_substs: Substs::empty(),
ty::ParameterEnvironment { free_substs: Substs::empty(),
caller_bounds: Vec::new(),
implicit_region_bound: ty::ReEmpty,
selection_cache: traits::SelectionCache::new(),
@ -2856,7 +2853,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
generics: &ty::Generics<'tcx>,
generic_predicates: &ty::GenericPredicates<'tcx>,
free_id_outlive: CodeExtent)
-> ParameterEnvironment<'a, 'tcx>
-> ParameterEnvironment<'tcx>
{
//
// Construct the free substs.
@ -2886,7 +2883,6 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
//
let unnormalized_env = ty::ParameterEnvironment {
tcx: self,
free_substs: free_substs,
implicit_region_bound: ty::ReScope(free_id_outlive),
caller_bounds: predicates,
@ -2896,7 +2892,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
};
let cause = traits::ObligationCause::misc(span, free_id_outlive.node_id(&self.region_maps));
traits::normalize_param_env_or_error(unnormalized_env, cause)
traits::normalize_param_env_or_error(self, unnormalized_env, cause)
}
pub fn is_method_call(self, expr_id: NodeId) -> bool {

View File

@ -758,10 +758,9 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ClosureUpvar<'tcx> {
}
}
impl<'a, 'tcx> TypeFoldable<'tcx> for ty::ParameterEnvironment<'a, 'tcx> where 'tcx: 'a {
impl<'tcx> TypeFoldable<'tcx> for ty::ParameterEnvironment<'tcx> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::ParameterEnvironment {
tcx: self.tcx,
free_substs: self.free_substs.fold_with(folder),
implicit_region_bound: self.implicit_region_bound.fold_with(folder),
caller_bounds: self.caller_bounds.fold_with(folder),

View File

@ -129,11 +129,10 @@ pub enum Representability {
SelfRecursive,
}
impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
pub fn can_type_implement_copy(&self, self_type: Ty<'tcx>, span: Span)
-> Result<(),CopyImplementationError> {
let tcx = self.tcx;
impl<'tcx> ParameterEnvironment<'tcx> {
pub fn can_type_implement_copy<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
self_type: Ty<'tcx>, span: Span)
-> Result<(),CopyImplementationError> {
// FIXME: (@jroesch) float this code up
let infcx = InferCtxt::new(tcx, &tcx.tables, Some(self.clone()),
ProjectionMode::Topmost);
@ -509,12 +508,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
}
impl<'a, 'tcx> ty::TyS<'tcx> {
fn impls_bound(&'tcx self, param_env: &ParameterEnvironment<'a, 'tcx>,
bound: ty::BuiltinBound,
span: Span)
-> bool
fn impls_bound(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: &ParameterEnvironment<'tcx>,
bound: ty::BuiltinBound, span: Span) -> bool
{
let tcx = param_env.tcx;
let infcx = InferCtxt::new(tcx, &tcx.tables, Some(param_env.clone()),
ProjectionMode::Topmost);
@ -528,7 +525,8 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
}
// FIXME (@jroesch): I made this public to use it, not sure if should be private
pub fn moves_by_default(&'tcx self, param_env: &ParameterEnvironment<'a, 'tcx>,
pub fn moves_by_default(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: &ParameterEnvironment<'tcx>,
span: Span) -> bool {
if self.flags.get().intersects(TypeFlags::MOVENESS_CACHED) {
return self.flags.get().intersects(TypeFlags::MOVES_BY_DEFAULT);
@ -550,7 +548,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
TyArray(..) | TySlice(_) | TyTrait(..) | TyTuple(..) |
TyClosure(..) | TyEnum(..) | TyStruct(..) |
TyProjection(..) | TyParam(..) | TyInfer(..) | TyError => None
}.unwrap_or_else(|| !self.impls_bound(param_env, ty::BoundCopy, span));
}.unwrap_or_else(|| !self.impls_bound(tcx, param_env, ty::BoundCopy, span));
if !self.has_param_types() && !self.has_self_ty() {
self.flags.set(self.flags.get() | if result {
@ -564,17 +562,19 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
}
#[inline]
pub fn is_sized(&'tcx self, param_env: &ParameterEnvironment<'a, 'tcx>,
pub fn is_sized(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: &ParameterEnvironment<'tcx>,
span: Span) -> bool
{
if self.flags.get().intersects(TypeFlags::SIZEDNESS_CACHED) {
return self.flags.get().intersects(TypeFlags::IS_SIZED);
}
self.is_sized_uncached(param_env, span)
self.is_sized_uncached(tcx, param_env, span)
}
fn is_sized_uncached(&'tcx self, param_env: &ParameterEnvironment<'a, 'tcx>,
fn is_sized_uncached(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: &ParameterEnvironment<'tcx>,
span: Span) -> bool {
assert!(!self.needs_infer());
@ -588,7 +588,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
TyEnum(..) | TyStruct(..) | TyProjection(..) | TyParam(..) |
TyInfer(..) | TyError => None
}.unwrap_or_else(|| self.impls_bound(param_env, ty::BoundSized, span));
}.unwrap_or_else(|| self.impls_bound(tcx, param_env, ty::BoundSized, span));
if !self.has_param_types() && !self.has_self_ty() {
self.flags.set(self.flags.get() | if result {

View File

@ -557,7 +557,7 @@ impl<'tcx> fmt::Debug for ty::ClosureUpvar<'tcx> {
}
}
impl<'a, 'tcx> fmt::Debug for ty::ParameterEnvironment<'a, 'tcx> {
impl<'tcx> fmt::Debug for ty::ParameterEnvironment<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "ParameterEnvironment(\
free_substs={:?}, \

View File

@ -92,7 +92,7 @@ struct CheckLoanCtxt<'a, 'tcx: 'a> {
dfcx_loans: &'a LoanDataFlow<'a, 'tcx>,
move_data: &'a move_data::FlowedMoveData<'a, 'tcx>,
all_loans: &'a [Loan<'tcx>],
param_env: &'a ty::ParameterEnvironment<'a, 'tcx>,
param_env: &'a ty::ParameterEnvironment<'tcx>,
}
impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {

View File

@ -627,13 +627,13 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
db.emit();
}
pub fn report_use_of_moved_value<'b>(&self,
use_span: Span,
use_kind: MovedValueUseKind,
lp: &LoanPath<'tcx>,
the_move: &move_data::Move,
moved_lp: &LoanPath<'tcx>,
_param_env: &ty::ParameterEnvironment<'b,'tcx>) {
pub fn report_use_of_moved_value(&self,
use_span: Span,
use_kind: MovedValueUseKind,
lp: &LoanPath<'tcx>,
the_move: &move_data::Move,
moved_lp: &LoanPath<'tcx>,
_param_env: &ty::ParameterEnvironment<'tcx>) {
let (verb, verb_participle) = match use_kind {
MovedInUse => ("use", "used"),
MovedInCapture => ("capture", "captured"),

View File

@ -107,7 +107,7 @@ impl<'a> FromIterator<Vec<&'a Pat>> for Matrix<'a> {
//NOTE: appears to be the only place other then InferCtxt to contain a ParamEnv
pub struct MatchCheckCtxt<'a, 'tcx: 'a> {
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
pub param_env: ParameterEnvironment<'a, 'tcx>,
pub param_env: ParameterEnvironment<'tcx>,
}
#[derive(Clone, PartialEq)]

View File

@ -497,10 +497,10 @@ impl LateLintPass for MissingCopyImplementations {
let parameter_environment = cx.tcx.empty_parameter_environment();
// FIXME (@jroesch) should probably inver this so that the parameter env still impls this
// method
if !ty.moves_by_default(&parameter_environment, item.span) {
if !ty.moves_by_default(cx.tcx, &parameter_environment, item.span) {
return;
}
if parameter_environment.can_type_implement_copy(ty, item.span).is_ok() {
if parameter_environment.can_type_implement_copy(cx.tcx, ty, item.span).is_ok() {
cx.span_lint(MISSING_COPY_IMPLEMENTATIONS,
item.span,
"type could implement `Copy`; consider adding `impl \

View File

@ -75,14 +75,15 @@ bitflags! {
}
}
impl Qualif {
impl<'a, 'tcx> Qualif {
/// Remove flags which are impossible for the given type.
fn restrict<'a, 'tcx>(&mut self, ty: Ty<'tcx>,
param_env: &ty::ParameterEnvironment<'a, 'tcx>) {
if !ty.type_contents(param_env.tcx).interior_unsafe() {
fn restrict(&mut self, ty: Ty<'tcx>,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: &ty::ParameterEnvironment<'tcx>) {
if !ty.type_contents(tcx).interior_unsafe() {
*self = *self - Qualif::MUTABLE_INTERIOR;
}
if !param_env.tcx.type_needs_drop_given_env(ty, param_env) {
if !tcx.type_needs_drop_given_env(ty, param_env) {
*self = *self - Qualif::NEEDS_DROP;
}
}
@ -133,7 +134,7 @@ struct Qualifier<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
mir: &'a Mir<'tcx>,
rpo: ReversePostorder<'a, 'tcx>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
param_env: ty::ParameterEnvironment<'a, 'tcx>,
param_env: ty::ParameterEnvironment<'tcx>,
qualif_map: &'a mut DefIdMap<Qualif>,
mir_map: Option<&'a MirMap<'tcx>>,
temp_qualif: Vec<Option<Qualif>>,
@ -146,7 +147,8 @@ struct Qualifier<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
}
impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
fn new(param_env: ty::ParameterEnvironment<'a, 'tcx>,
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: ty::ParameterEnvironment<'tcx>,
qualif_map: &'a mut DefIdMap<Qualif>,
mir_map: Option<&'a MirMap<'tcx>>,
def_id: DefId,
@ -162,7 +164,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
def_id: def_id,
mir: mir,
rpo: rpo,
tcx: param_env.tcx,
tcx: tcx,
param_env: param_env,
qualif_map: qualif_map,
mir_map: mir_map,
@ -208,7 +210,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
/// Add the given type's qualification to self.qualif.
fn add_type(&mut self, ty: Ty<'tcx>) {
self.add(Qualif::MUTABLE_INTERIOR | Qualif::NEEDS_DROP);
self.qualif.restrict(ty, &self.param_env);
self.qualif.restrict(ty, self.tcx, &self.param_env);
}
/// Within the provided closure, self.qualif will start
@ -555,7 +557,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
}
let ty = this.mir.lvalue_ty(this.tcx, lvalue)
.to_ty(this.tcx);
this.qualif.restrict(ty, &this.param_env);
this.qualif.restrict(ty, this.tcx, &this.param_env);
}
ProjectionElem::ConstantIndex {..} |
@ -939,7 +941,7 @@ fn qualify_const_item_cached<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
bug!("missing constant MIR for {}", tcx.item_path_str(def_id))
});
let mut qualifier = Qualifier::new(param_env, qualif_map, mir_map,
let mut qualifier = Qualifier::new(tcx, param_env, qualif_map, mir_map,
def_id, mir, Mode::Const);
let qualif = qualifier.qualify_const();
qualifier.qualif_map.insert(def_id, qualif);
@ -991,7 +993,7 @@ impl<'tcx> MirMapPass<'tcx> for QualifyAndPromoteConstants {
// This is ugly because Qualifier holds onto mir,
// which can't be mutated until its scope ends.
let (temps, candidates) = {
let mut qualifier = Qualifier::new(param_env, &mut qualif_map,
let mut qualifier = Qualifier::new(tcx, param_env, &mut qualif_map,
None, def_id, mir, mode);
if mode == Mode::ConstFn {
// Enforce a constant-like CFG for `const fn`.
@ -1009,7 +1011,7 @@ impl<'tcx> MirMapPass<'tcx> for QualifyAndPromoteConstants {
// Do the actual promotion, now that we know what's viable.
promote_consts::promote_candidates(mir, tcx, temps, candidates);
} else {
let mut qualifier = Qualifier::new(param_env, &mut qualif_map,
let mut qualifier = Qualifier::new(tcx, param_env, &mut qualif_map,
None, def_id, mir, mode);
qualifier.qualify_const();
}

View File

@ -55,7 +55,7 @@ impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for RvalueContext<'a, 'tcx> {
struct RvalueContextDelegate<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: &'a ty::ParameterEnvironment<'a,'tcx>,
param_env: &'a ty::ParameterEnvironment<'tcx>,
}
impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> {
@ -65,7 +65,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> {
cmt: mc::cmt<'tcx>,
_: euv::ConsumeMode) {
debug!("consume; cmt: {:?}; type: {:?}", *cmt, cmt.ty);
if !cmt.ty.is_sized(self.param_env, span) {
if !cmt.ty.is_sized(self.tcx, self.param_env, span) {
span_err!(self.tcx.sess, span, E0161,
"cannot move a value of type {0}: the size of {0} cannot be statically determined",
cmt.ty);

View File

@ -1532,7 +1532,7 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &hir::Pat,
let llmatch;
let trmode;
let moves_by_default = variable_ty.moves_by_default(&param_env, span);
let moves_by_default = variable_ty.moves_by_default(tcx, &param_env, span);
match bm {
hir::BindByValue(_) if !moves_by_default || reassigned =>
{

View File

@ -59,7 +59,7 @@ pub use context::{CrateContext, SharedCrateContext};
/// Is the type's representation size known at compile time?
pub fn type_is_sized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
ty.is_sized(&tcx.empty_parameter_environment(), DUMMY_SP)
ty.is_sized(tcx, &tcx.empty_parameter_environment(), DUMMY_SP)
}
pub fn type_is_fat_ptr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
@ -281,7 +281,7 @@ pub struct FunctionContext<'a, 'tcx: 'a> {
pub llfn: ValueRef,
// always an empty parameter-environment NOTE: @jroesch another use of ParamEnv
pub param_env: ty::ParameterEnvironment<'a, 'tcx>,
pub param_env: ty::ParameterEnvironment<'tcx>,
// A pointer to where to store the return value. If the return type is
// immediate, this points to an alloca in the function. Otherwise, it's a

View File

@ -769,8 +769,8 @@ impl<'tcx, K: KindOps + fmt::Debug> Datum<'tcx, K> {
* affine values (since they must never be duplicated).
*/
assert!(!self.ty
.moves_by_default(&bcx.tcx().empty_parameter_environment(), DUMMY_SP));
assert!(!self.ty.moves_by_default(bcx.tcx(),
&bcx.tcx().empty_parameter_environment(), DUMMY_SP));
self.shallow_copy_raw(bcx, dst)
}

View File

@ -239,7 +239,8 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
// the new hybrid bounds we computed.
let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_body_id);
let trait_param_env = impl_param_env.with_caller_bounds(hybrid_preds.into_vec());
let trait_param_env = traits::normalize_param_env_or_error(trait_param_env,
let trait_param_env = traits::normalize_param_env_or_error(tcx,
trait_param_env,
normalize_cause.clone());
// FIXME(@jroesch) this seems ugly, but is a temporary change
infcx.parameter_environment = trait_param_env;

View File

@ -375,7 +375,7 @@ impl<'a, 'gcx, 'tcx> Deref for FnCtxt<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Inherited<'a, 'tcx, 'tcx> {
fn new(ccx: &'a CrateCtxt<'a, 'tcx>,
tables: &'a RefCell<ty::Tables<'tcx>>,
param_env: ty::ParameterEnvironment<'a, 'tcx>)
param_env: ty::ParameterEnvironment<'tcx>)
-> Inherited<'a, 'tcx, 'tcx> {
Inherited {
@ -490,7 +490,7 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
fn_id: ast::NodeId,
fn_span: Span,
raw_fty: Ty<'tcx>,
param_env: ty::ParameterEnvironment<'a, 'tcx>)
param_env: ty::ParameterEnvironment<'tcx>)
{
match raw_fty.sty {
ty::TyFnDef(_, _, ref fn_ty) => {
@ -1449,7 +1449,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx, 'tcx> {
}
}
pub fn param_env(&self) -> &ty::ParameterEnvironment<'a,'tcx> {
pub fn param_env(&self) -> &ty::ParameterEnvironment<'tcx> {
&self.parameter_environment
}

View File

@ -302,7 +302,7 @@ fn get_base_type_def_id(&self, span: Span, ty: Ty<'tcx>) -> Option<DefId> {
debug!("check_implementations_of_copy: self_type={:?} (free)",
self_type);
match param_env.can_type_implement_copy(self_type, span) {
match param_env.can_type_implement_copy(tcx, self_type, span) {
Ok(()) => {}
Err(CopyImplementationError::InfrigingField(name)) => {
span_err!(tcx.sess, span, E0204,