Skip to content

Commit 2ead651

Browse files
committed
Move Ty::builtin to TyBuilder
1 parent 620769f commit 2ead651

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

crates/hir/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use hir_ty::{
5959
traits::{FnTrait, Solution, SolutionVariables},
6060
AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, CanonicalVarKinds, Cast,
6161
DebruijnIndex, InEnvironment, Interner, ProjectionTy, QuantifiedWhereClause, Scalar,
62-
Substitution, TraitEnvironment, Ty, TyDefId, TyKind, TyVariableKind, WhereClause,
62+
Substitution, TraitEnvironment, Ty, TyBuilder, TyDefId, TyKind, TyVariableKind, WhereClause,
6363
};
6464
use itertools::Itertools;
6565
use rustc_hash::FxHashSet;
@@ -1129,7 +1129,7 @@ pub struct BuiltinType {
11291129
impl BuiltinType {
11301130
pub fn ty(self, db: &dyn HirDatabase, module: Module) -> Type {
11311131
let resolver = module.id.resolver(db.upcast());
1132-
Type::new_with_resolver(db, &resolver, Ty::builtin(self.inner))
1132+
Type::new_with_resolver(db, &resolver, TyBuilder::builtin(self.inner))
11331133
.expect("crate not present in resolver")
11341134
}
11351135

crates/hir_ty/src/lib.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,23 @@ impl TyBuilder<()> {
877877
})
878878
.intern(&Interner)
879879
}
880+
881+
pub fn builtin(builtin: BuiltinType) -> Ty {
882+
match builtin {
883+
BuiltinType::Char => TyKind::Scalar(Scalar::Char).intern(&Interner),
884+
BuiltinType::Bool => TyKind::Scalar(Scalar::Bool).intern(&Interner),
885+
BuiltinType::Str => TyKind::Str.intern(&Interner),
886+
BuiltinType::Int(t) => {
887+
TyKind::Scalar(Scalar::Int(primitive::int_ty_from_builtin(t))).intern(&Interner)
888+
}
889+
BuiltinType::Uint(t) => {
890+
TyKind::Scalar(Scalar::Uint(primitive::uint_ty_from_builtin(t))).intern(&Interner)
891+
}
892+
BuiltinType::Float(t) => {
893+
TyKind::Scalar(Scalar::Float(primitive::float_ty_from_builtin(t))).intern(&Interner)
894+
}
895+
}
896+
}
880897
}
881898

882899
impl TyBuilder<hir_def::AdtId> {
@@ -911,23 +928,6 @@ impl TyBuilder<hir_def::AdtId> {
911928
}
912929

913930
impl Ty {
914-
pub fn builtin(builtin: BuiltinType) -> Self {
915-
match builtin {
916-
BuiltinType::Char => TyKind::Scalar(Scalar::Char).intern(&Interner),
917-
BuiltinType::Bool => TyKind::Scalar(Scalar::Bool).intern(&Interner),
918-
BuiltinType::Str => TyKind::Str.intern(&Interner),
919-
BuiltinType::Int(t) => {
920-
TyKind::Scalar(Scalar::Int(primitive::int_ty_from_builtin(t))).intern(&Interner)
921-
}
922-
BuiltinType::Uint(t) => {
923-
TyKind::Scalar(Scalar::Uint(primitive::uint_ty_from_builtin(t))).intern(&Interner)
924-
}
925-
BuiltinType::Float(t) => {
926-
TyKind::Scalar(Scalar::Float(primitive::float_ty_from_builtin(t))).intern(&Interner)
927-
}
928-
}
929-
}
930-
931931
pub fn as_reference(&self) -> Option<(&Ty, Mutability)> {
932932
match self.kind(&Interner) {
933933
TyKind::Ref(mutability, ty) => Some((ty, *mutability)),

crates/hir_ty/src/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ impl_from!(FunctionId, StructId, UnionId, EnumVariantId, ConstId, StaticId for V
12161216
/// namespace.
12171217
pub(crate) fn ty_query(db: &dyn HirDatabase, def: TyDefId) -> Binders<Ty> {
12181218
match def {
1219-
TyDefId::BuiltinType(it) => Binders::new(0, Ty::builtin(it)),
1219+
TyDefId::BuiltinType(it) => Binders::new(0, TyBuilder::builtin(it)),
12201220
TyDefId::AdtId(it) => type_for_adt(db, it),
12211221
TyDefId::TypeAliasId(it) => type_for_type_alias(db, it),
12221222
}

0 commit comments

Comments
 (0)