Skip to content

Commit

Permalink
wast: Add #[non_exhaustive] to WastArg and WastRet (bytecodea…
Browse files Browse the repository at this point in the history
…lliance#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
  • Loading branch information
Robbepop authored Nov 3, 2024
1 parent 5dee4ec commit 537ca81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions crates/wast/src/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,9 @@ pub enum QuoteWatTest {

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

#[derive(Debug)]
#[allow(missing_docs)]
#[non_exhaustive]
pub enum WastRet<'a> {
Core(WastRetCore<'a>),
#[cfg(feature = "component-model")]
Expand Down
4 changes: 2 additions & 2 deletions src/bin/wasm-tools/json_from_wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl<'a> JsonBuilder<'a> {
for arg in args {
let arg = match arg {
WastArg::Core(core) => core,
WastArg::Component(_) => bail!("component support not implemented yet"),
_ => bail!("encountered unsupported Wast argument: {arg:?}"),
};
let val = match arg {
I32(i) => json::Const::I32 {
Expand Down Expand Up @@ -419,7 +419,7 @@ impl<'a> JsonBuilder<'a> {
for r in rets {
let r = match r {
WastRet::Core(core) => self.core_ret(core)?,
WastRet::Component(_) => bail!("component support not implemented yet"),
_ => bail!("encountered unsupported Wast result: {r:?}"),
};
ret.push(r);
}
Expand Down

0 comments on commit 537ca81

Please sign in to comment.