aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/consts.rs
diff options
context:
space:
mode:
authorJade <[email protected]>2021-05-12 12:39:48 +0100
committerJade <[email protected]>2021-05-13 05:22:46 +0100
commit8b147624ff906a11134d2e18be071c6cb8ec4beb (patch)
tree28df73a940497bc170ec9f080329657f4b1370b8 /crates/hir_ty/src/consts.rs
parent312f1fe20a6a0a8e69834c66f51b9abc9db5e0ce (diff)
Add lowering of array lengths in types
Now e.g. ```rust fn a(b: [u8; 2]) { } ``` will know about the length of b.
Diffstat (limited to 'crates/hir_ty/src/consts.rs')
-rw-r--r--crates/hir_ty/src/consts.rs21
1 files changed, 0 insertions, 21 deletions
diff --git a/crates/hir_ty/src/consts.rs b/crates/hir_ty/src/consts.rs
deleted file mode 100644
index 0044b1cff..000000000
--- a/crates/hir_ty/src/consts.rs
+++ /dev/null
@@ -1,21 +0,0 @@
1//! Handling of concrete const values
2
3/// A concrete constant value
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum ConstScalar {
6 // for now, we only support the trivial case of constant evaluating the length of an array
7 // Note that this is u64 because the target usize may be bigger than our usize
8 Usize(u64),
9
10 /// Case of an unknown value that rustc might know but we don't
11 Unknown,
12}
13
14impl std::fmt::Display for ConstScalar {
15 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
16 match self {
17 ConstScalar::Usize(us) => write!(fmt, "{}", us),
18 ConstScalar::Unknown => write!(fmt, "_"),
19 }
20 }
21}