aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/primitive.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/primitive.rs')
-rw-r--r--crates/ra_hir/src/ty/primitive.rs32
1 files changed, 13 insertions, 19 deletions
diff --git a/crates/ra_hir/src/ty/primitive.rs b/crates/ra_hir/src/ty/primitive.rs
index 7362de4c3..47789db87 100644
--- a/crates/ra_hir/src/ty/primitive.rs
+++ b/crates/ra_hir/src/ty/primitive.rs
@@ -4,44 +4,38 @@ use std::fmt;
4 4
5pub use hir_def::builtin_type::{FloatBitness, IntBitness, Signedness}; 5pub use hir_def::builtin_type::{FloatBitness, IntBitness, Signedness};
6 6
7#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] 7#[derive(Clone, Copy, Eq, PartialEq, Hash, Debug)]
8pub enum UncertainIntTy { 8pub enum Uncertain<T> {
9 Unknown, 9 Unknown,
10 Known(IntTy), 10 Known(T),
11} 11}
12 12
13impl From<IntTy> for UncertainIntTy { 13impl From<IntTy> for Uncertain<IntTy> {
14 fn from(ty: IntTy) -> Self { 14 fn from(ty: IntTy) -> Self {
15 UncertainIntTy::Known(ty) 15 Uncertain::Known(ty)
16 } 16 }
17} 17}
18 18
19impl fmt::Display for UncertainIntTy { 19impl fmt::Display for Uncertain<IntTy> {
20 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 20 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21 match *self { 21 match *self {
22 UncertainIntTy::Unknown => write!(f, "{{integer}}"), 22 Uncertain::Unknown => write!(f, "{{integer}}"),
23 UncertainIntTy::Known(ty) => write!(f, "{}", ty), 23 Uncertain::Known(ty) => write!(f, "{}", ty),
24 } 24 }
25 } 25 }
26} 26}
27 27
28#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] 28impl From<FloatTy> for Uncertain<FloatTy> {
29pub enum UncertainFloatTy {
30 Unknown,
31 Known(FloatTy),
32}
33
34impl From<FloatTy> for UncertainFloatTy {
35 fn from(ty: FloatTy) -> Self { 29 fn from(ty: FloatTy) -> Self {
36 UncertainFloatTy::Known(ty) 30 Uncertain::Known(ty)
37 } 31 }
38} 32}
39 33
40impl fmt::Display for UncertainFloatTy { 34impl fmt::Display for Uncertain<FloatTy> {
41 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 35 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
42 match *self { 36 match *self {
43 UncertainFloatTy::Unknown => write!(f, "{{float}}"), 37 Uncertain::Unknown => write!(f, "{{float}}"),
44 UncertainFloatTy::Known(ty) => write!(f, "{}", ty), 38 Uncertain::Known(ty) => write!(f, "{}", ty),
45 } 39 }
46 } 40 }
47} 41}