Skip to content

Commit e6f007d

Browse files
committed
Move Ty::fn_ptr to TyBuilder
1 parent b0fe3d9 commit e6f007d

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

crates/hir_ty/src/infer/coerce.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use chalk_ir::{cast::Cast, Mutability, TyVariableKind};
88
use hir_def::lang_item::LangItemTarget;
99

1010
use crate::{
11-
autoderef, to_chalk_trait_id, traits::Solution, Interner, Substitution, TraitRef, Ty, TyKind,
11+
autoderef, to_chalk_trait_id, traits::Solution, Interner, Substitution, TraitRef, Ty,
12+
TyBuilder, TyKind,
1213
};
1314

1415
use super::{InEnvironment, InferenceContext};
@@ -44,8 +45,8 @@ impl<'a> InferenceContext<'a> {
4445
// https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916
4546
let sig1 = ty1.callable_sig(self.db).expect("FnDef without callable sig");
4647
let sig2 = ty2.callable_sig(self.db).expect("FnDef without callable sig");
47-
let ptr_ty1 = Ty::fn_ptr(sig1);
48-
let ptr_ty2 = Ty::fn_ptr(sig2);
48+
let ptr_ty1 = TyBuilder::fn_ptr(sig1);
49+
let ptr_ty2 = TyBuilder::fn_ptr(sig2);
4950
self.coerce_merge_branch(&ptr_ty1, &ptr_ty2)
5051
} else {
5152
cov_mark::hit!(coerce_merge_fail_fallback);
@@ -95,7 +96,7 @@ impl<'a> InferenceContext<'a> {
9596
(TyKind::FnDef(..), TyKind::Function { .. }) => match from_ty.callable_sig(self.db) {
9697
None => return false,
9798
Some(sig) => {
98-
from_ty = Ty::fn_ptr(sig);
99+
from_ty = TyBuilder::fn_ptr(sig);
99100
}
100101
},
101102

crates/hir_ty/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -818,21 +818,21 @@ impl TyBuilder {
818818
pub fn unit() -> Ty {
819819
TyKind::Tuple(0, Substitution::empty(&Interner)).intern(&Interner)
820820
}
821-
}
822-
823-
impl Ty {
824-
pub fn adt_ty(adt: hir_def::AdtId, substs: Substitution) -> Ty {
825-
TyKind::Adt(AdtId(adt), substs).intern(&Interner)
826-
}
827821

828-
pub fn fn_ptr(sig: CallableSig) -> Self {
822+
pub fn fn_ptr(sig: CallableSig) -> Ty {
829823
TyKind::Function(FnPointer {
830824
num_args: sig.params().len(),
831825
sig: FnSig { abi: (), safety: Safety::Safe, variadic: sig.is_varargs },
832826
substs: Substitution::from_iter(&Interner, sig.params_and_return.iter().cloned()),
833827
})
834828
.intern(&Interner)
835829
}
830+
}
831+
832+
impl Ty {
833+
pub fn adt_ty(adt: hir_def::AdtId, substs: Substitution) -> Ty {
834+
TyKind::Adt(AdtId(adt), substs).intern(&Interner)
835+
}
836836

837837
pub fn builtin(builtin: BuiltinType) -> Self {
838838
match builtin {

0 commit comments

Comments
 (0)