aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
authorJade <[email protected]>2021-05-16 02:51:18 +0100
committerJade <[email protected]>2021-05-16 02:51:18 +0100
commitde0ed9860d86c3b905a967b1a7b5243499d32d67 (patch)
tree6c98701c319b32a52fdd6d39ce85c590aaf254f9 /crates/hir_def
parent78d6b88f211cc9faf88815ce7fb1a91546cfce15 (diff)
Address final feedback
* rename ConstExtension->ConstExt * refactor a manual construction of a Const
Diffstat (limited to 'crates/hir_def')
-rw-r--r--crates/hir_def/src/type_ref.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/hir_def/src/type_ref.rs b/crates/hir_def/src/type_ref.rs
index 6a3259b27..9e44547cb 100644
--- a/crates/hir_def/src/type_ref.rs
+++ b/crates/hir_def/src/type_ref.rs
@@ -336,6 +336,14 @@ impl std::fmt::Display for ConstScalar {
336} 336}
337 337
338impl ConstScalar { 338impl ConstScalar {
339 /// Gets a target usize out of the ConstScalar
340 pub fn as_usize(&self) -> Option<u64> {
341 match self {
342 &ConstScalar::Usize(us) => Some(us),
343 _ => None,
344 }
345 }
346
339 // FIXME: as per the comments on `TypeRef::Array`, this evaluation should not happen at this 347 // FIXME: as per the comments on `TypeRef::Array`, this evaluation should not happen at this
340 // parse stage. 348 // parse stage.
341 fn usize_from_literal_expr(expr: ast::Expr) -> ConstScalar { 349 fn usize_from_literal_expr(expr: ast::Expr) -> ConstScalar {