diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 24 |
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 |
