Dejargnonize subst

This commit is contained in:
Shoyu Vanilla 2024-02-12 15:39:32 +09:00
parent 084ce5bdb5
commit 3856df059e
128 changed files with 574 additions and 541 deletions

View file

@ -1796,7 +1796,7 @@ fn maybe_expand_private_type_alias<'tcx>(
} else {
Lifetime::elided()
};
args.insert(param.def_id.to_def_id(), SubstParam::Lifetime(cleaned));
args.insert(param.def_id.to_def_id(), InstantiationParam::Lifetime(cleaned));
}
indices.lifetimes += 1;
}
@ -1813,9 +1813,15 @@ fn maybe_expand_private_type_alias<'tcx>(
_ => None,
});
if let Some(ty) = type_ {
args.insert(param.def_id.to_def_id(), SubstParam::Type(clean_ty(ty, cx)));
args.insert(
param.def_id.to_def_id(),
InstantiationParam::Type(clean_ty(ty, cx)),
);
} else if let Some(default) = *default {
args.insert(param.def_id.to_def_id(), SubstParam::Type(clean_ty(default, cx)));
args.insert(
param.def_id.to_def_id(),
InstantiationParam::Type(clean_ty(default, cx)),
);
}
indices.types += 1;
}
@ -1832,7 +1838,7 @@ fn maybe_expand_private_type_alias<'tcx>(
_ => None,
});
if let Some(_) = const_ {
args.insert(param.def_id.to_def_id(), SubstParam::Constant);
args.insert(param.def_id.to_def_id(), InstantiationParam::Constant);
}
// FIXME(const_generics_defaults)
indices.consts += 1;

View file

@ -2542,14 +2542,14 @@ pub(crate) enum TypeBindingKind {
/// ```
///
/// `public_fn`'s docs will show it as returning `Vec<i32>`, since `PrivAlias` is private.
/// [`SubstParam`] is used to record that `T` should be mapped to `i32`.
pub(crate) enum SubstParam {
/// [`InstantiationParam`] is used to record that `T` should be mapped to `i32`.
pub(crate) enum InstantiationParam {
Type(Type),
Lifetime(Lifetime),
Constant,
}
impl SubstParam {
impl InstantiationParam {
pub(crate) fn as_ty(&self) -> Option<&Type> {
if let Self::Type(ty) = self { Some(ty) } else { None }
}

View file

@ -44,10 +44,10 @@ pub(crate) struct DocContext<'tcx> {
/// Used while populating `external_traits` to ensure we don't process the same trait twice at
/// the same time.
pub(crate) active_extern_traits: DefIdSet,
// The current set of parameter substitutions,
// The current set of parameter instantiations,
// for expanding type aliases at the HIR level:
/// Table `DefId` of type, lifetime, or const parameter -> substituted type, lifetime, or const
pub(crate) args: DefIdMap<clean::SubstParam>,
/// Table `DefId` of type, lifetime, or const parameter -> instantiated type, lifetime, or const
pub(crate) args: DefIdMap<clean::InstantiationParam>,
pub(crate) current_type_aliases: DefIdMap<usize>,
/// Table synthetic type parameter for `impl Trait` in argument position -> bounds
pub(crate) impl_trait_bounds: FxHashMap<ImplTraitParam, Vec<clean::GenericBound>>,
@ -84,10 +84,10 @@ impl<'tcx> DocContext<'tcx> {
}
/// Call the closure with the given parameters set as
/// the substitutions for a type alias' RHS.
/// the generic parameters for a type alias' RHS.
pub(crate) fn enter_alias<F, R>(
&mut self,
args: DefIdMap<clean::SubstParam>,
args: DefIdMap<clean::InstantiationParam>,
def_id: DefId,
f: F,
) -> R