diff options
author | David Faust <david.faust@oracle.com> | 2022-05-10 11:19:40 -0700 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2022-05-11 09:29:55 -0700 |
commit | 502c8a859750064103bb71f4d559cef7b1c1b8af (patch) | |
tree | a200b18cd14d2bc8db86415662d6498476e9776a | |
parent | Merge #1242 (diff) | |
download | gccrs-502c8a859750064103bb71f4d559cef7b1c1b8af.tar.gz gccrs-502c8a859750064103bb71f4d559cef7b1c1b8af.tar.bz2 gccrs-502c8a859750064103bb71f4d559cef7b1c1b8af.tar.xz |
typecheck: add is_primitive_type_kind helper
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.cc | 20 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.h | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 6b034ea63a7..d0e8b761622 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc | |||
@@ -114,6 +114,26 @@ TypeKindFormat::to_string (TypeKind kind) | |||
114 | } | 114 | } |
115 | 115 | ||
116 | bool | 116 | bool |
117 | is_primitive_type_kind (TypeKind kind) | ||
118 | { | ||
119 | switch (kind) | ||
120 | { | ||
121 | case TypeKind::BOOL: | ||
122 | case TypeKind::CHAR: | ||
123 | case TypeKind::INT: | ||
124 | case TypeKind::UINT: | ||
125 | case TypeKind::ISIZE: | ||
126 | case TypeKind::USIZE: | ||
127 | case TypeKind::FLOAT: | ||
128 | case TypeKind::NEVER: | ||
129 | case TypeKind::STR: | ||
130 | return true; | ||
131 | default: | ||
132 | return false; | ||
133 | } | ||
134 | } | ||
135 | |||
136 | bool | ||
117 | BaseType::satisfies_bound (const TypeBoundPredicate &predicate) const | 137 | BaseType::satisfies_bound (const TypeBoundPredicate &predicate) const |
118 | { | 138 | { |
119 | const Resolver::TraitReference *query = predicate.get (); | 139 | const Resolver::TraitReference *query = predicate.get (); |
diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 5f35c320a5f..a2950e97b56 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h | |||
@@ -67,6 +67,9 @@ enum TypeKind | |||
67 | ERROR | 67 | ERROR |
68 | }; | 68 | }; |
69 | 69 | ||
70 | extern bool | ||
71 | is_primitive_type_kind (TypeKind kind); | ||
72 | |||
70 | class TypeKindFormat | 73 | class TypeKindFormat |
71 | { | 74 | { |
72 | public: | 75 | public: |