Rename Ty::Param => Ty::Placeholder

This aligns more with Chalk.
This commit is contained in:
Florian Diebold
2020-02-14 14:44:00 +01:00
parent a19f52f9ae
commit a324d066cb
3 changed files with 11 additions and 11 deletions

View File

@@ -291,7 +291,7 @@ pub enum Ty {
/// {}` when we're type-checking the body of that function. In this /// {}` when we're type-checking the body of that function. In this
/// situation, we know this stands for *some* type, but don't know the exact /// situation, we know this stands for *some* type, but don't know the exact
/// type. /// type.
Param(TypeParamId), Placeholder(TypeParamId),
/// A bound type variable. This is used in various places: when representing /// A bound type variable. This is used in various places: when representing
/// some polymorphic type like the type of function `fn f<T>`, the type /// some polymorphic type like the type of function `fn f<T>`, the type
@@ -365,7 +365,7 @@ impl Substs {
/// Return Substs that replace each parameter by itself (i.e. `Ty::Param`). /// Return Substs that replace each parameter by itself (i.e. `Ty::Param`).
pub(crate) fn type_params_for_generics(generic_params: &Generics) -> Substs { pub(crate) fn type_params_for_generics(generic_params: &Generics) -> Substs {
Substs(generic_params.iter().map(|(id, _)| Ty::Param(id)).collect()) Substs(generic_params.iter().map(|(id, _)| Ty::Placeholder(id)).collect())
} }
/// Return Substs that replace each parameter by itself (i.e. `Ty::Param`). /// Return Substs that replace each parameter by itself (i.e. `Ty::Param`).
@@ -813,7 +813,7 @@ impl TypeWalk for Ty {
p.walk(f); p.walk(f);
} }
} }
Ty::Param { .. } | Ty::Bound(_) | Ty::Infer(_) | Ty::Unknown => {} Ty::Placeholder { .. } | Ty::Bound(_) | Ty::Infer(_) | Ty::Unknown => {}
} }
f(self); f(self);
} }
@@ -831,7 +831,7 @@ impl TypeWalk for Ty {
p.walk_mut_binders(f, binders + 1); p.walk_mut_binders(f, binders + 1);
} }
} }
Ty::Param { .. } | Ty::Bound(_) | Ty::Infer(_) | Ty::Unknown => {} Ty::Placeholder { .. } | Ty::Bound(_) | Ty::Infer(_) | Ty::Unknown => {}
} }
f(self, binders); f(self, binders);
} }
@@ -1032,7 +1032,7 @@ impl HirDisplay for Ty {
match self { match self {
Ty::Apply(a_ty) => a_ty.hir_fmt(f)?, Ty::Apply(a_ty) => a_ty.hir_fmt(f)?,
Ty::Projection(p_ty) => p_ty.hir_fmt(f)?, Ty::Projection(p_ty) => p_ty.hir_fmt(f)?,
Ty::Param(id) => { Ty::Placeholder(id) => {
let generics = generics(f.db, id.parent); let generics = generics(f.db, id.parent);
let param_data = &generics.params.types[id.local_id]; let param_data = &generics.params.types[id.local_id];
match param_data.provenance { match param_data.provenance {

View File

@@ -152,7 +152,7 @@ impl Ty {
data.provenance == TypeParamProvenance::ArgumentImplTrait data.provenance == TypeParamProvenance::ArgumentImplTrait
}) })
.nth(idx as usize) .nth(idx as usize)
.map_or(Ty::Unknown, |(id, _)| Ty::Param(id)); .map_or(Ty::Unknown, |(id, _)| Ty::Placeholder(id));
param param
} else { } else {
Ty::Unknown Ty::Unknown
@@ -270,7 +270,7 @@ impl Ty {
let generics = let generics =
generics(ctx.db, ctx.resolver.generic_def().expect("generics in scope")); generics(ctx.db, ctx.resolver.generic_def().expect("generics in scope"));
match ctx.type_param_mode { match ctx.type_param_mode {
TypeParamLoweringMode::Placeholder => Ty::Param(param_id), TypeParamLoweringMode::Placeholder => Ty::Placeholder(param_id),
TypeParamLoweringMode::Variable => { TypeParamLoweringMode::Variable => {
let idx = generics.param_idx(param_id).expect("matching generics"); let idx = generics.param_idx(param_id).expect("matching generics");
Ty::Bound(idx) Ty::Bound(idx)
@@ -339,7 +339,7 @@ impl Ty {
None => return Ty::Unknown, // this can't actually happen None => return Ty::Unknown, // this can't actually happen
}; };
let param_id = match self_ty { let param_id = match self_ty {
Ty::Param(id) if ctx.type_param_mode == TypeParamLoweringMode::Placeholder => id, Ty::Placeholder(id) if ctx.type_param_mode == TypeParamLoweringMode::Placeholder => id,
Ty::Bound(idx) if ctx.type_param_mode == TypeParamLoweringMode::Variable => { Ty::Bound(idx) if ctx.type_param_mode == TypeParamLoweringMode::Variable => {
let generics = generics(ctx.db, def); let generics = generics(ctx.db, def);
let param_id = if let Some((id, _)) = generics.iter().nth(idx as usize) { let param_id = if let Some((id, _)) = generics.iter().nth(idx as usize) {
@@ -544,7 +544,7 @@ impl GenericPredicate {
let generics = generics(ctx.db, generic_def); let generics = generics(ctx.db, generic_def);
let param_id = hir_def::TypeParamId { parent: generic_def, local_id: *param_id }; let param_id = hir_def::TypeParamId { parent: generic_def, local_id: *param_id };
match ctx.type_param_mode { match ctx.type_param_mode {
TypeParamLoweringMode::Placeholder => Ty::Param(param_id), TypeParamLoweringMode::Placeholder => Ty::Placeholder(param_id),
TypeParamLoweringMode::Variable => { TypeParamLoweringMode::Variable => {
let idx = generics.param_idx(param_id).expect("matching generics"); let idx = generics.param_idx(param_id).expect("matching generics");
Ty::Bound(idx) Ty::Bound(idx)

View File

@@ -142,7 +142,7 @@ impl ToChalk for Ty {
let substitution = proj_ty.parameters.to_chalk(db); let substitution = proj_ty.parameters.to_chalk(db);
chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern() chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern()
} }
Ty::Param(id) => { Ty::Placeholder(id) => {
let interned_id = db.intern_type_param_id(id); let interned_id = db.intern_type_param_id(id);
PlaceholderIndex { PlaceholderIndex {
ui: UniverseIndex::ROOT, ui: UniverseIndex::ROOT,
@@ -184,7 +184,7 @@ impl ToChalk for Ty {
let interned_id = crate::db::GlobalTypeParamId::from_intern_id( let interned_id = crate::db::GlobalTypeParamId::from_intern_id(
crate::salsa::InternId::from(idx.idx), crate::salsa::InternId::from(idx.idx),
); );
Ty::Param(db.lookup_intern_type_param_id(interned_id)) Ty::Placeholder(db.lookup_intern_type_param_id(interned_id))
} }
chalk_ir::TyData::Alias(proj) => { chalk_ir::TyData::Alias(proj) => {
let associated_ty = from_chalk(db, proj.associated_ty_id); let associated_ty = from_chalk(db, proj.associated_ty_id);