@@ -877,6 +877,23 @@ impl TyBuilder<()> {
877
877
} )
878
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
882
899
impl TyBuilder < hir_def:: AdtId > {
@@ -911,23 +928,6 @@ impl TyBuilder<hir_def::AdtId> {
911
928
}
912
929
913
930
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
-
931
931
pub fn as_reference ( & self ) -> Option < ( & Ty , Mutability ) > {
932
932
match self . kind ( & Interner ) {
933
933
TyKind :: Ref ( mutability, ty) => Some ( ( ty, * mutability) ) ,
0 commit comments