From ed069b714885d0cb504480db4a41d2cf2ec7cf88 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 23 Jan 2026 13:34:21 -0800 Subject: [PATCH] Remove support for `float{32,64}` This was transitioned long ago at this point, so no need to keep around the old compat code. --- crates/wit-component/src/printing.rs | 25 ++----------------------- crates/wit-parser/src/ast.rs | 9 +-------- crates/wit-parser/src/ast/lex.rs | 23 ++--------------------- 3 files changed, 5 insertions(+), 52 deletions(-) diff --git a/crates/wit-component/src/printing.rs b/crates/wit-component/src/printing.rs index e8efac6b6a..e02b9b17fc 100644 --- a/crates/wit-component/src/printing.rs +++ b/crates/wit-component/src/printing.rs @@ -6,9 +6,6 @@ use std::mem; use std::ops::Deref; use wit_parser::*; -// NB: keep in sync with `crates/wit-parser/src/ast/lex.rs` -const PRINT_F32_F64_DEFAULT: bool = true; - /// A utility for printing WebAssembly interface definitions to a string. pub struct WitPrinter { /// Visitor that holds the WIT document being printed. @@ -20,8 +17,6 @@ pub struct WitPrinter { // Whether to print doc comments. emit_docs: bool, - - print_f32_f64: bool, } impl Default for WitPrinter { @@ -37,10 +32,6 @@ impl WitPrinter { output, any_items: false, emit_docs: true, - print_f32_f64: match std::env::var("WIT_REQUIRE_F32_F64") { - Ok(s) => s == "1", - Err(_) => PRINT_F32_F64_DEFAULT, - }, } } @@ -543,20 +534,8 @@ impl WitPrinter { Type::S16 => self.output.ty("s16", TypeKind::BuiltIn), Type::S32 => self.output.ty("s32", TypeKind::BuiltIn), Type::S64 => self.output.ty("s64", TypeKind::BuiltIn), - Type::F32 => { - if self.print_f32_f64 { - self.output.ty("f32", TypeKind::BuiltIn) - } else { - self.output.ty("f32", TypeKind::BuiltIn) - } - } - Type::F64 => { - if self.print_f32_f64 { - self.output.ty("f64", TypeKind::BuiltIn) - } else { - self.output.ty("f64", TypeKind::BuiltIn) - } - } + Type::F32 => self.output.ty("f32", TypeKind::BuiltIn), + Type::F64 => self.output.ty("f64", TypeKind::BuiltIn), Type::Char => self.output.ty("char", TypeKind::BuiltIn), Type::String => self.output.ty("string", TypeKind::BuiltIn), Type::ErrorContext => self.output.ty("error-context", TypeKind::BuiltIn), diff --git a/crates/wit-parser/src/ast.rs b/crates/wit-parser/src/ast.rs index 84d30be186..a2253877e3 100644 --- a/crates/wit-parser/src/ast.rs +++ b/crates/wit-parser/src/ast.rs @@ -1693,7 +1693,6 @@ fn eat_id(tokens: &mut Tokenizer<'_>, expected: &str) -> Result { pub struct SourceMap { sources: Vec, offset: u32, - require_f32_f64: Option, } #[derive(Clone)] @@ -1709,11 +1708,6 @@ impl SourceMap { SourceMap::default() } - #[doc(hidden)] // NB: only here for a transitionary period - pub fn set_require_f32_f64(&mut self, enable: bool) { - self.require_f32_f64 = Some(enable); - } - /// Reads the file `path` on the filesystem and appends its contents to this /// [`SourceMap`]. #[cfg(feature = "std")] @@ -1778,7 +1772,6 @@ impl SourceMap { // passing through the source to get tokenized. &src.contents[..src.contents.len() - 1], src.offset, - self.require_f32_f64, ) .with_context(|| format!("failed to tokenize path: {}", src.path))?; let mut file = PackageFile::parse(&mut tokens)?; @@ -1965,7 +1958,7 @@ pub enum ParsedUsePath { } pub fn parse_use_path(s: &str) -> Result { - let mut tokens = Tokenizer::new(s, 0, None)?; + let mut tokens = Tokenizer::new(s, 0)?; let path = UsePath::parse(&mut tokens)?; if tokens.next()?.is_some() { bail!("trailing tokens in path specifier"); diff --git a/crates/wit-parser/src/ast/lex.rs b/crates/wit-parser/src/ast/lex.rs index 443a01b8e6..4ee653ced3 100644 --- a/crates/wit-parser/src/ast/lex.rs +++ b/crates/wit-parser/src/ast/lex.rs @@ -13,7 +13,6 @@ pub struct Tokenizer<'a> { input: &'a str, span_offset: u32, chars: CrlfFold<'a>, - require_f32_f64: bool, } #[derive(Clone)] @@ -120,15 +119,8 @@ pub enum Error { }, } -// NB: keep in sync with `crates/wit-component/src/printing.rs`. -const REQUIRE_F32_F64_BY_DEFAULT: bool = true; - impl<'a> Tokenizer<'a> { - pub fn new( - input: &'a str, - span_offset: u32, - require_f32_f64: Option, - ) -> Result> { + pub fn new(input: &'a str, span_offset: u32) -> Result> { detect_invalid_input(input)?; let mut t = Tokenizer { @@ -137,15 +129,6 @@ impl<'a> Tokenizer<'a> { chars: CrlfFold { chars: input.char_indices(), }, - require_f32_f64: require_f32_f64.unwrap_or_else(|| { - #[cfg(feature = "std")] - match std::env::var("WIT_REQUIRE_F32_F64") { - Ok(s) => s == "1", - Err(_) => REQUIRE_F32_F64_BY_DEFAULT, - } - #[cfg(not(feature = "std"))] - REQUIRE_F32_F64_BY_DEFAULT - }), }; // Eat utf-8 BOM t.eatc('\u{feff}'); @@ -289,8 +272,6 @@ impl<'a> Tokenizer<'a> { "s64" => S64, "f32" => F32, "f64" => F64, - "float32" if !self.require_f32_f64 => F32, - "float64" if !self.require_f32_f64 => F64, "char" => Char, "resource" => Resource, "own" => Own, @@ -673,7 +654,7 @@ fn test_validate_id() { #[test] fn test_tokenizer() { fn collect(s: &str) -> Result> { - let mut t = Tokenizer::new(s, 0, None)?; + let mut t = Tokenizer::new(s, 0)?; let mut tokens = Vec::new(); while let Some(token) = t.next()? { tokens.push(token.1);