Skip to content

Commit 537ca81

Browse files
authored
wast: Add #[non_exhaustive] to WastArg and WastRet (bytecodealliance#1891)
* add #[non_exhaustive] to WastArg and WastRet This attribute is required because depending on #[cfg(feature = "component-model")] WastArg and WastRet can be enums with a single variant. Since crate features are resolved together this might cause problems in a crate due to feature usage of another crate or dependency, e.g. in the same workspace, with respect to irrefutable patterns. * fix errors after attribute additions * remove now outdated comment
1 parent 5dee4ec commit 537ca81

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

crates/wast/src/wast.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,9 @@ pub enum QuoteWatTest {
498498

499499
#[derive(Debug)]
500500
#[allow(missing_docs)]
501+
#[non_exhaustive]
501502
pub enum WastArg<'a> {
502503
Core(WastArgCore<'a>),
503-
// TODO: technically this isn't cargo-compliant since it means that this
504-
// isn't and additive feature by defining this conditionally. That being
505-
// said this seems unlikely to break many in practice so this isn't a shared
506-
// type, so fixing this is left to a future commit.
507504
#[cfg(feature = "component-model")]
508505
Component(WastVal<'a>),
509506
}
@@ -524,6 +521,7 @@ impl<'a> Parse<'a> for WastArg<'a> {
524521

525522
#[derive(Debug)]
526523
#[allow(missing_docs)]
524+
#[non_exhaustive]
527525
pub enum WastRet<'a> {
528526
Core(WastRetCore<'a>),
529527
#[cfg(feature = "component-model")]

src/bin/wasm-tools/json_from_wast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl<'a> JsonBuilder<'a> {
362362
for arg in args {
363363
let arg = match arg {
364364
WastArg::Core(core) => core,
365-
WastArg::Component(_) => bail!("component support not implemented yet"),
365+
_ => bail!("encountered unsupported Wast argument: {arg:?}"),
366366
};
367367
let val = match arg {
368368
I32(i) => json::Const::I32 {
@@ -419,7 +419,7 @@ impl<'a> JsonBuilder<'a> {
419419
for r in rets {
420420
let r = match r {
421421
WastRet::Core(core) => self.core_ret(core)?,
422-
WastRet::Component(_) => bail!("component support not implemented yet"),
422+
_ => bail!("encountered unsupported Wast result: {r:?}"),
423423
};
424424
ret.push(r);
425425
}

0 commit comments

Comments
 (0)