diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-05 18:25:19 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-05 18:25:19 +0100 |
commit | c91b5376835ab54cd4bca02953625ef1f1fabeba (patch) | |
tree | 390be0ec3c0a57db5188b06c86f0a7df0242b01c /crates/hir/src/lib.rs | |
parent | 467a5c6cd13af6ccb76e9ebdb35f96fc10fb438f (diff) | |
parent | a316d583600e11ee1fcc8027a838efafe435f03c (diff) |
Merge #8348
8348: Make `Binders` more like Chalk r=flodiebold a=flodiebold
Working towards #8313.
- hide `value`
- use `VariableKinds`
- adjust `subst` to be like Chalk's `substitute`
- also clean up some other `TypeWalk` stuff to prepare for it being replaced by Chalk's `Fold`
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r-- | crates/hir/src/lib.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index b14c9a675..003821981 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -516,7 +516,7 @@ impl Field { | |||
516 | VariantDef::Variant(it) => it.parent.id.into(), | 516 | VariantDef::Variant(it) => it.parent.id.into(), |
517 | }; | 517 | }; |
518 | let substs = TyBuilder::type_params_subst(db, generic_def_id); | 518 | let substs = TyBuilder::type_params_subst(db, generic_def_id); |
519 | let ty = db.field_types(var_id)[self.id].clone().subst(&substs); | 519 | let ty = db.field_types(var_id)[self.id].clone().substitute(&Interner, &substs); |
520 | Type::new(db, self.parent.module(db).id.krate(), var_id, ty) | 520 | Type::new(db, self.parent.module(db).id.krate(), var_id, ty) |
521 | } | 521 | } |
522 | 522 | ||
@@ -702,7 +702,7 @@ impl_from!(Struct, Union, Enum for Adt); | |||
702 | impl Adt { | 702 | impl Adt { |
703 | pub fn has_non_default_type_params(self, db: &dyn HirDatabase) -> bool { | 703 | pub fn has_non_default_type_params(self, db: &dyn HirDatabase) -> bool { |
704 | let subst = db.generic_defaults(self.into()); | 704 | let subst = db.generic_defaults(self.into()); |
705 | subst.iter().any(|ty| ty.value.is_unknown()) | 705 | subst.iter().any(|ty| ty.skip_binders().is_unknown()) |
706 | } | 706 | } |
707 | 707 | ||
708 | /// Turns this ADT into a type. Any type parameters of the ADT will be | 708 | /// Turns this ADT into a type. Any type parameters of the ADT will be |
@@ -1089,7 +1089,7 @@ pub struct TypeAlias { | |||
1089 | impl TypeAlias { | 1089 | impl TypeAlias { |
1090 | pub fn has_non_default_type_params(self, db: &dyn HirDatabase) -> bool { | 1090 | pub fn has_non_default_type_params(self, db: &dyn HirDatabase) -> bool { |
1091 | let subst = db.generic_defaults(self.id.into()); | 1091 | let subst = db.generic_defaults(self.id.into()); |
1092 | subst.iter().any(|ty| ty.value.is_unknown()) | 1092 | subst.iter().any(|ty| ty.skip_binders().is_unknown()) |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | pub fn module(self, db: &dyn HirDatabase) -> Module { | 1095 | pub fn module(self, db: &dyn HirDatabase) -> Module { |
@@ -1503,7 +1503,7 @@ impl TypeParam { | |||
1503 | let krate = self.id.parent.module(db.upcast()).krate(); | 1503 | let krate = self.id.parent.module(db.upcast()).krate(); |
1504 | let ty = params.get(local_idx)?.clone(); | 1504 | let ty = params.get(local_idx)?.clone(); |
1505 | let subst = TyBuilder::type_params_subst(db, self.id.parent); | 1505 | let subst = TyBuilder::type_params_subst(db, self.id.parent); |
1506 | let ty = ty.subst(&subst.prefix(local_idx)); | 1506 | let ty = ty.substitute(&Interner, &subst.prefix(local_idx)); |
1507 | Some(Type::new_with_resolver_inner(db, krate, &resolver, ty)) | 1507 | Some(Type::new_with_resolver_inner(db, krate, &resolver, ty)) |
1508 | } | 1508 | } |
1509 | } | 1509 | } |
@@ -1916,7 +1916,7 @@ impl Type { | |||
1916 | .iter() | 1916 | .iter() |
1917 | .map(|(local_id, ty)| { | 1917 | .map(|(local_id, ty)| { |
1918 | let def = Field { parent: variant_id.into(), id: local_id }; | 1918 | let def = Field { parent: variant_id.into(), id: local_id }; |
1919 | let ty = ty.clone().subst(substs); | 1919 | let ty = ty.clone().substitute(&Interner, substs); |
1920 | (def, self.derived(ty)) | 1920 | (def, self.derived(ty)) |
1921 | }) | 1921 | }) |
1922 | .collect() | 1922 | .collect() |