From f7be314579db29f64ef660aef1896da33d420ad6 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 21 Mar 2021 20:05:38 +0100 Subject: Align Canonical more with Chalk's version In particular, use chalk_ir::CanonicalVarKinds. --- crates/hir/src/lib.rs | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'crates/hir/src') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index a325b6691..b7ab03edf 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -56,9 +56,9 @@ use hir_ty::{ primitive::UintTy, to_assoc_type_id, traits::{FnTrait, Solution, SolutionVariables}, - AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, Cast, DebruijnIndex, - InEnvironment, Interner, ProjectionTy, QuantifiedWhereClause, Scalar, Substitution, Ty, - TyDefId, TyKind, TyVariableKind, WhereClause, + AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, CanonicalVarKinds, Cast, + DebruijnIndex, InEnvironment, Interner, ProjectionTy, QuantifiedWhereClause, Scalar, + Substitution, Ty, TyDefId, TyKind, TyVariableKind, WhereClause, }; use itertools::Itertools; use rustc_hash::FxHashSet; @@ -1723,7 +1723,10 @@ impl Type { None => return false, }; - let canonical_ty = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) }; + let canonical_ty = Canonical { + value: self.ty.value.clone(), + binders: CanonicalVarKinds::empty(&Interner), + }; method_resolution::implements_trait( &canonical_ty, db, @@ -1745,7 +1748,10 @@ impl Type { None => return false, }; - let canonical_ty = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) }; + let canonical_ty = Canonical { + value: self.ty.value.clone(), + binders: CanonicalVarKinds::empty(&Interner), + }; method_resolution::implements_trait_unique( &canonical_ty, db, @@ -1769,7 +1775,7 @@ impl Type { self.ty.environment.clone(), trait_ref.cast(&Interner), ), - kinds: Arc::new([]), + binders: CanonicalVarKinds::empty(&Interner), }; db.trait_solve(self.krate, goal).is_some() @@ -1786,8 +1792,8 @@ impl Type { .push(self.ty.value.clone()) .fill(args.iter().map(|t| t.ty.value.clone())) .build(); - let goal = Canonical { - value: InEnvironment::new( + let goal = Canonical::new( + InEnvironment::new( self.ty.environment.clone(), AliasEq { alias: AliasTy::Projection(ProjectionTy { @@ -1799,8 +1805,8 @@ impl Type { } .cast(&Interner), ), - kinds: Arc::new([TyVariableKind::General]), - }; + [TyVariableKind::General].iter().copied(), + ); match db.trait_solve(self.krate, goal)? { Solution::Unique(SolutionVariables(subst)) => { @@ -1911,7 +1917,10 @@ impl Type { pub fn autoderef<'a>(&'a self, db: &'a dyn HirDatabase) -> impl Iterator + 'a { // There should be no inference vars in types passed here // FIXME check that? - let canonical = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) }; + let canonical = Canonical { + value: self.ty.value.clone(), + binders: CanonicalVarKinds::empty(&Interner), + }; let environment = self.ty.environment.clone(); let ty = InEnvironment { value: canonical, environment }; autoderef(db, Some(self.krate), ty) @@ -1962,7 +1971,10 @@ impl Type { // There should be no inference vars in types passed here // FIXME check that? // FIXME replace Unknown by bound vars here - let canonical = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) }; + let canonical = Canonical { + value: self.ty.value.clone(), + binders: CanonicalVarKinds::empty(&Interner), + }; let env = self.ty.environment.clone(); let krate = krate.id; @@ -1993,7 +2005,10 @@ impl Type { // There should be no inference vars in types passed here // FIXME check that? // FIXME replace Unknown by bound vars here - let canonical = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) }; + let canonical = Canonical { + value: self.ty.value.clone(), + binders: CanonicalVarKinds::empty(&Interner), + }; let env = self.ty.environment.clone(); let krate = krate.id; -- cgit v1.2.3