rename parameter_environment to param_env

This commit is contained in:
Niko Matsakis 2017-05-15 18:00:35 -04:00
parent 697146bf40
commit 45dd0632bc
24 changed files with 44 additions and 44 deletions

View File

@ -161,7 +161,7 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
// For region variables.
region_vars: RegionVarBindings<'a, 'gcx, 'tcx>,
pub parameter_environment: ty::ParamEnv<'gcx>,
pub param_env: ty::ParamEnv<'gcx>,
/// Caches the results of trait selection. This cache is used
/// for things that have to do with the parameters in scope.
@ -453,7 +453,7 @@ impl<'a, 'tcx> InferEnv<'a, 'tcx> for hir::BodyId {
let def_id = tcx.hir.body_owner_def_id(self);
(Some(tcx.typeck_tables_of(def_id)),
None,
Some(tcx.parameter_environment(def_id)))
Some(tcx.param_env(def_id)))
}
}
@ -498,7 +498,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'gcx> {
int_unification_table: RefCell::new(UnificationTable::new()),
float_unification_table: RefCell::new(UnificationTable::new()),
region_vars: RegionVarBindings::new(self),
parameter_environment: param_env.unwrap(),
param_env: param_env.unwrap(),
selection_cache: traits::SelectionCache::new(),
evaluation_cache: traits::EvaluationCache::new(),
projection_cache: RefCell::new(traits::ProjectionCache::new()),
@ -535,7 +535,7 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
int_unification_table: RefCell::new(UnificationTable::new()),
float_unification_table: RefCell::new(UnificationTable::new()),
region_vars: RegionVarBindings::new(tcx),
parameter_environment: param_env,
param_env: param_env,
selection_cache: traits::SelectionCache::new(),
evaluation_cache: traits::EvaluationCache::new(),
reported_trait_errors: RefCell::new(FxHashSet()),
@ -1673,7 +1673,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}
pub fn param_env(&self) -> ty::ParamEnv<'gcx> {
self.parameter_environment
self.param_env
}
pub fn closure_kind(&self,

View File

@ -482,7 +482,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx.infer_ctxt(elaborated_env, Reveal::UserFacing).enter(|infcx| {
let predicates = match fully_normalize(
&infcx, cause,
// You would really want to pass infcx.parameter_environment.caller_bounds here,
// You would really want to pass infcx.param_env.caller_bounds here,
// but that is an interned slice, and fully_normalize takes &T and returns T, so
// without further refactoring, a slice can't be used. Luckily, we still have the
// predicate vector from which we created the ParamEnv in infcx, so we
@ -494,7 +494,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
Err(errors) => {
infcx.report_fulfillment_errors(&errors);
// An unnormalized env is better than nothing.
return infcx.parameter_environment;
return infcx.param_env;
}
};
@ -516,13 +516,13 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// all things considered.
tcx.sess.span_err(span, &fixup_err.to_string());
// An unnormalized env is better than nothing.
return infcx.parameter_environment;
return infcx.param_env;
}
};
let predicates = match tcx.lift_to_global(&predicates) {
Some(predicates) => predicates,
None => return infcx.parameter_environment
None => return infcx.param_env
};
debug!("normalize_param_env_or_error: resolved predicates={:?}",

View File

@ -180,7 +180,7 @@ pub fn specializes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
// create a parameter environment corresponding to a (skolemized) instantiation of impl1
let penv = tcx.parameter_environment(impl1_def_id);
let penv = tcx.param_env(impl1_def_id);
let impl1_trait_ref = tcx.impl_trait_ref(impl1_def_id).unwrap();
// Create a infcx, taking the predicates of impl1 as assumptions:
@ -250,7 +250,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
source_trait_ref,
target_trait_ref,
errors,
infcx.parameter_environment.caller_bounds);
infcx.param_env.caller_bounds);
Err(())
}

View File

@ -1079,7 +1079,7 @@ impl<'a, 'gcx, 'tcx> Layout {
let ptr_layout = |pointee: Ty<'gcx>| {
let non_zero = !ty.is_unsafe_ptr();
let pointee = infcx.normalize_projections(pointee);
if pointee.is_sized(tcx, infcx.parameter_environment, DUMMY_SP) {
if pointee.is_sized(tcx, infcx.param_env, DUMMY_SP) {
Ok(Scalar { value: Pointer, non_zero: non_zero })
} else {
let unsized_part = tcx.struct_tail(pointee);
@ -1268,7 +1268,7 @@ impl<'a, 'gcx, 'tcx> Layout {
let kind = if def.is_enum() || def.variants[0].fields.len() == 0{
StructKind::AlwaysSizedUnivariant
} else {
let param_env = tcx.parameter_environment(def.did);
let param_env = tcx.param_env(def.did);
let fields = &def.variants[0].fields;
let last_field = &fields[fields.len()-1];
let always_sized = tcx.type_of(last_field.did)

View File

@ -890,7 +890,7 @@ define_maps! { <'tcx>
[] specialization_graph_of: SpecializationGraph(DefId) -> Rc<specialization_graph::Graph>,
[] is_object_safe: ObjectSafety(DefId) -> bool,
[] parameter_environment: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
[] param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
// Trait selection queries. These are best used by invoking `ty.moves_by_default()`,
// `ty.is_copy()`, etc, since that will prune the environment where possible.

View File

@ -2518,7 +2518,7 @@ fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option
}
/// See `ParamEnv` struct def'n for details.
fn parameter_environment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId)
-> ParamEnv<'tcx> {
// Compute the bounds on Self and the type parameters.
@ -2555,7 +2555,7 @@ pub fn provide(providers: &mut ty::maps::Providers) {
adt_sized_constraint,
adt_dtorck_constraint,
def_span,
parameter_environment,
param_env,
trait_of_item,
trait_impls_of: trait_def::trait_impls_of_provider,
relevant_trait_impls_for: trait_def::relevant_trait_impls_provider,
@ -2569,7 +2569,7 @@ pub fn provide_extern(providers: &mut ty::maps::Providers) {
adt_dtorck_constraint,
trait_impls_of: trait_def::trait_impls_of_provider,
relevant_trait_impls_for: trait_def::relevant_trait_impls_provider,
parameter_environment,
param_env,
..*providers
};
}

View File

@ -197,7 +197,7 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
dfcx_loans: dfcx_loans,
move_data: move_data,
all_loans: all_loans,
param_env: &infcx.parameter_environment
param_env: &infcx.param_env
};
euv::ExprUseVisitor::new(&mut clcx, &bccx.region_maps, &infcx).consume_body(body);
}

View File

@ -44,7 +44,7 @@ impl MirPass for ElaborateDrops {
_ => return
}
let id = src.item_id();
let param_env = tcx.parameter_environment(tcx.hir.local_def_id(id));
let param_env = tcx.param_env(tcx.hir.local_def_id(id));
let move_data = MoveData::gather_moves(mir, tcx, param_env);
let elaborate_patch = {
let mir = &*mir;

View File

@ -65,7 +65,7 @@ pub fn borrowck_mir(bcx: &mut BorrowckCtxt,
// steals it, but it forces the `borrowck` query.
let mir = &tcx.mir_validated(def_id).borrow();
let param_env = tcx.parameter_environment(def_id);
let param_env = tcx.param_env(def_id);
let move_data = MoveData::gather_moves(mir, tcx, param_env);
let mdpe = MoveDataParamEnv { move_data: move_data, param_env: param_env };
let dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len());

View File

@ -52,7 +52,7 @@ impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> {
tcx: self.tcx,
tables: self.tcx.body_tables(b),
region_maps: &self.tcx.region_maps(def_id),
param_env: self.tcx.parameter_environment(def_id)
param_env: self.tcx.param_env(def_id)
}.visit_body(self.tcx.hir.body(b));
}
}

View File

@ -988,7 +988,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
traits::Obligation::new(traits::ObligationCause::misc(span, expr_id),
trait_ref.to_poly_trait_predicate());
let param_env = tcx.parameter_environment(method.def_id);
let param_env = tcx.param_env(method.def_id);
tcx.infer_ctxt(param_env, Reveal::UserFacing).enter(|infcx| {
let mut selcx = traits::SelectionContext::new(&infcx);
match selcx.select(&obligation) {
@ -1257,7 +1257,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
fn check_item(&mut self, ctx: &LateContext, item: &hir::Item) {
if let hir::ItemUnion(ref vdata, _) = item.node {
let item_def_id = ctx.tcx.hir.local_def_id(item.id);
let param_env = ctx.tcx.parameter_environment(item_def_id);
let param_env = ctx.tcx.param_env(item_def_id);
for field in vdata.fields() {
let field_ty = ctx.tcx.type_of(ctx.tcx.hir.local_def_id(field.id));
if field_ty.needs_drop(ctx.tcx, param_env) {

View File

@ -172,7 +172,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
{
let span = tcx.hir.span(ctor_id);
if let hir::VariantData::Tuple(ref fields, ctor_id) = *v {
let pe = tcx.parameter_environment(tcx.hir.local_def_id(ctor_id));
let pe = tcx.param_env(tcx.hir.local_def_id(ctor_id));
tcx.infer_ctxt(pe, Reveal::UserFacing).enter(|infcx| {
let (mut mir, src) =
shim::build_adt_ctor(&infcx, ctor_id, fields, span);

View File

@ -168,7 +168,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
type with inference types/regions",
ty);
});
ty.needs_drop(self.tcx.global_tcx(), self.infcx.parameter_environment)
ty.needs_drop(self.tcx.global_tcx(), self.infcx.param_env)
}
pub fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> {

View File

@ -186,7 +186,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
if let Some(..) = ty {
let patch = {
let param_env = tcx.parameter_environment(def_id);
let param_env = tcx.param_env(def_id);
let mut elaborator = DropShimElaborator {
mir: &mir,
patch: MirPatch::new(&mir),

View File

@ -220,7 +220,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
// FIXME: Give a bonus to functions with only a single caller
let def_id = tcx.hir.local_def_id(self.source.item_id());
let param_env = tcx.parameter_environment(def_id);
let param_env = tcx.param_env(def_id);
let mut first_block = true;
let mut cost = 0;

View File

@ -937,7 +937,7 @@ fn mir_const_qualif<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
return Qualif::NOT_CONST.bits();
}
let param_env = tcx.parameter_environment(def_id);
let param_env = tcx.param_env(def_id);
let mut qualifier = Qualifier::new(tcx, param_env, def_id, mir, Mode::Const);
qualifier.qualify_const().bits()
@ -965,7 +965,7 @@ impl MirPass for QualifyAndPromoteConstants {
MirSource::Const(_) |
MirSource::Promoted(..) => return
};
let param_env = tcx.parameter_environment(def_id);
let param_env = tcx.param_env(def_id);
if mode == Mode::Fn || mode == Mode::ConstFn {
// This is ugly because Qualifier holds onto mir,

View File

@ -751,7 +751,7 @@ impl MirPass for TypeckMir {
// broken MIR, so try not to report duplicate errors.
return;
}
let param_env = tcx.parameter_environment(def_id);
let param_env = tcx.param_env(def_id);
tcx.infer_ctxt(param_env, Reveal::UserFacing).enter(|infcx| {
let mut checker = TypeChecker::new(&infcx, item_id);
{

View File

@ -139,7 +139,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> {
}
let outer_penv = self.tcx.infer_ctxt(body_id, Reveal::UserFacing).enter(|infcx| {
let param_env = infcx.parameter_environment.clone();
let param_env = infcx.param_env.clone();
let outer_penv = mem::replace(&mut self.param_env, param_env);
let region_maps = &self.tcx.region_maps(item_def_id);;
euv::ExprUseVisitor::new(self, region_maps, &infcx).consume_body(body);

View File

@ -223,7 +223,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let infcx = &inh.infcx;
debug!("compare_impl_method: caller_bounds={:?}",
infcx.parameter_environment.caller_bounds);
infcx.param_env.caller_bounds);
let mut selcx = traits::SelectionContext::new(&infcx);
@ -345,7 +345,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let region_maps = RegionMaps::new();
let mut free_regions = FreeRegionMap::new();
free_regions.relate_free_regions_from_predicates(
&infcx.parameter_environment.caller_bounds);
&infcx.param_env.caller_bounds);
infcx.resolve_regions_and_report_errors(impl_m.def_id, &region_maps, &free_regions);
} else {
let fcx = FnCtxt::new(&inh, impl_m_node_id);

View File

@ -79,7 +79,7 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>(
// check that the impl type can be made to match the trait type.
let impl_param_env = tcx.parameter_environment(self_type_did);
let impl_param_env = tcx.param_env(self_type_did);
tcx.infer_ctxt(impl_param_env, Reveal::UserFacing).enter(|ref infcx| {
let tcx = infcx.tcx;
let mut fulfillment_cx = traits::FulfillmentContext::new();

View File

@ -566,7 +566,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
param_ty: ty::ParamTy) {
// FIXME -- Do we want to commit to this behavior for param bounds?
let bounds: Vec<_> = self.parameter_environment
let bounds: Vec<_> = self.param_env
.caller_bounds
.iter()
.filter_map(|predicate| {
@ -893,7 +893,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
debug!("assemble_where_clause_candidates(trait_def_id={:?})",
trait_def_id);
let caller_predicates = self.parameter_environment.caller_bounds.to_vec();
let caller_predicates = self.param_env.caller_bounds.to_vec();
for poly_bound in traits::elaborate_predicates(self.tcx, caller_predicates)
.filter_map(|p| p.to_opt_poly_trait_ref())
.filter(|b| b.def_id() == trait_def_id) {

View File

@ -539,7 +539,7 @@ impl<'a, 'gcx, 'tcx> Inherited<'a, 'gcx, 'tcx> {
pub fn build(tcx: TyCtxt<'a, 'gcx, 'gcx>, def_id: DefId)
-> InheritedBuilder<'a, 'gcx, 'tcx> {
let tables = ty::TypeckTables::empty();
let param_env = tcx.parameter_environment(def_id);
let param_env = tcx.param_env(def_id);
InheritedBuilder {
infcx: tcx.infer_ctxt((tables, param_env), Reveal::UserFacing),
def_id,
@ -1561,7 +1561,7 @@ impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> {
let index = generics.type_param_to_index[&def_id.index];
ty::GenericPredicates {
parent: None,
predicates: self.parameter_environment.caller_bounds.iter().filter(|predicate| {
predicates: self.param_env.caller_bounds.iter().filter(|predicate| {
match **predicate {
ty::Predicate::Trait(ref data) => {
data.0.self_ty().is_param(index)

View File

@ -138,7 +138,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let subject = self.tcx.hir.local_def_id(item_id);
let mut rcx = RegionCtxt::new(self, RepeatingScope(item_id), item_id, Subject(subject));
rcx.free_region_map.relate_free_regions_from_predicates(
&self.parameter_environment.caller_bounds);
&self.param_env.caller_bounds);
rcx.relate_free_regions(wf_tys, item_id, span);
rcx.visit_region_obligations(item_id);
rcx.resolve_regions_and_report_errors();
@ -158,7 +158,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
rcx.free_region_map.relate_free_regions_from_predicates(
&self.parameter_environment.caller_bounds);
&self.param_env.caller_bounds);
rcx.resolve_regions_and_report_errors();
@ -1682,7 +1682,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
fn declared_generic_bounds_from_env(&self, generic: GenericKind<'tcx>)
-> Vec<ty::Region<'tcx>>
{
let param_env = &self.parameter_environment;
let param_env = &self.param_env;
// To start, collect bounds from user:
let mut param_bounds = self.tcx.required_region_bounds(generic.to_ty(self.tcx),

View File

@ -105,7 +105,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
self_type);
let span = tcx.hir.span(impl_node_id);
let param_env = tcx.parameter_environment(impl_did);
let param_env = tcx.param_env(impl_did);
assert!(!self_type.has_escaping_regions());
debug!("visit_implementation_of_copy: self_type={:?} (free)",
@ -199,7 +199,7 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
target);
let span = tcx.hir.span(impl_node_id);
let param_env = tcx.parameter_environment(impl_did);
let param_env = tcx.param_env(impl_did);
assert!(!source.has_escaping_regions());
let err_info = CoerceUnsizedInfo { custom_kind: None };
@ -387,7 +387,7 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Finally, resolve all regions.
let region_maps = RegionMaps::new();
let mut free_regions = FreeRegionMap::new();
free_regions.relate_free_regions_from_predicates(&infcx.parameter_environment
free_regions.relate_free_regions_from_predicates(&infcx.param_env
.caller_bounds);
infcx.resolve_regions_and_report_errors(impl_did, &region_maps, &free_regions);