Auto merge of #60195 - varkor:commontypes-to-common, r=eddyb

Split `CommonTypes` into `CommonTypes` and `CommonLifetimes`

The so-called "`CommonTypes`" contains more than just types.

r? @eddyb
This commit is contained in:
bors 2019-05-01 09:32:58 +00:00
commit 47e0803d5c
31 changed files with 82 additions and 68 deletions

View File

@ -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(..) => {

View File

@ -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
}

View File

@ -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
},
}
}

View File

@ -434,7 +434,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.

View File

@ -965,7 +965,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)
};

View File

@ -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,
);
}

View File

@ -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,

View File

@ -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]

View File

@ -225,7 +225,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>,
@ -935,11 +937,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())),
@ -963,10 +960,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),
}
}
}
@ -1018,6 +1027,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<DefIndex,
@ -1216,6 +1228,7 @@ impl<'a, 'gcx, 'tcx> 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);
@ -1270,6 +1283,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| {
@ -2468,7 +2482,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]

View File

@ -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
}
}
}

View File

@ -624,7 +624,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn erase_late_bound_regions<T>(self, value: &Binder<T>) -> 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

View File

@ -1676,7 +1676,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;
@ -1689,7 +1689,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

View File

@ -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)
}

View File

@ -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

View File

@ -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() }
)),
})

View File

@ -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
}
}

View File

@ -224,7 +224,7 @@ impl<'tcx> UniversalRegions<'tcx> {
closure_base_def_id: DefId,
) -> IndexVec<RegionVid, ty::Region<'tcx>> {
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()));

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -1148,7 +1148,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]

View File

@ -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)))

View File

@ -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) {

View File

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

View File

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

View File

@ -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

View File

@ -157,7 +157,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))
}
}

View File

@ -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()

View File

@ -3093,7 +3093,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,

View File

@ -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)
}
}