]> git.lizzy.rs Git - rust.git/commitdiff
refactor `ParamEnv::empty(Reveal)` into two distinct methods
authorNiko Matsakis <niko@alum.mit.edu>
Sat, 10 Feb 2018 18:18:02 +0000 (13:18 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 13 Mar 2018 15:21:30 +0000 (11:21 -0400)
- `ParamEnv::empty()` -- does not reveal all, good for typeck
- `ParamEnv::reveal_all()` -- does, good for trans
- `param_env.with_reveal_all()` -- converts an existing parameter environment

29 files changed:
src/librustc/infer/mod.rs
src/librustc/lint/context.rs
src/librustc/traits/coherence.rs
src/librustc/traits/error_reporting.rs
src/librustc/traits/mod.rs
src/librustc/traits/select.rs
src/librustc/traits/specialize/mod.rs
src/librustc/traits/structural_impls.rs
src/librustc/ty/instance.rs
src/librustc/ty/layout.rs
src/librustc/ty/mod.rs
src/librustc/ty/relate.rs
src/librustc/ty/util.rs
src/librustc_driver/test.rs
src/librustc_lint/builtin.rs
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/monomorphize/collector.rs
src/librustc_mir/monomorphize/mod.rs
src/librustc_mir/transform/qualify_consts.rs
src/librustc_passes/rvalue_promotion.rs
src/librustc_trans/callee.rs
src/librustc_trans/common.rs
src/librustc_trans/context.rs
src/librustc_trans/mir/block.rs
src/librustc_trans/mir/constant.rs
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/dropck.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/lib.rs

index 713cf56085151ded6e0d0ba3e75cd9af2a2f41a6..5f0c2d1e76bcc2ab7b0379ffa92b5c5e12b99ee9 100644 (file)
@@ -28,7 +28,7 @@
 use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
 use ty::fold::TypeFoldable;
 use ty::relate::RelateResult;
-use traits::{self, ObligationCause, PredicateObligations, Reveal};
+use traits::{self, ObligationCause, PredicateObligations};
 use rustc_data_structures::unify as ut;
 use std::cell::{Cell, RefCell, Ref, RefMut};
 use std::collections::BTreeMap;
@@ -563,7 +563,7 @@ pub fn fully_normalize_associated_types_in<T>(self, value: &T) -> T
     {
         debug!("fully_normalize_associated_types_in(t={:?})", value);
 
-        let param_env = ty::ParamEnv::empty(Reveal::All);
+        let param_env = ty::ParamEnv::reveal_all();
         let value = self.erase_regions(value);
 
         if !value.has_projections() {
@@ -593,7 +593,7 @@ pub fn normalize_associated_type_in_env<T>(
         }
 
         self.infer_ctxt().enter(|infcx| {
-            value.trans_normalize(&infcx, env.reveal_all())
+            value.trans_normalize(&infcx, env.with_reveal_all())
        })
     }
 }
index a1381817223f19f8be7077f1056e7b3d3b464a42..4fa6594df169cd4af5f33efb3b9172410b6e7cba 100644 (file)
@@ -34,7 +34,6 @@
 use middle::privacy::AccessLevels;
 use rustc_serialize::{Decoder, Decodable, Encoder, Encodable};
 use session::{config, early_error, Session};
-use traits::Reveal;
 use ty::{self, TyCtxt, Ty};
 use ty::layout::{LayoutError, LayoutOf, TyLayout};
 use util::nodemap::FxHashMap;
@@ -1055,7 +1054,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
     let mut cx = LateContext {
         tcx,
         tables: &ty::TypeckTables::empty(None),
-        param_env: ty::ParamEnv::empty(Reveal::UserFacing),
+        param_env: ty::ParamEnv::empty(),
         access_levels,
         lint_sess: LintSession::new(&tcx.sess.lint_store),
         last_ast_node_with_lint_attrs: ast::CRATE_NODE_ID,
index 183b1a5470e5ac0a7aa5cdb65f27f99f3aa778cc..06926b1648df5ed67acb09754865599c3e64e088 100644 (file)
@@ -16,7 +16,7 @@
 
 use hir::def_id::{DefId, LOCAL_CRATE};
 use syntax_pos::DUMMY_SP;
-use traits::{self, Normalized, SelectionContext, Obligation, ObligationCause, Reveal};
+use traits::{self, Normalized, SelectionContext, Obligation, ObligationCause};
 use traits::IntercrateMode;
 use traits::select::IntercrateAmbiguityCause;
 use ty::{self, Ty, TyCtxt};
@@ -125,7 +125,7 @@ fn overlap<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>,
     // types into scope; instead, we replace the generic types with
     // fresh type variables, and hence we do our evaluations in an
     // empty environment.
-    let param_env = ty::ParamEnv::empty(Reveal::UserFacing);
+    let param_env = ty::ParamEnv::empty();
 
     let a_impl_header = with_fresh_ty_vars(selcx, param_env, a_def_id);
     let b_impl_header = with_fresh_ty_vars(selcx, param_env, b_def_id);
index cd2d0d7e2a043d297715b7d37818ab112570b922..b8455b97fa41f3eb7f514475eff5ceb954df1376 100644 (file)
@@ -21,7 +21,6 @@
     TraitNotObjectSafe,
     ConstEvalFailure,
     PredicateObligation,
-    Reveal,
     SelectionContext,
     SelectionError,
     ObjectSafetyViolation,
@@ -140,7 +139,7 @@ fn error_implies(&self,
                 // FIXME: I'm just not taking associated types at all here.
                 // Eventually I'll need to implement param-env-aware
                 // `Γ₁ ⊦ φ₁ => Γ₂ ⊦ φ₂` logic.
-                let param_env = ty::ParamEnv::empty(Reveal::UserFacing);
+                let param_env = ty::ParamEnv::empty();
                 if let Ok(_) = self.can_sub(param_env, error, implication) {
                     debug!("error_implies: {:?} -> {:?} -> {:?}", cond, error, implication);
                     return true
index e0e85600b9036c353f1fda479fb98f33e8fddfc4..4450c60b68d3b6a8f68d92b8845545ae71d50d3f 100644 (file)
@@ -695,7 +695,7 @@ fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
            predicates);
 
     let result = tcx.infer_ctxt().enter(|infcx| {
-        let param_env = ty::ParamEnv::empty(Reveal::All);
+        let param_env = ty::ParamEnv::reveal_all();
         let mut selcx = SelectionContext::new(&infcx);
         let mut fulfill_cx = FulfillmentContext::new();
         let cause = ObligationCause::dummy();
index 91d86394b0192d56ae58c7383a027def22f27c46..728702ef61fd10cfe95da5fb49546ccd7eaab954 100644 (file)
@@ -777,7 +777,7 @@ fn evaluate_trait_predicate_recursively<'o>(&mut self,
             // value in order to work, so we can clear out the param env and get better
             // caching. (If the current param env is inconsistent, we don't care what happens).
             debug!("evaluate_trait_predicate_recursively({:?}) - in global", obligation);
-            obligation.param_env = ty::ParamEnv::empty(obligation.param_env.reveal);
+            obligation.param_env = obligation.param_env.without_caller_bounds();
         }
 
         let stack = self.push_stack(previous_stack, &obligation);
index d11565618a687ede894f069fa6f841c4ab38599c..5ea089abb8e86ac6be8e413515d73671ab23f737 100644 (file)
@@ -26,7 +26,7 @@
 use hir::def_id::DefId;
 use infer::{InferCtxt, InferOk};
 use ty::subst::{Subst, Substs};
-use traits::{self, Reveal, ObligationCause};
+use traits::{self, ObligationCause};
 use traits::select::IntercrateAmbiguityCause;
 use ty::{self, TyCtxt, TypeFoldable};
 use syntax_pos::DUMMY_SP;
@@ -132,7 +132,7 @@ pub fn find_associated_item<'a, 'tcx>(
     match ancestors.defs(tcx, item.name, item.kind, trait_def_id).next() {
         Some(node_item) => {
             let substs = tcx.infer_ctxt().enter(|infcx| {
-                let param_env = ty::ParamEnv::empty(Reveal::All);
+                let param_env = ty::ParamEnv::reveal_all();
                 let substs = substs.rebase_onto(tcx, trait_def_id, impl_data.substs);
                 let substs = translate_substs(&infcx, param_env, impl_data.impl_def_id,
                                               substs, node_item.node);
index 99adc1fc873defaf7227ec6aaa8adf79b18991b4..a2d98a456f49a0ea39b00b7e2eb7b226208b3bb9 100644 (file)
@@ -425,5 +425,3 @@ impl<'tcx, T> TypeFoldable<'tcx> for Normalized<'tcx, T> {
         obligations
     } where T: TypeFoldable<'tcx>
 }
-
-
index 614158bafa63807332ec72f31d34875f2253f6c3..ebb058c5d292904fa3a8d03493451f711459631e 100644 (file)
@@ -199,7 +199,7 @@ pub fn resolve(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 _ => {
                     if Some(def_id) == tcx.lang_items().drop_in_place_fn() {
                         let ty = substs.type_at(0);
-                        if ty.needs_drop(tcx, ty::ParamEnv::empty(traits::Reveal::All)) {
+                        if ty.needs_drop(tcx, ty::ParamEnv::reveal_all()) {
                             debug!(" => nontrivial drop glue");
                             ty::InstanceDef::DropGlue(def_id, Some(ty))
                         } else {
index 1b919ad68d047069d141ed0d736a07e570786e0f..9ce232ba17303638dbc936fd6eb55ba5b407e304 100644 (file)
@@ -2058,7 +2058,7 @@ impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
     /// Computes the layout of a type. Note that this implicitly
     /// executes in "reveal all" mode.
     fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
-        let param_env = self.param_env.reveal_all();
+        let param_env = self.param_env.with_reveal_all();
         let ty = self.tcx.normalize_associated_type_in_env(&ty, param_env);
         let details = self.tcx.layout_raw(param_env.and(ty))?;
         let layout = TyLayout {
@@ -2084,9 +2084,9 @@ impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for LayoutCx<'tcx, ty::maps::TyCtxtAt<'a, 'tcx
     /// Computes the layout of a type. Note that this implicitly
     /// executes in "reveal all" mode.
     fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
-        let param_env = self.param_env.reveal_all();
-        let ty = self.tcx.normalize_associated_type_in_env(&ty, param_env.reveal_all());
-        let details = self.tcx.layout_raw(param_env.reveal_all().and(ty))?;
+        let param_env = self.param_env.with_reveal_all();
+        let ty = self.tcx.normalize_associated_type_in_env(&ty, param_env);
+        let details = self.tcx.layout_raw(param_env.and(ty))?;
         let layout = TyLayout {
             ty,
             details
index 63494438f7d82e6866088d934542f9e883bab9ae..40d7aa9556df9598c3e682dbf2a55a34c779b051 100644 (file)
@@ -1420,7 +1420,7 @@ pub fn and<T: TypeFoldable<'tcx>>(self, value: T) -> ParamEnvAnd<'tcx, T> {
             }
         } else {
             ParamEnvAnd {
-                param_env: ParamEnv::empty(self.reveal),
+                param_env: self.without_caller_bounds(),
                 value,
             }
         }
@@ -1829,7 +1829,7 @@ pub fn eval_explicit_discr(
         tcx: TyCtxt<'a, 'gcx, 'tcx>,
         expr_did: DefId,
     ) -> Option<Discr<'tcx>> {
-        let param_env = ParamEnv::empty(traits::Reveal::UserFacing);
+        let param_env = ParamEnv::empty();
         let repr_type = self.repr.discr_type();
         let bit_size = layout::Integer::from_attr(tcx, repr_type).size().bits();
         let substs = Substs::identity_for_item(tcx.global_tcx(), expr_did);
index 7f48f8c431fac08ae71befb3e8fef059945a825a..72e7d16b64dcec2da31f3930c3e0b23eb7112107 100644 (file)
@@ -15,7 +15,6 @@
 
 use hir::def_id::DefId;
 use middle::const_val::ConstVal;
-use traits::Reveal;
 use ty::subst::{Kind, UnpackedKind, Substs};
 use ty::{self, Ty, TyCtxt, TypeFoldable};
 use ty::error::{ExpectedFound, TypeError};
@@ -473,7 +472,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
                     ConstVal::Value(Value::ByVal(prim)) => Ok(prim.to_u64().unwrap()),
                     ConstVal::Unevaluated(def_id, substs) => {
                         // FIXME(eddyb) get the right param_env.
-                        let param_env = ty::ParamEnv::empty(Reveal::UserFacing);
+                        let param_env = ty::ParamEnv::empty();
                         match tcx.lift_to_global(&substs) {
                             Some(substs) => {
                                 let instance = ty::Instance::resolve(
index cbd9a1b8d4f932de801e58e65ec3364310348a4b..ca6817d992b6e2e41f67e7e4967054095d16bbf1 100644 (file)
@@ -183,9 +183,22 @@ pub enum Representability {
 
 impl<'tcx> ty::ParamEnv<'tcx> {
     /// Construct a trait environment suitable for contexts where
-    /// there are no where clauses in scope.
-    pub fn empty(reveal: Reveal) -> Self {
-        Self::new(ty::Slice::empty(), reveal, ty::UniverseIndex::ROOT)
+    /// there are no where clauses in scope. Hidden types (like `impl
+    /// Trait`) are left hidden, so this is suitable for ordinary
+    /// type-checking.
+    pub fn empty() -> Self {
+        Self::new(ty::Slice::empty(), Reveal::UserFacing, ty::UniverseIndex::ROOT)
+    }
+
+    /// Construct a trait environment with no where clauses in scope
+    /// where the values of all `impl Trait` and other hidden types
+    /// are revealed. This is suitable for monomorphized, post-typeck
+    /// environments like trans or doing optimizations.
+    ///
+    /// NB. If you want to have predicates in scope, use `ParamEnv::new`,
+    /// or invoke `param_env.with_reveal_all()`.
+    pub fn reveal_all() -> Self {
+        Self::new(ty::Slice::empty(), Reveal::All, ty::UniverseIndex::ROOT)
     }
 
     /// Construct a trait environment with the given set of predicates.
@@ -202,10 +215,15 @@ pub fn new(caller_bounds: &'tcx ty::Slice<ty::Predicate<'tcx>>,
     /// the desired behavior during trans and certain other special
     /// contexts; normally though we want to use `Reveal::UserFacing`,
     /// which is the default.
-    pub fn reveal_all(self) -> Self {
+    pub fn with_reveal_all(self) -> Self {
         ty::ParamEnv { reveal: Reveal::All, ..self }
     }
 
+    /// Returns this same environment but with no caller bounds.
+    pub fn without_caller_bounds(self) -> Self {
+        ty::ParamEnv { caller_bounds: ty::Slice::empty(), ..self }
+    }
+
     pub fn can_type_implement_copy<'a>(self,
                                        tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                        self_type: Ty<'tcx>, span: Span)
index becdbb54e5beb2bd1dcddc1ad157d09d86c5200a..06610609ebdbddb3c6036ddb4f53e34a6ed20cac 100644 (file)
@@ -18,7 +18,7 @@
 use rustc_resolve::MakeGlobMap;
 use rustc::middle::region;
 use rustc::ty::subst::Subst;
-use rustc::traits::{ObligationCause, Reveal};
+use rustc::traits::ObligationCause;
 use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
 use rustc::ty::maps::OnDiskCache;
 use rustc::infer::{self, InferOk, InferResult};
@@ -153,7 +153,7 @@ fn test_env<F>(source_string: &str,
                              |tcx| {
         tcx.infer_ctxt().enter(|infcx| {
             let mut region_scope_tree = region::ScopeTree::default();
-            let param_env = ty::ParamEnv::empty(Reveal::UserFacing);
+            let param_env = ty::ParamEnv::empty();
             body(Env {
                 infcx: &infcx,
                 region_scope_tree: &mut region_scope_tree,
index c6698cbd006893c7f664152d3af957dd3e7e0005..031033f7208e1dff4767e43afdec28e79e56ffbb 100644 (file)
@@ -33,7 +33,7 @@
 use rustc::cfg;
 use rustc::ty::subst::Substs;
 use rustc::ty::{self, Ty};
-use rustc::traits::{self, Reveal};
+use rustc::traits;
 use rustc::hir::map as hir_map;
 use util::nodemap::NodeSet;
 use lint::{LateContext, LintContext, LintArray};
@@ -525,7 +525,7 @@ fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
         if def.has_dtor(cx.tcx) {
             return;
         }
-        let param_env = ty::ParamEnv::empty(Reveal::UserFacing);
+        let param_env = ty::ParamEnv::empty();
         if !ty.moves_by_default(cx.tcx, param_env, item.span) {
             return;
         }
index 13090ca53302b48ccc5d6ff4af0f9c8255d6a87b..d766ea3e2bd0d233c417e87f6a21d3fc1fa04b01 100644 (file)
@@ -949,8 +949,7 @@ pub fn read_global_as_value(&self, gid: GlobalId<'tcx>, ty: Ty<'tcx>) -> EvalRes
 
     pub fn const_eval(&self, gid: GlobalId<'tcx>) -> EvalResult<'tcx, &'tcx ty::Const<'tcx>> {
         let param_env = if self.tcx.is_static(gid.instance.def_id()).is_some() {
-            use rustc::traits;
-            ty::ParamEnv::empty(traits::Reveal::All)
+            ty::ParamEnv::reveal_all()
         } else {
             self.param_env
         };
index f6b47efca31cd7decc2cdde09e17608996158eaf..561500a3f3c5f69b5f83adb4ac629c57bac73775 100644 (file)
 use rustc::middle::const_val::ConstVal;
 use rustc::mir::interpret::{Value, PrimVal, AllocId, Pointer};
 use rustc::middle::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem};
-use rustc::traits;
 use rustc::ty::subst::{Substs, Kind};
 use rustc::ty::{self, TypeFoldable, Ty, TyCtxt};
 use rustc::ty::adjustment::CustomCoerceUnsized;
@@ -383,7 +382,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 instance,
                 promoted: None,
             };
-            let param_env = ty::ParamEnv::empty(traits::Reveal::All);
+            let param_env = ty::ParamEnv::reveal_all();
 
             match tcx.const_eval(param_env.and(cid)) {
                 Ok(val) => collect_const(tcx, val, instance.substs, &mut neighbors),
@@ -654,7 +653,7 @@ fn visit_fn_use<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 {
     if let ty::TyFnDef(def_id, substs) = ty.sty {
         let instance = ty::Instance::resolve(tcx,
-                                             ty::ParamEnv::empty(traits::Reveal::All),
+                                             ty::ParamEnv::reveal_all(),
                                              def_id,
                                              substs).unwrap();
         visit_instance_use(tcx, instance, is_direct_call, output);
@@ -776,7 +775,7 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let ptr_vtable = |inner_source: Ty<'tcx>, inner_target: Ty<'tcx>| {
         let type_has_metadata = |ty: Ty<'tcx>| -> bool {
             use syntax_pos::DUMMY_SP;
-            if ty.is_sized(tcx.at(DUMMY_SP), ty::ParamEnv::empty(traits::Reveal::All)) {
+            if ty.is_sized(tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all()) {
                 return false;
             }
             let tail = tcx.struct_tail(ty);
@@ -859,7 +858,7 @@ fn create_mono_items_for_vtable_methods<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             let methods = methods.iter().cloned().filter_map(|method| method)
                 .map(|(def_id, substs)| ty::Instance::resolve(
                         tcx,
-                        ty::ParamEnv::empty(traits::Reveal::All),
+                        ty::ParamEnv::reveal_all(),
                         def_id,
                         substs).unwrap())
                 .filter(|&instance| should_monomorphize_locally(tcx, &instance))
@@ -1013,7 +1012,7 @@ fn push_extra_entry_roots(&mut self, def_id: DefId) {
 
         let start_instance = Instance::resolve(
             self.tcx,
-            ty::ParamEnv::empty(traits::Reveal::All),
+            ty::ParamEnv::reveal_all(),
             start_def_id,
             self.tcx.mk_substs(iter::once(Kind::from(main_ret_ty)))
         ).unwrap();
@@ -1062,7 +1061,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                     }
 
                     let instance = ty::Instance::resolve(tcx,
-                                                         ty::ParamEnv::empty(traits::Reveal::All),
+                                                         ty::ParamEnv::reveal_all(),
                                                          method.def_id,
                                                          callee_substs).unwrap();
 
@@ -1120,7 +1119,7 @@ fn collect_neighbours<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         output,
         param_substs: instance.substs,
     }.visit_mir(&mir);
-    let param_env = ty::ParamEnv::empty(traits::Reveal::All);
+    let param_env = ty::ParamEnv::reveal_all();
     for (i, promoted) in mir.promoted.iter().enumerate() {
         use rustc_data_structures::indexed_vec::Idx;
         let cid = GlobalId {
@@ -1155,7 +1154,7 @@ fn collect_const<'a, 'tcx>(
 
     let val = match constant.val {
         ConstVal::Unevaluated(def_id, substs) => {
-            let param_env = ty::ParamEnv::empty(traits::Reveal::All);
+            let param_env = ty::ParamEnv::reveal_all();
             let substs = tcx.trans_apply_param_substs(param_substs,
                                                         &substs);
             let instance = ty::Instance::resolve(tcx,
index 2ca6c76a8009a058e18f8bdc1c2e33f958544f8e..4c9789782a6e1dd020beaacf5cb54002cbeccdd2 100644 (file)
@@ -154,7 +154,7 @@ pub fn resolve_drop_in_place<'a, 'tcx>(
 {
     let def_id = tcx.require_lang_item(DropInPlaceFnLangItem);
     let substs = tcx.intern_substs(&[ty.into()]);
-    Instance::resolve(tcx, ty::ParamEnv::empty(traits::Reveal::All), def_id, substs).unwrap()
+    Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap()
 }
 
 pub fn custom_coerce_unsize_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
@@ -168,7 +168,7 @@ pub fn custom_coerce_unsize_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         substs: tcx.mk_substs_trait(source_ty, &[target_ty])
     });
 
-    match tcx.trans_fulfill_obligation( (ty::ParamEnv::empty(traits::Reveal::All), trait_ref)) {
+    match tcx.trans_fulfill_obligation( (ty::ParamEnv::reveal_all(), trait_ref)) {
         traits::VtableImpl(traits::VtableImplData { impl_def_id, .. }) => {
             tcx.coerce_unsized_info(impl_def_id).custom_kind.unwrap()
         }
index 88618122e4f1137d5e0fe7b8b90849fc2d0cf640..94446a98e63fe1c46969f365c77f817c9f9353f9 100644 (file)
@@ -21,7 +21,7 @@
 use rustc::hir;
 use rustc::hir::def_id::DefId;
 use rustc::middle::const_val::ConstVal;
-use rustc::traits::{self, Reveal};
+use rustc::traits;
 use rustc::ty::{self, TyCtxt, Ty, TypeFoldable};
 use rustc::ty::cast::CastTy;
 use rustc::ty::maps::Providers;
@@ -1237,7 +1237,7 @@ fn run_pass<'a, 'tcx>(&self,
             }
             let ty = mir.return_ty();
             tcx.infer_ctxt().enter(|infcx| {
-                let param_env = ty::ParamEnv::empty(Reveal::UserFacing);
+                let param_env = ty::ParamEnv::empty();
                 let cause = traits::ObligationCause::new(mir.span, id, traits::SharedStatic);
                 let mut fulfillment_cx = traits::FulfillmentContext::new();
                 fulfillment_cx.register_bound(&infcx,
index 16278c37a0cc0cba6a06e1c2b72197f1734aa125..356ad9ec11bb70c0b6e4883e8d22af3c0eb690c0 100644 (file)
@@ -34,7 +34,6 @@
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::ty::maps::Providers;
 use rustc::ty::subst::Substs;
-use rustc::traits::Reveal;
 use rustc::util::nodemap::{ItemLocalSet, NodeSet};
 use rustc::hir;
 use rustc_data_structures::sync::Lrc;
@@ -87,7 +86,7 @@ fn rvalue_promotable_map<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         in_static: false,
         promotable: false,
         mut_rvalue_borrows: NodeSet(),
-        param_env: ty::ParamEnv::empty(Reveal::UserFacing),
+        param_env: ty::ParamEnv::empty(),
         identity_substs: Substs::empty(),
         result: ItemLocalSet(),
     };
index 54cc561e8041505065d1eae557cacb52072dec58..1dcf349e23bd882028b1cd37a63f0828e48c1712 100644 (file)
@@ -25,7 +25,6 @@
 use rustc::hir::def_id::DefId;
 use rustc::ty::{self, TypeFoldable};
 use rustc::ty::layout::LayoutOf;
-use rustc::traits;
 use rustc::ty::subst::Substs;
 use rustc_back::PanicStrategy;
 
@@ -185,7 +184,7 @@ pub fn resolve_and_get_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
         cx,
         ty::Instance::resolve(
             cx.tcx,
-            ty::ParamEnv::empty(traits::Reveal::All),
+            ty::ParamEnv::reveal_all(),
             def_id,
             substs
         ).unwrap()
index 7c4e2340d5bdc4dcaecf9f8ede17c813096c80dc..c71c0cc0ebf2c9ee3a98b25a649b6d0bfd5004c0 100644 (file)
@@ -25,7 +25,6 @@
 use type_::Type;
 use type_of::LayoutLlvmExt;
 use value::Value;
-use rustc::traits;
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::ty::layout::{HasDataLayout, LayoutOf};
 use rustc::hir;
 pub use context::CodegenCx;
 
 pub fn type_needs_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
-    ty.needs_drop(tcx, ty::ParamEnv::empty(traits::Reveal::All))
+    ty.needs_drop(tcx, ty::ParamEnv::reveal_all())
 }
 
 pub fn type_is_sized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
-    ty.is_sized(tcx.at(DUMMY_SP), ty::ParamEnv::empty(traits::Reveal::All))
+    ty.is_sized(tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all())
 }
 
 pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
-    ty.is_freeze(tcx, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP)
+    ty.is_freeze(tcx, ty::ParamEnv::reveal_all(), DUMMY_SP)
 }
 
 /*
index dc5e788959448ac6f2e8b4c4ec14695607eb56c8..1f2c3cc883c682fcf3e3283ce434d11fb6091115 100644 (file)
@@ -14,7 +14,6 @@
 use rustc::dep_graph::DepGraphSafe;
 use rustc::hir;
 use rustc::hir::def_id::DefId;
-use rustc::traits;
 use debuginfo;
 use callee;
 use base;
@@ -435,7 +434,7 @@ pub fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
 
     pub fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {
         use syntax_pos::DUMMY_SP;
-        if ty.is_sized(self.tcx.at(DUMMY_SP), ty::ParamEnv::empty(traits::Reveal::All)) {
+        if ty.is_sized(self.tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all()) {
             return false;
         }
 
@@ -464,7 +463,7 @@ impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a CodegenCx<'a, 'tcx> {
     type TyLayout = TyLayout<'tcx>;
 
     fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
-        self.tcx.layout_of(ty::ParamEnv::empty(traits::Reveal::All).and(ty))
+        self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty))
             .unwrap_or_else(|e| match e {
                 LayoutError::SizeOverflow(_) => self.sess().fatal(&e.to_string()),
                 _ => bug!("failed to get layout for `{}`: {}", ty, e)
index efb5338f680af1cc5d792bea56ae727ba6f9902e..606c1396c1dafa589fc74e7d79c259122657e9ba 100644 (file)
@@ -12,7 +12,6 @@
 use rustc::middle::lang_items;
 use rustc::ty::{self, TypeFoldable};
 use rustc::ty::layout::{self, LayoutOf};
-use rustc::traits;
 use rustc::mir;
 use abi::{Abi, FnType, ArgType, PassMode};
 use base;
@@ -419,7 +418,7 @@ fn trans_terminator(&mut self,
                 let (instance, mut llfn) = match callee.layout.ty.sty {
                     ty::TyFnDef(def_id, substs) => {
                         (Some(ty::Instance::resolve(bx.cx.tcx,
-                                                    ty::ParamEnv::empty(traits::Reveal::All),
+                                                    ty::ParamEnv::reveal_all(),
                                                     def_id,
                                                     substs).unwrap()),
                          None)
index 6aa8b7e5449fd1e6037d0e0ef7cfa2b41ee762df..977c7c983d6f2458dd4eb0e08b54897de84f2837 100644 (file)
@@ -12,7 +12,6 @@
 use rustc::middle::const_val::{ConstVal, ConstEvalErr};
 use rustc_mir::interpret::{read_target_uint, const_val_field};
 use rustc::hir::def_id::DefId;
-use rustc::traits;
 use rustc::mir;
 use rustc_data_structures::indexed_vec::Idx;
 use rustc::mir::interpret::{Allocation, GlobalId, MemoryPointer, PrimVal, Value as MiriValue};
@@ -126,7 +125,7 @@ pub fn trans_static_initializer<'a, 'tcx>(
         instance,
         promoted: None
     };
-    let param_env = ty::ParamEnv::empty(traits::Reveal::All);
+    let param_env = ty::ParamEnv::reveal_all();
     cx.tcx.const_eval(param_env.and(cid))?;
 
     let alloc_id = cx
@@ -152,7 +151,7 @@ fn const_to_miri_value(
         match constant.val {
             ConstVal::Unevaluated(def_id, ref substs) => {
                 let tcx = bx.tcx();
-                let param_env = ty::ParamEnv::empty(traits::Reveal::All);
+                let param_env = ty::ParamEnv::reveal_all();
                 let instance = ty::Instance::resolve(tcx, param_env, def_id, substs).unwrap();
                 let cid = GlobalId {
                     instance,
@@ -172,7 +171,7 @@ pub fn mir_constant_to_miri_value(
     ) -> Result<MiriValue, ConstEvalErr<'tcx>> {
         match constant.literal {
             mir::Literal::Promoted { index } => {
-                let param_env = ty::ParamEnv::empty(traits::Reveal::All);
+                let param_env = ty::ParamEnv::reveal_all();
                 let cid = mir::interpret::GlobalId {
                     instance: self.instance,
                     promoted: Some(index),
@@ -201,7 +200,7 @@ pub fn simd_shuffle_indices(
                 let values: Result<Vec<ValueRef>, _> = (0..fields).map(|field| {
                     let field = const_val_field(
                         bx.tcx(),
-                        ty::ParamEnv::empty(traits::Reveal::All),
+                        ty::ParamEnv::reveal_all(),
                         self.instance,
                         None,
                         mir::Field::new(field as usize),
index a3a1f2a930778936ce72d779c3bed7b44dd02bbe..b6459b624104fd038e8e7875433226ba0a7d78df 100644 (file)
@@ -501,7 +501,7 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             ty::TraitContainer(_) => tcx.mk_self_type()
         };
         let self_arg_ty = *tcx.fn_sig(method.def_id).input(0).skip_binder();
-        let param_env = ty::ParamEnv::empty(Reveal::All);
+        let param_env = ty::ParamEnv::reveal_all();
 
         tcx.infer_ctxt().enter(|infcx| {
             let self_arg_ty = tcx.liberate_late_bound_regions(
@@ -759,7 +759,7 @@ pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     debug!("compare_const_impl(impl_trait_ref={:?})", impl_trait_ref);
 
     tcx.infer_ctxt().enter(|infcx| {
-        let param_env = ty::ParamEnv::empty(Reveal::UserFacing);
+        let param_env = ty::ParamEnv::empty();
         let inh = Inherited::new(infcx, impl_c.def_id);
         let infcx = &inh.infcx;
 
index 165cfe6604e8b0ec1905fa60ace5500718a8f509..f33536227a0ba4308b255d92cab1f31c8bed1857 100644 (file)
@@ -16,7 +16,7 @@
 use rustc::middle::region;
 use rustc::ty::subst::{Subst, Substs, UnpackedKind};
 use rustc::ty::{self, Ty, TyCtxt};
-use rustc::traits::{self, Reveal, ObligationCause};
+use rustc::traits::{self, ObligationCause};
 use util::common::ErrorReported;
 use util::nodemap::FxHashSet;
 
@@ -126,7 +126,7 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>(
         // it did the wrong thing, so I chose to preserve existing
         // behavior, since it ought to be simply more
         // conservative. -nmatsakis
-        let outlives_env = OutlivesEnvironment::new(ty::ParamEnv::empty(Reveal::UserFacing));
+        let outlives_env = OutlivesEnvironment::new(ty::ParamEnv::empty());
 
         infcx.resolve_regions_and_report_errors(drop_impl_did, &region_scope_tree, &outlives_env);
         Ok(())
index 1ea1ff1fae24df1a533514a58f67b3a5d2dfabdd..48591998a1fb8972eeccfb76dae25aa578374fe9 100644 (file)
@@ -3997,7 +3997,7 @@ fn check_expr_kind(&self,
           }
           hir::ExprRepeat(ref element, count) => {
             let count_def_id = tcx.hir.body_owner_def_id(count);
-            let param_env = ty::ParamEnv::empty(traits::Reveal::UserFacing);
+            let param_env = ty::ParamEnv::empty();
             let substs = Substs::identity_for_item(tcx.global_tcx(), count_def_id);
             let instance = ty::Instance::resolve(
                 tcx.global_tcx(),
index 49a23f14338b448b530cac17e05e3605908cbe51..ea90c35cb8f2ef548608a8dca7be8ae12e14092d 100644 (file)
 use rustc::ty::subst::Substs;
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::ty::maps::Providers;
-use rustc::traits::{FulfillmentContext, ObligationCause, ObligationCauseCode, Reveal};
+use rustc::traits::{FulfillmentContext, ObligationCause, ObligationCauseCode};
 use session::{CompileIncomplete, config};
 use util::common::time;
 
@@ -158,7 +158,7 @@ fn require_same_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                 actual: Ty<'tcx>)
                                 -> bool {
     tcx.infer_ctxt().enter(|ref infcx| {
-        let param_env = ty::ParamEnv::empty(Reveal::UserFacing);
+        let param_env = ty::ParamEnv::empty();
         let mut fulfill_cx = FulfillmentContext::new();
         match infcx.at(&cause, param_env).eq(expected, actual) {
             Ok(InferOk { obligations, .. }) => {