diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index 201717b34ee41..27ed36ab98b0f 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -101,7 +101,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { ty::ReEmpty | ty::ReErased => { // replace all free regions with 'erased - self.tcx().types.re_erased + self.tcx().lifetimes.re_erased } ty::ReClosureBound(..) => { diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs index 03ade88253682..bde2ed5e7ccb4 100644 --- a/src/librustc/infer/lexical_region_resolve/mod.rs +++ b/src/librustc/infer/lexical_region_resolve/mod.rs @@ -138,8 +138,8 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { /// empty region. The `expansion` phase will grow this larger. fn construct_var_data(&self, tcx: TyCtxt<'_, '_, 'tcx>) -> LexicalRegionResolutions<'tcx> { LexicalRegionResolutions { - error_region: tcx.types.re_static, - values: IndexVec::from_elem_n(VarValue::Value(tcx.types.re_empty), self.num_vars()) + error_region: tcx.lifetimes.re_static, + values: IndexVec::from_elem_n(VarValue::Value(tcx.lifetimes.re_empty), self.num_vars()) } } @@ -266,7 +266,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { let b_universe = self.var_infos[b_vid].universe; if let ty::RePlaceholder(p) = lub { if b_universe.cannot_name(p.universe) { - lub = self.tcx().types.re_static; + lub = self.tcx().lifetimes.re_static; } } @@ -348,7 +348,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { // otherwise, we don't know what the free region is, // so we must conservatively say the LUB is static: - tcx.types.re_static + tcx.lifetimes.re_static } (&ReScope(a_id), &ReScope(b_id)) => { @@ -371,7 +371,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { (&RePlaceholder(..), _) | (_, &RePlaceholder(..)) => if a == b { a } else { - tcx.types.re_static + tcx.lifetimes.re_static }, } } @@ -598,7 +598,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { for lower_bound in &lower_bounds { let effective_lower_bound = if let ty::RePlaceholder(p) = lower_bound.region { if node_universe.cannot_name(p.universe) { - self.tcx().types.re_static + self.tcx().lifetimes.re_static } else { lower_bound.region } diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index be9460ad86fc4..b1d009146473f 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -370,7 +370,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } - let least_region = least_region.unwrap_or(self.tcx.types.re_static); + let least_region = least_region.unwrap_or(self.tcx.lifetimes.re_static); debug!("constrain_opaque_types: least_region={:?}", least_region); // Require that the type `concrete_ty` outlives @@ -608,7 +608,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ReverseMapper<'cx, 'gcx, 'tcx> err.emit(); } } - self.tcx.types.re_empty + self.tcx.lifetimes.re_empty }, } } diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 217af7eea9685..582c4de2e7c21 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -435,7 +435,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { hir::ExprKind::Match(ref discr, ref arms, _) => { let discr_cmt = Rc::new(return_if_err!(self.mc.cat_expr(&discr))); - let r = self.tcx().types.re_empty; + let r = self.tcx().lifetimes.re_empty; self.borrow_expr(&discr, r, ty::ImmBorrow, MatchDiscriminant); // treatment of the discriminant is handled while walking the arms. diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index a4a54ba18371a..74a6d35da3bd4 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -966,7 +966,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { // we can promote to a constant, otherwise equal to enclosing temp // lifetime. let re = if promotable { - self.tcx.types.re_static + self.tcx.lifetimes.re_static } else { self.temporary_scope(hir_id.local_id) }; diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index e93351197fe47..af16e055460a1 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -787,7 +787,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { (None, Some(t_a)) => { select.infcx().register_region_obligation_with_cause( t_a, - select.infcx().tcx.types.re_static, + select.infcx().tcx.lifetimes.re_static, &dummy_cause, ); } diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index 8c684c0775ee3..e725ebb797e37 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -359,7 +359,7 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx, // `for<'a> T: 'a where 'a not in T`, which we can treat as // `T: 'static`. Some(t_a) => { - let r_static = self.selcx.tcx().types.re_static; + let r_static = self.selcx.tcx().lifetimes.re_static; if self.register_region_obligations { self.selcx.infcx().register_region_obligation_with_cause( t_a, diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index b875bfdfa9fa4..7f37350c6653e 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -1010,7 +1010,7 @@ fn vtable_methods<'a, 'tcx>( let substs = trait_ref.map_bound(|trait_ref| InternalSubsts::for_item(tcx, def_id, |param, _| match param.kind { - GenericParamDefKind::Lifetime => tcx.types.re_erased.into(), + GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(), GenericParamDefKind::Type { .. } | GenericParamDefKind::Const => { trait_ref.substs[param.index as usize] diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index ed500d1ac3351..6756c50e7dd5b 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -223,7 +223,9 @@ pub struct CommonTypes<'tcx> { /// a trait object, and which gets removed in `ExistentialTraitRef`. /// This type must not appear anywhere in other converted types. pub trait_object_dummy_self: Ty<'tcx>, +} +pub struct CommonLifetimes<'tcx> { pub re_empty: Region<'tcx>, pub re_static: Region<'tcx>, pub re_erased: Region<'tcx>, @@ -933,11 +935,6 @@ EnumLiftImpl! { impl<'tcx> CommonTypes<'tcx> { fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> { let mk = |sty| CtxtInterners::intern_ty(interners, interners, sty); - let mk_region = |r| { - interners.region.borrow_mut().intern(r, |r| { - Interned(interners.arena.alloc(r)) - }).0 - }; CommonTypes { unit: mk(Tuple(List::empty())), @@ -961,10 +958,22 @@ impl<'tcx> CommonTypes<'tcx> { f64: mk(Float(ast::FloatTy::F64)), trait_object_dummy_self: mk(Infer(ty::FreshTy(0))), + } + } +} - re_empty: mk_region(RegionKind::ReEmpty), - re_static: mk_region(RegionKind::ReStatic), - re_erased: mk_region(RegionKind::ReErased), +impl<'tcx> CommonLifetimes<'tcx> { + fn new(interners: &CtxtInterners<'tcx>) -> CommonLifetimes<'tcx> { + let mk = |r| { + interners.region.borrow_mut().intern(r, |r| { + Interned(interners.arena.alloc(r)) + }).0 + }; + + CommonLifetimes { + re_empty: mk(RegionKind::ReEmpty), + re_static: mk(RegionKind::ReStatic), + re_erased: mk(RegionKind::ReErased), } } } @@ -1016,6 +1025,9 @@ pub struct GlobalCtxt<'tcx> { /// Common types, pre-interned for your convenience. pub types: CommonTypes<'tcx>, + /// Common lifetimes, pre-interned for your convenience. + pub lifetimes: CommonLifetimes<'tcx>, + /// Map indicating what traits are in scope for places where this /// is relevant; generated by resolve. trait_map: FxHashMap TyCtxt<'a, 'gcx, 'tcx> { }); let interners = CtxtInterners::new(&arenas.interner); let common_types = CommonTypes::new(&interners); + let common_lifetimes = CommonLifetimes::new(&interners); let dep_graph = hir.dep_graph.clone(); let max_cnum = cstore.crates_untracked().iter().map(|c| c.as_usize()).max().unwrap_or(0); let mut providers = IndexVec::from_elem_n(extern_providers, max_cnum + 1); @@ -1268,6 +1281,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { global_interners: interners, dep_graph, types: common_types, + lifetimes: common_lifetimes, trait_map, export_map: resolutions.export_map.into_iter().map(|(k, v)| { let exports: Vec<_> = v.into_iter().map(|e| { @@ -2486,7 +2500,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { #[inline] pub fn mk_static_str(self) -> Ty<'tcx> { - self.mk_imm_ref(self.types.re_static, self.mk_str()) + self.mk_imm_ref(self.lifetimes.re_static, self.mk_str()) } #[inline] diff --git a/src/librustc/ty/erase_regions.rs b/src/librustc/ty/erase_regions.rs index 0431afcc76c9e..1f2d45a4e7ff7 100644 --- a/src/librustc/ty/erase_regions.rs +++ b/src/librustc/ty/erase_regions.rs @@ -67,7 +67,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionEraserVisitor<'a, 'gcx, 't // whenever a substitution occurs. match *r { ty::ReLateBound(..) => r, - _ => self.tcx.types.re_erased + _ => self.tcx.lifetimes.re_erased } } } diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index 321e55270c689..1bf22b08d06f4 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -624,7 +624,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn erase_late_bound_regions(self, value: &Binder) -> T where T : TypeFoldable<'tcx> { - self.replace_late_bound_regions(value, |_| self.types.re_erased).0 + self.replace_late_bound_regions(value, |_| self.lifetimes.re_erased).0 } /// Rewrite any late-bound regions so that they are anonymous. Region numbers are diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index fd1d3a91ede1f..d8ae9f38e715a 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1675,7 +1675,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> let ptr_ty = if this.ty.is_unsafe_ptr() { tcx.mk_mut_ptr(nil) } else { - tcx.mk_mut_ref(tcx.types.re_static, nil) + tcx.mk_mut_ref(tcx.lifetimes.re_static, nil) }; return cx.layout_of(ptr_ty).map_same(|mut ptr_layout| { ptr_layout.ty = this.ty; @@ -1688,7 +1688,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> ty::Str => tcx.types.usize, ty::Dynamic(_, _) => { tcx.mk_imm_ref( - tcx.types.re_static, + tcx.lifetimes.re_static, tcx.mk_array(tcx.types.usize, 3), ) /* FIXME: use actual fn pointers diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 67507f7b5d116..86836434cf50c 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -601,7 +601,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn empty_substs_for_def_id(self, item_def_id: DefId) -> SubstsRef<'tcx> { InternalSubsts::for_item(self, item_def_id, |param, _| { match param.kind { - GenericParamDefKind::Lifetime => self.types.re_erased.into(), + GenericParamDefKind::Lifetime => self.lifetimes.re_erased.into(), GenericParamDefKind::Type { .. } => { bug!("empty_substs_for_def_id: {:?} has type parameters", item_def_id) } diff --git a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs index 9680dd4ce2faf..1607a62920109 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs @@ -110,7 +110,7 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> { } Categorization::StaticItem | Categorization::Deref(_, mc::UnsafePtr(..)) => { - self.bccx.tcx.types.re_static + self.bccx.tcx.lifetimes.re_static } Categorization::Deref(_, mc::BorrowedPtr(_, r)) => { r diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index 35e9d918aa6f9..1caafb014e012 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -371,7 +371,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { (bx, OperandRef { val, layout: self.cx.layout_of(self.cx.tcx().mk_ref( - self.cx.tcx().types.re_erased, + self.cx.tcx().lifetimes.re_erased, ty::TypeAndMut { ty, mutbl: bk.to_mutbl_lossy() } )), }) diff --git a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs index 28835b959d76f..87544754f5de9 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs @@ -71,7 +71,7 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, '_, 'tcx> { let origin = NLLRegionVariableOrigin::Existential; self.infcx.next_nll_region_var(origin) } else { - self.infcx.tcx.types.re_erased + self.infcx.tcx.lifetimes.re_erased } } @@ -82,7 +82,7 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, '_, 'tcx> { if let Some(borrowck_context) = &mut self.borrowck_context { borrowck_context.constraints.placeholder_region(self.infcx, placeholder) } else { - self.infcx.tcx.types.re_erased + self.infcx.tcx.lifetimes.re_erased } } diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index d3cef46b4022d..e72cd2b7e1a66 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -224,7 +224,7 @@ impl<'tcx> UniversalRegions<'tcx> { closure_base_def_id: DefId, ) -> IndexVec> { let mut region_mapping = IndexVec::with_capacity(expected_num_vars); - region_mapping.push(tcx.types.re_static); + region_mapping.push(tcx.lifetimes.re_static); tcx.for_each_free_region(&closure_substs, |fr| { region_mapping.push(fr); }); @@ -542,7 +542,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { DefiningTy::FnDef(_, substs) | DefiningTy::Const(_, substs) => substs, }; - let global_mapping = iter::once((gcx.types.re_static, fr_static)); + let global_mapping = iter::once((gcx.lifetimes.re_static, fr_static)); let subst_mapping = identity_substs .regions() .zip(fr_substs.regions().map(|r| r.to_region_vid())); diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index da2de43c09efe..629aef56f5f19 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -74,7 +74,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { BorrowKind::Shared => unpack!(block = this.as_read_only_place(block, arg)), _ => unpack!(block = this.as_place(block, arg)), }; - block.and(Rvalue::Ref(this.hir.tcx().types.re_erased, borrow_kind, arg_place)) + block.and(Rvalue::Ref(this.hir.tcx().lifetimes.re_erased, borrow_kind, arg_place)) } ExprKind::Binary { op, lhs, rhs } => { let lhs = unpack!(block = this.as_operand(block, scope, lhs)); @@ -572,7 +572,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { block, source_info, &Place::Base(PlaceBase::Local(temp)), - Rvalue::Ref(this.hir.tcx().types.re_erased, borrow_kind, arg_place), + Rvalue::Ref(this.hir.tcx().lifetimes.re_erased, borrow_kind, arg_place), ); // In constants, temp_lifetime is None. We should not need to drop diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 5e15d98e246b7..51d5c96083d8f 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -1295,7 +1295,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { all_fake_borrows.into_iter().map(|matched_place| { let fake_borrow_deref_ty = matched_place.ty(&self.local_decls, tcx).ty; - let fake_borrow_ty = tcx.mk_imm_ref(tcx.types.re_erased, fake_borrow_deref_ty); + let fake_borrow_ty = tcx.mk_imm_ref(tcx.lifetimes.re_erased, fake_borrow_deref_ty); let fake_borrow_temp = self.local_decls.push( LocalDecl::new_temp(fake_borrow_ty, temp_span) ); @@ -1443,7 +1443,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { debug!("Entering guard building context: {:?}", guard_frame); self.guard_context.push(guard_frame); - let re_erased = tcx.types.re_erased; + let re_erased = tcx.lifetimes.re_erased; let scrutinee_source_info = self.source_info(scrutinee_span); for &(place, temp) in fake_borrows { let borrow = Rvalue::Ref( @@ -1607,7 +1607,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // Assign each of the bindings. Since we are binding for a // guard expression, this will never trigger moves out of the // candidate. - let re_erased = self.hir.tcx().types.re_erased; + let re_erased = self.hir.tcx().lifetimes.re_erased; for binding in bindings { let source_info = self.source_info(binding.span); @@ -1659,7 +1659,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ) where 'tcx: 'b { debug!("bind_matched_candidate_for_arm_body(block={:?})", block); - let re_erased = self.hir.tcx().types.re_erased; + let re_erased = self.hir.tcx().lifetimes.re_erased; // Assign each of the bindings. This may trigger moves out of the candidate. for binding in bindings { let source_info = self.source_info(binding.span); @@ -1735,7 +1735,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // This variable isn't mutated but has a name, so has to be // immutable to avoid the unused mut lint. mutability: Mutability::Not, - ty: tcx.mk_imm_ref(tcx.types.re_erased, var_ty), + ty: tcx.mk_imm_ref(tcx.lifetimes.re_erased, var_ty), user_ty: UserTypeProjections::none(), name: Some(name), source_info, diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 1eaf3d7ba9982..a5834b02ffc82 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -307,7 +307,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let (mty, method) = self.hir.trait_method(eq_def_id, "eq", ty, &[ty.into()]); let method = self.hir.tcx().mk_const(method); - let re_erased = self.hir.tcx().types.re_erased; + let re_erased = self.hir.tcx().lifetimes.re_erased; // take the argument by reference let tam = ty::TypeAndMut { ty, diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 7ab3341127546..e3755e6999530 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -141,7 +141,7 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, // then an unsafe coercion. expr = Expr { temp_lifetime, - ty: cx.tcx.mk_ref(cx.tcx.types.re_erased, + ty: cx.tcx.mk_ref(cx.tcx.lifetimes.re_erased, ty::TypeAndMut { ty: expr.ty, mutbl: m, diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 47fe136e0e451..c656dabb24ace 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -1149,7 +1149,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let substs = InternalSubsts::for_item(tcx, method.def_id, |param, _| { match param.kind { - GenericParamDefKind::Lifetime => tcx.types.re_erased.into(), + GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(), GenericParamDefKind::Type { .. } | GenericParamDefKind::Const => { trait_ref.substs[param.index as usize] diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index cb25db73cd2be..1bfcaea203492 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -465,7 +465,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { let ref_loc = self.make_place( Mutability::Not, - tcx.mk_ref(tcx.types.re_erased, ty::TypeAndMut { + tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::MutImmutable, }) @@ -475,7 +475,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { let statement = self.make_statement( StatementKind::Assign( ref_loc.clone(), - box Rvalue::Ref(tcx.types.re_erased, BorrowKind::Shared, src) + box Rvalue::Ref(tcx.lifetimes.re_erased, BorrowKind::Shared, src) ) ); @@ -734,7 +734,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // let rcvr = &mut rcvr; let ref_rcvr = local_decls.push(temp_decl( Mutability::Not, - tcx.mk_ref(tcx.types.re_erased, ty::TypeAndMut { + tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty: sig.inputs()[0], mutbl: hir::Mutability::MutMutable }), @@ -747,7 +747,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, source_info, kind: StatementKind::Assign( Place::Base(PlaceBase::Local(ref_rcvr)), - box Rvalue::Ref(tcx.types.re_erased, borrow_kind, rcvr_l) + box Rvalue::Ref(tcx.lifetimes.re_erased, borrow_kind, rcvr_l) ) }); Operand::Move(Place::Base(PlaceBase::Local(ref_rcvr))) diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index a853f8d92beae..e7e2887d92c8d 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -29,7 +29,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for EraseRegionsVisitor<'a, 'tcx> { } fn visit_region(&mut self, region: &mut ty::Region<'tcx>, _: Location) { - *region = self.tcx.types.re_erased; + *region = self.tcx.lifetimes.re_erased; } fn visit_const(&mut self, constant: &mut &'tcx ty::Const<'tcx>, _: Location) { diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index e96a40ad2f036..dbeae4df7db8d 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -458,7 +458,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { let dest = if dest_needs_borrow(&destination.0) { debug!("Creating temp for return destination"); let dest = Rvalue::Ref( - self.tcx.types.re_erased, + self.tcx.lifetimes.re_erased, BorrowKind::Mut { allow_two_phase_borrow: false }, destination.0); diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 2d275c9a13792..4ad0c324a43a9 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -515,7 +515,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> let ty = self.place_ty(self.place); let substs = tcx.mk_substs_trait(ty, &[]); - let ref_ty = tcx.mk_ref(tcx.types.re_erased, ty::TypeAndMut { + let ref_ty = tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::MutMutable }); @@ -525,7 +525,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> let result = BasicBlockData { statements: vec![self.assign( &Place::Base(PlaceBase::Local(ref_place)), - Rvalue::Ref(tcx.types.re_erased, + Rvalue::Ref(tcx.lifetimes.re_erased, BorrowKind::Mut { allow_two_phase_borrow: false }, self.place.clone()) )], @@ -574,7 +574,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> let move_ = |place: &Place<'tcx>| Operand::Move(place.clone()); let tcx = self.tcx(); - let ref_ty = tcx.mk_ref(tcx.types.re_erased, ty::TypeAndMut { + let ref_ty = tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty: ety, mutbl: hir::Mutability::MutMutable }); @@ -584,7 +584,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> let one = self.constant_usize(1); let (ptr_next, cur_next) = if ptr_based { (Rvalue::Ref( - tcx.types.re_erased, + tcx.lifetimes.re_erased, BorrowKind::Mut { allow_two_phase_borrow: false }, Place::Projection(Box::new(Projection { base: Place::Base(PlaceBase::Local(cur)), @@ -594,7 +594,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> Rvalue::BinaryOp(BinOp::Offset, copy(&Place::Base(PlaceBase::Local(cur))), one)) } else { (Rvalue::Ref( - tcx.types.re_erased, + tcx.lifetimes.re_erased, BorrowKind::Mut { allow_two_phase_borrow: false }, self.place.clone().index(cur)), Rvalue::BinaryOp(BinOp::Add, copy(&Place::Base(PlaceBase::Local(cur))), one)) @@ -742,7 +742,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> // cur = tmp as *mut T; // end = Offset(cur, len); drop_block_stmts.push(self.assign(&tmp, Rvalue::Ref( - tcx.types.re_erased, + tcx.lifetimes.re_erased, BorrowKind::Mut { allow_two_phase_borrow: false }, self.place.clone() ))); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index f5111954f8dfa..98d72ee03d06e 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -112,7 +112,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { let r = match tcx.named_region(lifetime.hir_id) { Some(rl::Region::Static) => { - tcx.types.re_static + tcx.lifetimes.re_static } Some(rl::Region::LateBound(debruijn, id, _)) => { @@ -155,7 +155,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { // Supply some dummy value. We don't have an // `re_error`, annoyingly, so use `'static`. - tcx.types.re_static + tcx.lifetimes.re_static }) } }; @@ -633,7 +633,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { // Provide substitutions for parameters for which arguments are inferred. |substs, param, infer_types| { match param.kind { - GenericParamDefKind::Lifetime => tcx.types.re_static.into(), + GenericParamDefKind::Lifetime => tcx.lifetimes.re_static.into(), GenericParamDefKind::Type { has_default, .. } => { if !infer_types && has_default { // No type parameter provided, but a default exists. @@ -1174,7 +1174,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { span_err!(tcx.sess, span, E0228, "the lifetime bound for this object type cannot be deduced \ from context; please supply an explicit bound"); - tcx.types.re_static + tcx.lifetimes.re_static }) } }) @@ -1954,7 +1954,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { // Replace all parent lifetimes with 'static. match param.kind { GenericParamDefKind::Lifetime => { - tcx.types.re_static.into() + tcx.lifetimes.re_static.into() } _ => tcx.mk_param_from_def(param) } @@ -2074,7 +2074,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { // If any of the derived region bounds are 'static, that is always // the best choice. if derived_region_bounds.iter().any(|&r| ty::ReStatic == *r) { - return Some(tcx.types.re_static); + return Some(tcx.lifetimes.re_static); } // Determine whether there is exactly one unique region in the set diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 032821e6d42f2..dc27e6e905f52 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -156,7 +156,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let expected_ty = self.structurally_resolved_type(pat.span, expected); if let ty::Ref(_, r_ty, _) = expected_ty.sty { if let ty::Slice(_) = r_ty.sty { - pat_ty = tcx.mk_imm_ref(tcx.types.re_static, + pat_ty = tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.mk_slice(tcx.types.u8)) } } diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 42156213f21df..5a420c3661594 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -1079,7 +1079,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { // In general, during probing we erase regions. See // `impl_self_ty()` for an explanation. - let region = tcx.types.re_erased; + let region = tcx.lifetimes.re_erased; let autoref_ty = tcx.mk_ref(region, ty::TypeAndMut { @@ -1545,7 +1545,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { GenericParamDefKind::Lifetime => { // In general, during probe we erase regions. See // `impl_self_ty()` for an explanation. - self.tcx.types.re_erased.into() + self.tcx.lifetimes.re_erased.into() } GenericParamDefKind::Type { .. } | GenericParamDefKind::Const => { @@ -1566,7 +1566,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { fn fresh_item_substs(&self, def_id: DefId) -> SubstsRef<'tcx> { InternalSubsts::for_item(self.tcx, def_id, |param, _| { match param.kind { - GenericParamDefKind::Lifetime => self.tcx.types.re_erased.into(), + GenericParamDefKind::Lifetime => self.tcx.lifetimes.re_erased.into(), GenericParamDefKind::Type { .. } => { self.next_ty_var(TypeVariableOrigin::SubstitutionPlaceholder( self.tcx.def_span(def_id))).into() diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index bd715df6e9d1e..08f6118c6e0ec 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3088,7 +3088,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { match lit.node { ast::LitKind::Str(..) => tcx.mk_static_str(), ast::LitKind::ByteStr(ref v) => { - tcx.mk_imm_ref(tcx.types.re_static, + tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.mk_array(tcx.types.u8, v.len() as u64)) } ast::LitKind::Byte(_) => tcx.types.u8, diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 193b17af55eff..f8f3b473a1abd 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -817,7 +817,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Resolver<'cx, 'gcx, 'tcx> { // FIXME This should be carefully checked // We could use `self.report_error` but it doesn't accept a ty::Region, right now. fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { - self.infcx.fully_resolve(&r).unwrap_or(self.tcx.types.re_static) + self.infcx.fully_resolve(&r).unwrap_or(self.tcx.lifetimes.re_static) } }