diff options
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r-- | crates/hir_ty/src/lib.rs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index 2afcb5413..5c4d5a7d7 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -276,7 +276,7 @@ pub enum TyKind { | |||
276 | /// represents the `Self` type inside the bounds. This is currently | 276 | /// represents the `Self` type inside the bounds. This is currently |
277 | /// implicit; Chalk has the `Binders` struct to make it explicit, but it | 277 | /// implicit; Chalk has the `Binders` struct to make it explicit, but it |
278 | /// didn't seem worth the overhead yet. | 278 | /// didn't seem worth the overhead yet. |
279 | Dyn(Arc<[GenericPredicate]>), | 279 | Dyn(Arc<[WhereClause]>), |
280 | 280 | ||
281 | /// A placeholder for a type which could not be computed; this is propagated | 281 | /// A placeholder for a type which could not be computed; this is propagated |
282 | /// to avoid useless error messages. Doubles as a placeholder where type | 282 | /// to avoid useless error messages. Doubles as a placeholder where type |
@@ -564,7 +564,7 @@ impl TypeWalk for TraitRef { | |||
564 | /// Like `generics::WherePredicate`, but with resolved types: A condition on the | 564 | /// Like `generics::WherePredicate`, but with resolved types: A condition on the |
565 | /// parameters of a generic item. | 565 | /// parameters of a generic item. |
566 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 566 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
567 | pub enum GenericPredicate { | 567 | pub enum WhereClause { |
568 | /// The given trait needs to be implemented for its type parameters. | 568 | /// The given trait needs to be implemented for its type parameters. |
569 | Implemented(TraitRef), | 569 | Implemented(TraitRef), |
570 | /// An associated type bindings like in `Iterator<Item = T>`. | 570 | /// An associated type bindings like in `Iterator<Item = T>`. |
@@ -574,32 +574,32 @@ pub enum GenericPredicate { | |||
574 | Error, | 574 | Error, |
575 | } | 575 | } |
576 | 576 | ||
577 | impl GenericPredicate { | 577 | impl WhereClause { |
578 | pub fn is_error(&self) -> bool { | 578 | pub fn is_error(&self) -> bool { |
579 | matches!(self, GenericPredicate::Error) | 579 | matches!(self, WhereClause::Error) |
580 | } | 580 | } |
581 | 581 | ||
582 | pub fn is_implemented(&self) -> bool { | 582 | pub fn is_implemented(&self) -> bool { |
583 | matches!(self, GenericPredicate::Implemented(_)) | 583 | matches!(self, WhereClause::Implemented(_)) |
584 | } | 584 | } |
585 | 585 | ||
586 | pub fn trait_ref(&self, db: &dyn HirDatabase) -> Option<TraitRef> { | 586 | pub fn trait_ref(&self, db: &dyn HirDatabase) -> Option<TraitRef> { |
587 | match self { | 587 | match self { |
588 | GenericPredicate::Implemented(tr) => Some(tr.clone()), | 588 | WhereClause::Implemented(tr) => Some(tr.clone()), |
589 | GenericPredicate::AliasEq(AliasEq { alias: AliasTy::Projection(proj), .. }) => { | 589 | WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(proj), .. }) => { |
590 | Some(proj.trait_ref(db)) | 590 | Some(proj.trait_ref(db)) |
591 | } | 591 | } |
592 | GenericPredicate::AliasEq(_) | GenericPredicate::Error => None, | 592 | WhereClause::AliasEq(_) | WhereClause::Error => None, |
593 | } | 593 | } |
594 | } | 594 | } |
595 | } | 595 | } |
596 | 596 | ||
597 | impl TypeWalk for GenericPredicate { | 597 | impl TypeWalk for WhereClause { |
598 | fn walk(&self, f: &mut impl FnMut(&Ty)) { | 598 | fn walk(&self, f: &mut impl FnMut(&Ty)) { |
599 | match self { | 599 | match self { |
600 | GenericPredicate::Implemented(trait_ref) => trait_ref.walk(f), | 600 | WhereClause::Implemented(trait_ref) => trait_ref.walk(f), |
601 | GenericPredicate::AliasEq(alias_eq) => alias_eq.walk(f), | 601 | WhereClause::AliasEq(alias_eq) => alias_eq.walk(f), |
602 | GenericPredicate::Error => {} | 602 | WhereClause::Error => {} |
603 | } | 603 | } |
604 | } | 604 | } |
605 | 605 | ||
@@ -609,9 +609,9 @@ impl TypeWalk for GenericPredicate { | |||
609 | binders: DebruijnIndex, | 609 | binders: DebruijnIndex, |
610 | ) { | 610 | ) { |
611 | match self { | 611 | match self { |
612 | GenericPredicate::Implemented(trait_ref) => trait_ref.walk_mut_binders(f, binders), | 612 | WhereClause::Implemented(trait_ref) => trait_ref.walk_mut_binders(f, binders), |
613 | GenericPredicate::AliasEq(alias_eq) => alias_eq.walk_mut_binders(f, binders), | 613 | WhereClause::AliasEq(alias_eq) => alias_eq.walk_mut_binders(f, binders), |
614 | GenericPredicate::Error => {} | 614 | WhereClause::Error => {} |
615 | } | 615 | } |
616 | } | 616 | } |
617 | } | 617 | } |
@@ -815,7 +815,7 @@ impl Ty { | |||
815 | pub fn dyn_trait_ref(&self) -> Option<&TraitRef> { | 815 | pub fn dyn_trait_ref(&self) -> Option<&TraitRef> { |
816 | match self.interned(&Interner) { | 816 | match self.interned(&Interner) { |
817 | TyKind::Dyn(bounds) => bounds.get(0).and_then(|b| match b { | 817 | TyKind::Dyn(bounds) => bounds.get(0).and_then(|b| match b { |
818 | GenericPredicate::Implemented(trait_ref) => Some(trait_ref), | 818 | WhereClause::Implemented(trait_ref) => Some(trait_ref), |
819 | _ => None, | 819 | _ => None, |
820 | }), | 820 | }), |
821 | _ => None, | 821 | _ => None, |
@@ -894,7 +894,7 @@ impl Ty { | |||
894 | } | 894 | } |
895 | } | 895 | } |
896 | 896 | ||
897 | pub fn impl_trait_bounds(&self, db: &dyn HirDatabase) -> Option<Vec<GenericPredicate>> { | 897 | pub fn impl_trait_bounds(&self, db: &dyn HirDatabase) -> Option<Vec<WhereClause>> { |
898 | match self.interned(&Interner) { | 898 | match self.interned(&Interner) { |
899 | TyKind::OpaqueType(opaque_ty_id, ..) => { | 899 | TyKind::OpaqueType(opaque_ty_id, ..) => { |
900 | match db.lookup_intern_impl_trait_id((*opaque_ty_id).into()) { | 900 | match db.lookup_intern_impl_trait_id((*opaque_ty_id).into()) { |
@@ -907,7 +907,7 @@ impl Ty { | |||
907 | // This is only used by type walking. | 907 | // This is only used by type walking. |
908 | // Parameters will be walked outside, and projection predicate is not used. | 908 | // Parameters will be walked outside, and projection predicate is not used. |
909 | // So just provide the Future trait. | 909 | // So just provide the Future trait. |
910 | let impl_bound = GenericPredicate::Implemented(TraitRef { | 910 | let impl_bound = WhereClause::Implemented(TraitRef { |
911 | trait_id: to_chalk_trait_id(future_trait), | 911 | trait_id: to_chalk_trait_id(future_trait), |
912 | substitution: Substitution::empty(), | 912 | substitution: Substitution::empty(), |
913 | }); | 913 | }); |
@@ -1166,7 +1166,7 @@ pub struct ReturnTypeImplTraits { | |||
1166 | 1166 | ||
1167 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] | 1167 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] |
1168 | pub(crate) struct ReturnTypeImplTrait { | 1168 | pub(crate) struct ReturnTypeImplTrait { |
1169 | pub(crate) bounds: Binders<Vec<GenericPredicate>>, | 1169 | pub(crate) bounds: Binders<Vec<WhereClause>>, |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | pub fn to_foreign_def_id(id: TypeAliasId) -> ForeignDefId { | 1172 | pub fn to_foreign_def_id(id: TypeAliasId) -> ForeignDefId { |