From 6d0f9319dfd4a115f64fd5e00be3749da5eda8bc Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 10 Feb 2018 13:18:02 -0500 Subject: [PATCH] refactor `ParamEnv::empty(Reveal)` into two distinct methods - `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 --- src/librustc/infer/mod.rs | 6 ++--- src/librustc/lint/context.rs | 3 +-- src/librustc/traits/coherence.rs | 4 +-- src/librustc/traits/error_reporting.rs | 3 +-- src/librustc/traits/mod.rs | 2 +- src/librustc/traits/select.rs | 2 +- src/librustc/traits/specialize/mod.rs | 4 +-- src/librustc/traits/structural_impls.rs | 2 -- src/librustc/ty/instance.rs | 2 +- src/librustc/ty/layout.rs | 8 +++--- src/librustc/ty/mod.rs | 4 +-- src/librustc/ty/relate.rs | 3 +-- src/librustc/ty/util.rs | 26 +++++++++++++++++--- src/librustc_driver/test.rs | 4 +-- src/librustc_lint/builtin.rs | 4 +-- src/librustc_mir/interpret/eval_context.rs | 3 +-- src/librustc_mir/monomorphize/collector.rs | 17 ++++++------- src/librustc_mir/monomorphize/mod.rs | 4 +-- src/librustc_mir/transform/qualify_consts.rs | 4 +-- src/librustc_passes/rvalue_promotion.rs | 3 +-- src/librustc_trans/callee.rs | 3 +-- src/librustc_trans/common.rs | 7 +++--- src/librustc_trans/context.rs | 5 ++-- src/librustc_trans/mir/block.rs | 3 +-- src/librustc_trans/mir/constant.rs | 9 +++---- src/librustc_typeck/check/compare_method.rs | 4 +-- src/librustc_typeck/check/dropck.rs | 4 +-- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/lib.rs | 4 +-- 29 files changed, 77 insertions(+), 72 deletions(-) diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 713cf560851..5f0c2d1e76b 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -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(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( } self.infer_ctxt().enter(|infcx| { - value.trans_normalize(&infcx, env.reveal_all()) + value.trans_normalize(&infcx, env.with_reveal_all()) }) } } diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index a1381817223..4fa6594df16 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -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, diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 183b1a5470e..06926b1648d 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -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); diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index cd2d0d7e2a0..b8455b97fa4 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -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 diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index e0e85600b90..4450c60b68d 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -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(); diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 91d86394b01..728702ef61f 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -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); diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index d11565618a6..5ea089abb8e 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -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); diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index 99adc1fc873..a2d98a456f4 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -425,5 +425,3 @@ impl<'tcx, T> TypeFoldable<'tcx> for Normalized<'tcx, T> { obligations } where T: TypeFoldable<'tcx> } - - diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index 614158bafa6..ebb058c5d29 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -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 { diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 1b919ad68d0..9ce232ba173 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -2058,7 +2058,7 @@ impl<'a, 'tcx> LayoutOf> 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> 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 diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 63494438f7d..40d7aa9556d 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1420,7 +1420,7 @@ pub fn and>(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> { - 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); diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index 7f48f8c431f..72e7d16b64d 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -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( diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index cbd9a1b8d4f..ca6817d992b 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -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>, /// 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) diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index becdbb54e5b..06610609ebd 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -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(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, diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index c6698cbd006..031033f7208 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -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; } diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 13090ca5330..d766ea3e2bd 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -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 }; diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index f6b47efca31..561500a3f3c 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -196,7 +196,6 @@ 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, diff --git a/src/librustc_mir/monomorphize/mod.rs b/src/librustc_mir/monomorphize/mod.rs index 2ca6c76a800..4c9789782a6 100644 --- a/src/librustc_mir/monomorphize/mod.rs +++ b/src/librustc_mir/monomorphize/mod.rs @@ -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() } diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 88618122e4f..94446a98e63 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -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, diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 16278c37a0c..356ad9ec11b 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -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(), }; diff --git a/src/librustc_trans/callee.rs b/src/librustc_trans/callee.rs index 54cc561e804..1dcf349e23b 100644 --- a/src/librustc_trans/callee.rs +++ b/src/librustc_trans/callee.rs @@ -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() diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs index 7c4e2340d5b..c71c0cc0ebf 100644 --- a/src/librustc_trans/common.rs +++ b/src/librustc_trans/common.rs @@ -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; @@ -40,15 +39,15 @@ 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) } /* diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index dc5e7889594..1f2c3cc883c 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -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> 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) diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index efb5338f680..606c1396c1d 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -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) diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs index 6aa8b7e5449..977c7c983d6 100644 --- a/src/librustc_trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -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> { 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, _> = (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), diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index a3a1f2a9307..b6459b62410 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -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; diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 165cfe6604e..f33536227a0 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -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, ®ion_scope_tree, &outlives_env); Ok(()) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 1ea1ff1fae2..48591998a1f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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(), diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 49a23f14338..ea90c35cb8f 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -110,7 +110,7 @@ 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, .. }) => { -- 2.44.0