mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Make Canonical::new a free-standing function
This commit is contained in:
parent
9b4ecd3723
commit
d1b645d236
2 changed files with 13 additions and 11 deletions
|
@ -1808,7 +1808,7 @@ impl Type {
|
||||||
.push(self.ty.clone())
|
.push(self.ty.clone())
|
||||||
.fill(args.iter().map(|t| t.ty.clone()))
|
.fill(args.iter().map(|t| t.ty.clone()))
|
||||||
.build();
|
.build();
|
||||||
let goal = Canonical::new(
|
let goal = hir_ty::make_canonical(
|
||||||
InEnvironment::new(
|
InEnvironment::new(
|
||||||
self.env.env.clone(),
|
self.env.env.clone(),
|
||||||
AliasEq {
|
AliasEq {
|
||||||
|
|
|
@ -107,16 +107,18 @@ pub fn make_only_type_binders<T>(num_vars: usize, value: T) -> Binders<T> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Canonical<T> {
|
// FIXME: get rid of this
|
||||||
pub fn new(value: T, kinds: impl IntoIterator<Item = TyVariableKind>) -> Self {
|
pub fn make_canonical<T>(
|
||||||
|
value: T,
|
||||||
|
kinds: impl IntoIterator<Item = TyVariableKind>,
|
||||||
|
) -> Canonical<T> {
|
||||||
let kinds = kinds.into_iter().map(|tk| {
|
let kinds = kinds.into_iter().map(|tk| {
|
||||||
chalk_ir::CanonicalVarKind::new(
|
chalk_ir::CanonicalVarKind::new(
|
||||||
chalk_ir::VariableKind::Ty(tk),
|
chalk_ir::VariableKind::Ty(tk),
|
||||||
chalk_ir::UniverseIndex::ROOT,
|
chalk_ir::UniverseIndex::ROOT,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
Self { value, binders: chalk_ir::CanonicalVarKinds::from_iter(&Interner, kinds) }
|
Canonical { value, binders: chalk_ir::CanonicalVarKinds::from_iter(&Interner, kinds) }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A function signature as seen by type inference: Several parameter types and
|
/// A function signature as seen by type inference: Several parameter types and
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue