Skip to content

Commit c5cc6d4

Browse files
authored
Remove support for float{32,64} (#2426)
This was transitioned long ago at this point, so no need to keep around the old compat code.
1 parent 6498b69 commit c5cc6d4

3 files changed

Lines changed: 5 additions & 52 deletions

File tree

crates/wit-component/src/printing.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ use std::mem;
66
use std::ops::Deref;
77
use wit_parser::*;
88

9-
// NB: keep in sync with `crates/wit-parser/src/ast/lex.rs`
10-
const PRINT_F32_F64_DEFAULT: bool = true;
11-
129
/// A utility for printing WebAssembly interface definitions to a string.
1310
pub struct WitPrinter<O: Output = OutputToString> {
1411
/// Visitor that holds the WIT document being printed.
@@ -20,8 +17,6 @@ pub struct WitPrinter<O: Output = OutputToString> {
2017

2118
// Whether to print doc comments.
2219
emit_docs: bool,
23-
24-
print_f32_f64: bool,
2520
}
2621

2722
impl Default for WitPrinter {
@@ -37,10 +32,6 @@ impl<O: Output> WitPrinter<O> {
3732
output,
3833
any_items: false,
3934
emit_docs: true,
40-
print_f32_f64: match std::env::var("WIT_REQUIRE_F32_F64") {
41-
Ok(s) => s == "1",
42-
Err(_) => PRINT_F32_F64_DEFAULT,
43-
},
4435
}
4536
}
4637

@@ -543,20 +534,8 @@ impl<O: Output> WitPrinter<O> {
543534
Type::S16 => self.output.ty("s16", TypeKind::BuiltIn),
544535
Type::S32 => self.output.ty("s32", TypeKind::BuiltIn),
545536
Type::S64 => self.output.ty("s64", TypeKind::BuiltIn),
546-
Type::F32 => {
547-
if self.print_f32_f64 {
548-
self.output.ty("f32", TypeKind::BuiltIn)
549-
} else {
550-
self.output.ty("f32", TypeKind::BuiltIn)
551-
}
552-
}
553-
Type::F64 => {
554-
if self.print_f32_f64 {
555-
self.output.ty("f64", TypeKind::BuiltIn)
556-
} else {
557-
self.output.ty("f64", TypeKind::BuiltIn)
558-
}
559-
}
537+
Type::F32 => self.output.ty("f32", TypeKind::BuiltIn),
538+
Type::F64 => self.output.ty("f64", TypeKind::BuiltIn),
560539
Type::Char => self.output.ty("char", TypeKind::BuiltIn),
561540
Type::String => self.output.ty("string", TypeKind::BuiltIn),
562541
Type::ErrorContext => self.output.ty("error-context", TypeKind::BuiltIn),

crates/wit-parser/src/ast.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,6 @@ fn eat_id(tokens: &mut Tokenizer<'_>, expected: &str) -> Result<Span> {
16931693
pub struct SourceMap {
16941694
sources: Vec<Source>,
16951695
offset: u32,
1696-
require_f32_f64: Option<bool>,
16971696
}
16981697

16991698
#[derive(Clone)]
@@ -1709,11 +1708,6 @@ impl SourceMap {
17091708
SourceMap::default()
17101709
}
17111710

1712-
#[doc(hidden)] // NB: only here for a transitionary period
1713-
pub fn set_require_f32_f64(&mut self, enable: bool) {
1714-
self.require_f32_f64 = Some(enable);
1715-
}
1716-
17171711
/// Reads the file `path` on the filesystem and appends its contents to this
17181712
/// [`SourceMap`].
17191713
#[cfg(feature = "std")]
@@ -1778,7 +1772,6 @@ impl SourceMap {
17781772
// passing through the source to get tokenized.
17791773
&src.contents[..src.contents.len() - 1],
17801774
src.offset,
1781-
self.require_f32_f64,
17821775
)
17831776
.with_context(|| format!("failed to tokenize path: {}", src.path))?;
17841777
let mut file = PackageFile::parse(&mut tokens)?;
@@ -1965,7 +1958,7 @@ pub enum ParsedUsePath {
19651958
}
19661959

19671960
pub fn parse_use_path(s: &str) -> Result<ParsedUsePath> {
1968-
let mut tokens = Tokenizer::new(s, 0, None)?;
1961+
let mut tokens = Tokenizer::new(s, 0)?;
19691962
let path = UsePath::parse(&mut tokens)?;
19701963
if tokens.next()?.is_some() {
19711964
bail!("trailing tokens in path specifier");

crates/wit-parser/src/ast/lex.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub struct Tokenizer<'a> {
1313
input: &'a str,
1414
span_offset: u32,
1515
chars: CrlfFold<'a>,
16-
require_f32_f64: bool,
1716
}
1817

1918
#[derive(Clone)]
@@ -120,15 +119,8 @@ pub enum Error {
120119
},
121120
}
122121

123-
// NB: keep in sync with `crates/wit-component/src/printing.rs`.
124-
const REQUIRE_F32_F64_BY_DEFAULT: bool = true;
125-
126122
impl<'a> Tokenizer<'a> {
127-
pub fn new(
128-
input: &'a str,
129-
span_offset: u32,
130-
require_f32_f64: Option<bool>,
131-
) -> Result<Tokenizer<'a>> {
123+
pub fn new(input: &'a str, span_offset: u32) -> Result<Tokenizer<'a>> {
132124
detect_invalid_input(input)?;
133125

134126
let mut t = Tokenizer {
@@ -137,15 +129,6 @@ impl<'a> Tokenizer<'a> {
137129
chars: CrlfFold {
138130
chars: input.char_indices(),
139131
},
140-
require_f32_f64: require_f32_f64.unwrap_or_else(|| {
141-
#[cfg(feature = "std")]
142-
match std::env::var("WIT_REQUIRE_F32_F64") {
143-
Ok(s) => s == "1",
144-
Err(_) => REQUIRE_F32_F64_BY_DEFAULT,
145-
}
146-
#[cfg(not(feature = "std"))]
147-
REQUIRE_F32_F64_BY_DEFAULT
148-
}),
149132
};
150133
// Eat utf-8 BOM
151134
t.eatc('\u{feff}');
@@ -289,8 +272,6 @@ impl<'a> Tokenizer<'a> {
289272
"s64" => S64,
290273
"f32" => F32,
291274
"f64" => F64,
292-
"float32" if !self.require_f32_f64 => F32,
293-
"float64" if !self.require_f32_f64 => F64,
294275
"char" => Char,
295276
"resource" => Resource,
296277
"own" => Own,
@@ -673,7 +654,7 @@ fn test_validate_id() {
673654
#[test]
674655
fn test_tokenizer() {
675656
fn collect(s: &str) -> Result<Vec<Token>> {
676-
let mut t = Tokenizer::new(s, 0, None)?;
657+
let mut t = Tokenizer::new(s, 0)?;
677658
let mut tokens = Vec::new();
678659
while let Some(token) = t.next()? {
679660
tokens.push(token.1);

0 commit comments

Comments
 (0)