about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-11-24 16:25:20 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-11-24 16:32:07 -0500
commit66dce1114d1014258c8cc586e176f2ea53ab4ed1 (patch)
treea77e2d5f09682aa800fee5f4da22a5c779edcd57 /src/libsyntax
parent5a1d028d4c8fc15473dc10473c38df162daa7b41 (diff)
downloadrust-66dce1114d1014258c8cc586e176f2ea53ab4ed1.tar.gz
rust-66dce1114d1014258c8cc586e176f2ea53ab4ed1.zip
Store ptr_width as u32 on Config
This removes the dependency on IntTy, UintTy from Session.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 14243076941..b8561216896 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1693,6 +1693,18 @@ impl IntTy {
             IntTy::I128 => 128,
         })
     }
+
+    pub fn normalize(&self, target_width: u32) -> Self {
+        match self {
+            IntTy::Isize => match target_width {
+                16 => IntTy::I16,
+                32 => IntTy::I32,
+                64 => IntTy::I64,
+                _ => unreachable!(),
+            },
+            _ => *self,
+        }
+    }
 }
 
 #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic,
@@ -1743,6 +1755,18 @@ impl UintTy {
             UintTy::U128 => 128,
         })
     }
+
+    pub fn normalize(&self, target_width: u32) -> Self {
+        match self {
+            UintTy::Usize => match target_width {
+                16 => UintTy::U16,
+                32 => UintTy::U32,
+                64 => UintTy::U64,
+                _ => unreachable!(),
+            },
+            _ => *self,
+        }
+    }
 }
 
 /// A constraint on an associated type (e.g., `A = Bar` in `Foo<A = Bar>` or