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
This commit is contained in:
Niko Matsakis 2018-02-10 13:18:02 -05:00
parent 1d377d10a1
commit 6d0f9319df
29 changed files with 77 additions and 72 deletions

View file

@ -28,7 +28,7 @@ use ty::{self, Ty, TyCtxt};
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 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
{
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 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
}
self.infer_ctxt().enter(|infcx| {
value.trans_normalize(&infcx, env.reveal_all())
value.trans_normalize(&infcx, env.with_reveal_all())
})
}
}

View file

@ -34,7 +34,6 @@ use lint::levels::{LintLevelSets, LintLevelsBuilder};
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,

View 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);

View file

@ -21,7 +21,6 @@ use super::{
TraitNotObjectSafe,
ConstEvalFailure,
PredicateObligation,
Reveal,
SelectionContext,
SelectionError,
ObjectSafetyViolation,
@ -140,7 +139,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// 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

View 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();

View file

@ -777,7 +777,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// 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);

View file

@ -26,7 +26,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
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);

View file

@ -425,5 +425,3 @@ BraceStructTypeFoldableImpl! {
obligations
} where T: TypeFoldable<'tcx>
}

View file

@ -199,7 +199,7 @@ impl<'a, 'b, 'tcx> Instance<'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 {

View 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

View file

@ -1420,7 +1420,7 @@ impl<'tcx> ParamEnv<'tcx> {
}
} else {
ParamEnvAnd {
param_env: ParamEnv::empty(self.reveal),
param_env: self.without_caller_bounds(),
value,
}
}
@ -1829,7 +1829,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
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);

View 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(

View 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 @@ impl<'tcx> ty::ParamEnv<'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)

View file

@ -18,7 +18,7 @@ use rustc_lint;
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,

View file

@ -33,7 +33,7 @@ use rustc::hir::def_id::DefId;
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 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
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;
}

View file

@ -949,8 +949,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
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
};

View file

@ -196,7 +196,6 @@ use rustc::hir::def_id::DefId;
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 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
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,

View 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()
}

View file

@ -21,7 +21,7 @@ use rustc_data_structures::fx::FxHashSet;
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 @@ impl MirPass for QualifyAndPromoteConstants {
}
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,

View file

@ -34,7 +34,6 @@ use rustc::middle::mem_categorization::Categorization;
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(),
};

View file

@ -25,7 +25,6 @@ use type_of::LayoutLlvmExt;
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()

View file

@ -25,7 +25,6 @@ use declare;
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 @@ use syntax_pos::{Span, DUMMY_SP};
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)
}
/*

View file

@ -14,7 +14,6 @@ use llvm::{ContextRef, ModuleRef, ValueRef};
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 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
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)

View file

@ -12,7 +12,6 @@ use llvm::{self, ValueRef, BasicBlockRef};
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 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
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)

View file

@ -12,7 +12,6 @@ use llvm::{self, ValueRef};
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 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
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 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
) -> 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 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
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),

View 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;

View file

@ -16,7 +16,7 @@ use rustc::infer::outlives::env::OutlivesEnvironment;
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(())

View file

@ -3997,7 +3997,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
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(),

View file

@ -110,7 +110,7 @@ use rustc::infer::InferOk;
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, .. }) => {