aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir/src/lib.rs4
-rw-r--r--crates/hir_ty/src/lib.rs34
-rw-r--r--crates/hir_ty/src/lower.rs2
3 files changed, 20 insertions, 20 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index eb19e4b51..682d49a21 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -59,7 +59,7 @@ use hir_ty::{
59 traits::{FnTrait, Solution, SolutionVariables}, 59 traits::{FnTrait, Solution, SolutionVariables},
60 AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, CanonicalVarKinds, Cast, 60 AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, CanonicalVarKinds, Cast,
61 DebruijnIndex, InEnvironment, Interner, ProjectionTy, QuantifiedWhereClause, Scalar, 61 DebruijnIndex, InEnvironment, Interner, ProjectionTy, QuantifiedWhereClause, Scalar,
62 Substitution, TraitEnvironment, Ty, TyDefId, TyKind, TyVariableKind, WhereClause, 62 Substitution, TraitEnvironment, Ty, TyBuilder, TyDefId, TyKind, TyVariableKind, WhereClause,
63}; 63};
64use itertools::Itertools; 64use itertools::Itertools;
65use rustc_hash::FxHashSet; 65use rustc_hash::FxHashSet;
@@ -1129,7 +1129,7 @@ pub struct BuiltinType {
1129impl BuiltinType { 1129impl BuiltinType {
1130 pub fn ty(self, db: &dyn HirDatabase, module: Module) -> Type { 1130 pub fn ty(self, db: &dyn HirDatabase, module: Module) -> Type {
1131 let resolver = module.id.resolver(db.upcast()); 1131 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))
1133 .expect("crate not present in resolver") 1133 .expect("crate not present in resolver")
1134 } 1134 }
1135 1135
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index afe5424d6..be6fe5016 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -877,6 +877,23 @@ impl TyBuilder<()> {
877 }) 877 })
878 .intern(&Interner) 878 .intern(&Interner)
879 } 879 }
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 }
880} 897}
881 898
882impl TyBuilder<hir_def::AdtId> { 899impl TyBuilder<hir_def::AdtId> {
@@ -911,23 +928,6 @@ impl TyBuilder<hir_def::AdtId> {
911} 928}
912 929
913impl Ty { 930impl 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
931 pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { 931 pub fn as_reference(&self) -> Option<(&Ty, Mutability)> {
932 match self.kind(&Interner) { 932 match self.kind(&Interner) {
933 TyKind::Ref(mutability, ty) => Some((ty, *mutability)), 933 TyKind::Ref(mutability, ty) => Some((ty, *mutability)),
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index 5e2024f0a..762b226e6 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -1216,7 +1216,7 @@ impl_from!(FunctionId, StructId, UnionId, EnumVariantId, ConstId, StaticId for V
1216/// namespace. 1216/// namespace.
1217pub(crate) fn ty_query(db: &dyn HirDatabase, def: TyDefId) -> Binders<Ty> { 1217pub(crate) fn ty_query(db: &dyn HirDatabase, def: TyDefId) -> Binders<Ty> {
1218 match def { 1218 match def {
1219 TyDefId::BuiltinType(it) => Binders::new(0, Ty::builtin(it)), 1219 TyDefId::BuiltinType(it) => Binders::new(0, TyBuilder::builtin(it)),
1220 TyDefId::AdtId(it) => type_for_adt(db, it), 1220 TyDefId::AdtId(it) => type_for_adt(db, it),
1221 TyDefId::TypeAliasId(it) => type_for_type_alias(db, it), 1221 TyDefId::TypeAliasId(it) => type_for_type_alias(db, it),
1222 } 1222 }