Rename and reorder lots of lifetimes.
- Replace non-standard names like 's, 'p, 'rg, 'ck, 'parent, 'this, and 'me with vanilla 'a. These are cases where the original name isn't really any more informative than 'a. - Replace names like 'cx, 'mir, and 'body with vanilla 'a when the lifetime applies to multiple fields and so the original lifetime name isn't really accurate. - Put 'tcx last in lifetime lists, and 'a before 'b.
This commit is contained in:
parent
606b9cb406
commit
8d32578fe1
40 changed files with 169 additions and 170 deletions
|
@ -842,14 +842,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
lifetime: Region<'tcx>,
|
||||
add_lt_suggs: &mut Vec<(Span, String)>,
|
||||
) -> String {
|
||||
struct LifetimeReplaceVisitor<'tcx, 'a> {
|
||||
struct LifetimeReplaceVisitor<'a, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
needle: hir::LifetimeName,
|
||||
new_lt: &'a str,
|
||||
add_lt_suggs: &'a mut Vec<(Span, String)>,
|
||||
}
|
||||
|
||||
impl<'hir, 'tcx> hir::intravisit::Visitor<'hir> for LifetimeReplaceVisitor<'tcx, '_> {
|
||||
impl<'hir, 'tcx> hir::intravisit::Visitor<'hir> for LifetimeReplaceVisitor<'_, 'tcx> {
|
||||
fn visit_lifetime(&mut self, lt: &'hir hir::Lifetime) {
|
||||
if lt.res == self.needle {
|
||||
self.add_lt_suggs.push(lt.suggestion(self.new_lt));
|
||||
|
|
|
@ -61,9 +61,9 @@ pub enum CoroutineInteriorOrUpvar {
|
|||
// This type provides a uniform interface to retrieve data on coroutines, whether it originated from
|
||||
// the local crate being compiled or from a foreign crate.
|
||||
#[derive(Debug)]
|
||||
struct CoroutineData<'tcx, 'a>(&'a TypeckResults<'tcx>);
|
||||
struct CoroutineData<'a, 'tcx>(&'a TypeckResults<'tcx>);
|
||||
|
||||
impl<'tcx, 'a> CoroutineData<'tcx, 'a> {
|
||||
impl<'a, 'tcx> CoroutineData<'a, 'tcx> {
|
||||
/// Try to get information about variables captured by the coroutine that matches a type we are
|
||||
/// looking for with `ty_matches` function. We uses it to find upvar which causes a failure to
|
||||
/// meet an obligation
|
||||
|
|
|
@ -25,7 +25,7 @@ use crate::traits::{
|
|||
};
|
||||
|
||||
#[extension(pub trait QueryNormalizeExt<'tcx>)]
|
||||
impl<'cx, 'tcx> At<'cx, 'tcx> {
|
||||
impl<'a, 'tcx> At<'a, 'tcx> {
|
||||
/// Normalize `value` in the context of the inference context,
|
||||
/// yielding a resulting type, or an error if `value` cannot be
|
||||
/// normalized. If you don't care about regions, you should prefer
|
||||
|
@ -160,9 +160,9 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MaxEscapingBoundVarVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
struct QueryNormalizer<'cx, 'tcx> {
|
||||
infcx: &'cx InferCtxt<'tcx>,
|
||||
cause: &'cx ObligationCause<'tcx>,
|
||||
struct QueryNormalizer<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
cause: &'a ObligationCause<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
obligations: Vec<PredicateObligation<'tcx>>,
|
||||
cache: SsoHashMap<Ty<'tcx>, Ty<'tcx>>,
|
||||
|
@ -170,7 +170,7 @@ struct QueryNormalizer<'cx, 'tcx> {
|
|||
universes: Vec<Option<ty::UniverseIndex>>,
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx> {
|
||||
impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'a, 'tcx> {
|
||||
type Error = NoSolution;
|
||||
|
||||
fn cx(&self) -> TyCtxt<'tcx> {
|
||||
|
|
|
@ -332,8 +332,8 @@ pub fn with_replaced_escaping_bound_vars<
|
|||
}
|
||||
}
|
||||
|
||||
pub struct BoundVarReplacer<'me, 'tcx> {
|
||||
infcx: &'me InferCtxt<'tcx>,
|
||||
pub struct BoundVarReplacer<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
// These three maps track the bound variable that were replaced by placeholders. It might be
|
||||
// nice to remove these since we already have the `kind` in the placeholder; we really just need
|
||||
// the `var` (but we *could* bring that into scope if we were to track them as we pass them).
|
||||
|
@ -345,15 +345,15 @@ pub struct BoundVarReplacer<'me, 'tcx> {
|
|||
current_index: ty::DebruijnIndex,
|
||||
// The `UniverseIndex` of the binding levels above us. These are optional, since we are lazy:
|
||||
// we don't actually create a universe until we see a bound var we have to replace.
|
||||
universe_indices: &'me mut Vec<Option<ty::UniverseIndex>>,
|
||||
universe_indices: &'a mut Vec<Option<ty::UniverseIndex>>,
|
||||
}
|
||||
|
||||
impl<'me, 'tcx> BoundVarReplacer<'me, 'tcx> {
|
||||
impl<'a, 'tcx> BoundVarReplacer<'a, 'tcx> {
|
||||
/// Returns `Some` if we *were* able to replace bound vars. If there are any bound vars that
|
||||
/// use a binding level above `universe_indices.len()`, we fail.
|
||||
pub fn replace_bound_vars<T: TypeFoldable<TyCtxt<'tcx>>>(
|
||||
infcx: &'me InferCtxt<'tcx>,
|
||||
universe_indices: &'me mut Vec<Option<ty::UniverseIndex>>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
universe_indices: &'a mut Vec<Option<ty::UniverseIndex>>,
|
||||
value: T,
|
||||
) -> (
|
||||
T,
|
||||
|
@ -479,22 +479,22 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> {
|
|||
}
|
||||
|
||||
/// The inverse of [`BoundVarReplacer`]: replaces placeholders with the bound vars from which they came.
|
||||
pub struct PlaceholderReplacer<'me, 'tcx> {
|
||||
infcx: &'me InferCtxt<'tcx>,
|
||||
pub struct PlaceholderReplacer<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
mapped_regions: FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
||||
mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy>,
|
||||
mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar>,
|
||||
universe_indices: &'me [Option<ty::UniverseIndex>],
|
||||
universe_indices: &'a [Option<ty::UniverseIndex>],
|
||||
current_index: ty::DebruijnIndex,
|
||||
}
|
||||
|
||||
impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> {
|
||||
impl<'a, 'tcx> PlaceholderReplacer<'a, 'tcx> {
|
||||
pub fn replace_placeholders<T: TypeFoldable<TyCtxt<'tcx>>>(
|
||||
infcx: &'me InferCtxt<'tcx>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
mapped_regions: FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
||||
mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy>,
|
||||
mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar>,
|
||||
universe_indices: &'me [Option<ty::UniverseIndex>],
|
||||
universe_indices: &'a [Option<ty::UniverseIndex>],
|
||||
value: T,
|
||||
) -> T {
|
||||
let mut replacer = PlaceholderReplacer {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue