diff options
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r-- | crates/hir_ty/src/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index 6bec389f8..50d248674 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -27,6 +27,7 @@ use std::{iter, mem, ops::Deref, sync::Arc}; | |||
27 | 27 | ||
28 | use base_db::{salsa, CrateId}; | 28 | use base_db::{salsa, CrateId}; |
29 | use hir_def::{ | 29 | use hir_def::{ |
30 | builtin_type::BuiltinType, | ||
30 | expr::ExprId, | 31 | expr::ExprId, |
31 | type_ref::{Mutability, Rawness}, | 32 | type_ref::{Mutability, Rawness}, |
32 | AdtId, AssocContainerId, DefWithBodyId, FunctionId, GenericDefId, HasModule, LifetimeParamId, | 33 | AdtId, AssocContainerId, DefWithBodyId, FunctionId, GenericDefId, HasModule, LifetimeParamId, |
@@ -738,6 +739,15 @@ impl Ty { | |||
738 | Substs(sig.params_and_return), | 739 | Substs(sig.params_and_return), |
739 | ) | 740 | ) |
740 | } | 741 | } |
742 | pub fn builtin(builtin: BuiltinType) -> Self { | ||
743 | Ty::simple(match builtin { | ||
744 | BuiltinType::Char => TypeCtor::Char, | ||
745 | BuiltinType::Bool => TypeCtor::Bool, | ||
746 | BuiltinType::Str => TypeCtor::Str, | ||
747 | BuiltinType::Int(t) => TypeCtor::Int(IntTy::from(t).into()), | ||
748 | BuiltinType::Float(t) => TypeCtor::Float(FloatTy::from(t).into()), | ||
749 | }) | ||
750 | } | ||
741 | 751 | ||
742 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { | 752 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { |
743 | match self { | 753 | match self { |