aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-07 19:47:04 +0100
committerFlorian Diebold <[email protected]>2021-04-07 19:47:04 +0100
commitd1b645d2360fb6e74aaa774ff713af02f685a110 (patch)
tree338d5e5fb998a6cec35cf3d4c89bfbfe70c2f89f /crates
parent9b4ecd3723c0184706d1276759846ebf3fdff944 (diff)
Make Canonical::new a free-standing function
Diffstat (limited to 'crates')
-rw-r--r--crates/hir/src/lib.rs2
-rw-r--r--crates/hir_ty/src/lib.rs22
2 files changed, 13 insertions, 11 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index f5cb7a4df..7ac9118fa 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1808,7 +1808,7 @@ impl Type {
1808 .push(self.ty.clone()) 1808 .push(self.ty.clone())
1809 .fill(args.iter().map(|t| t.ty.clone())) 1809 .fill(args.iter().map(|t| t.ty.clone()))
1810 .build(); 1810 .build();
1811 let goal = Canonical::new( 1811 let goal = hir_ty::make_canonical(
1812 InEnvironment::new( 1812 InEnvironment::new(
1813 self.env.env.clone(), 1813 self.env.env.clone(),
1814 AliasEq { 1814 AliasEq {
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 7538e0874..915b1028f 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -107,16 +107,18 @@ pub fn make_only_type_binders<T>(num_vars: usize, value: T) -> Binders<T> {
107 ) 107 )
108} 108}
109 109
110impl<T> Canonical<T> { 110// FIXME: get rid of this
111 pub fn new(value: T, kinds: impl IntoIterator<Item = TyVariableKind>) -> Self { 111pub fn make_canonical<T>(
112 let kinds = kinds.into_iter().map(|tk| { 112 value: T,
113 chalk_ir::CanonicalVarKind::new( 113 kinds: impl IntoIterator<Item = TyVariableKind>,
114 chalk_ir::VariableKind::Ty(tk), 114) -> Canonical<T> {
115 chalk_ir::UniverseIndex::ROOT, 115 let kinds = kinds.into_iter().map(|tk| {
116 ) 116 chalk_ir::CanonicalVarKind::new(
117 }); 117 chalk_ir::VariableKind::Ty(tk),
118 Self { value, binders: chalk_ir::CanonicalVarKinds::from_iter(&Interner, kinds) } 118 chalk_ir::UniverseIndex::ROOT,
119 } 119 )
120 });
121 Canonical { value, binders: chalk_ir::CanonicalVarKinds::from_iter(&Interner, kinds) }
120} 122}
121 123
122/// A function signature as seen by type inference: Several parameter types and 124/// A function signature as seen by type inference: Several parameter types and