From baba49d8f07ee37a07755cb26e94429f7254a4a1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 1 Mar 2024 04:02:47 -0500 Subject: [PATCH] Add `f16` and `f128` to the AST --- compiler/rustc_ast/src/ast.rs | 6 ++++++ compiler/rustc_middle/src/ty/mod.rs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 31dd358ad51..970e35221e1 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1909,22 +1909,28 @@ pub struct FnSig { #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[derive(Encodable, Decodable, HashStable_Generic)] pub enum FloatTy { + F16, F32, F64, + F128, } impl FloatTy { pub fn name_str(self) -> &'static str { match self { + FloatTy::F16 => "f16", FloatTy::F32 => "f32", FloatTy::F64 => "f64", + FloatTy::F128 => "f128", } } pub fn name(self) -> Symbol { match self { + FloatTy::F16 => sym::f16, FloatTy::F32 => sym::f32, FloatTy::F64 => sym::f64, + FloatTy::F128 => sym::f128, } } } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 6fdb03c0bab..f005a240504 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1991,8 +1991,10 @@ pub fn uint_ty(uty: ast::UintTy) -> UintTy { pub fn float_ty(fty: ast::FloatTy) -> FloatTy { match fty { + ast::FloatTy::F16 => FloatTy::F16, ast::FloatTy::F32 => FloatTy::F32, ast::FloatTy::F64 => FloatTy::F64, + ast::FloatTy::F128 => FloatTy::F128, } }