Skip to content

Commit

Permalink
Remove feature flag from post-stabilization feature gates
Browse files Browse the repository at this point in the history
This commit removes the optional `feature` specification from feature
gates (`@since`, in particular).

This change should simplify the usage of feature gates (see
WebAssembly/component-model#387) for more
discussion.

This is a breaking change for those who were depending on `wit-parser`
as `feature` now no longer present.

Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
  • Loading branch information
vados-cosmonic committed Aug 26, 2024
1 parent 1d20e5b commit 17072a4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
9 changes: 0 additions & 9 deletions crates/wit-parser/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,6 @@ enum Attribute<'a> {
Since {
span: Span,
version: Version,
feature: Option<Id<'a>>,
},
Unstable {
span: Span,
Expand All @@ -1571,18 +1570,10 @@ impl<'a> Attribute<'a> {
eat_id(tokens, "version")?;
tokens.expect(Token::Equals)?;
let (_span, version) = parse_version(tokens)?;
let feature = if tokens.eat(Token::Comma)? {
eat_id(tokens, "feature")?;
tokens.expect(Token::Equals)?;
Some(parse_id(tokens)?)
} else {
None
};
tokens.expect(Token::RightParen)?;
Attribute::Since {
span: id.span,
version,
feature,
}
}
"unstable" => {
Expand Down
14 changes: 3 additions & 11 deletions crates/wit-parser/src/ast/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1386,28 +1386,20 @@ impl<'a> Resolver<'a> {
match attrs {
[] => Ok(Stability::Unknown),

[ast::Attribute::Since {
version, feature, ..
}] => Ok(Stability::Stable {
[ast::Attribute::Since { version, .. }] => Ok(Stability::Stable {
since: version.clone(),
feature: feature.as_ref().map(|s| s.name.to_string()),
deprecated: None,
}),

[ast::Attribute::Since {
version, feature, ..
}, ast::Attribute::Deprecated {
[ast::Attribute::Since { version, .. }, ast::Attribute::Deprecated {
version: deprecated,
..
}]
| [ast::Attribute::Deprecated {
version: deprecated,
..
}, ast::Attribute::Since {
version, feature, ..
}] => Ok(Stability::Stable {
}, ast::Attribute::Since { version, .. }] => Ok(Stability::Stable {
since: version.clone(),
feature: feature.as_ref().map(|s| s.name.to_string()),
deprecated: Some(deprecated.clone()),
}),

Expand Down
2 changes: 0 additions & 2 deletions crates/wit-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,6 @@ pub enum Stability {
#[cfg_attr(feature = "serde", serde(serialize_with = "serialize_version"))]
#[cfg_attr(feature = "serde", serde(deserialize_with = "deserialize_version"))]
since: Version,
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
feature: Option<String>,
#[cfg_attr(
feature = "serde",
serde(
Expand Down

0 comments on commit 17072a4

Please sign in to comment.