Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIT: Implement @since and @unstable annotations #1508

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

alexcrichton
Copy link
Member

@alexcrichton alexcrichton commented Apr 19, 2024

This PR is an implementation of WebAssembly/component-model#332 for wasm-tools. This is a pretty big feature for WIT so it's a pretty large PR as well. I've tried to split out separate commits where each commit passes test to more easily digest the changes that are happening here.

At a high level:

  • Most items in WIT can now be tagged with @since and @unstable.
  • When tagged with @unstable items do not appear in Resolve by default
  • Features are enabled through the set at Resolve::features to control whether unstable items appear
  • WIT items always retain their stability annotations throught processing, e.g. in Resolve
  • Round-tripping a WIT document through the WebAssembly component encoding preserves stability annotations

The intention is that this will be a building block for WASI's release processes. Namely all APIs will start as @unstable and only become ungated with @since once they're voted to be at such a phase. @unstable APIs will be available to all consumers but only on an opt-in basis which will enable everyone to have proper gates and processes around ensuring that unstable APIs aren't relied on without knowing that things may change.

Previously the entire error message was replaced, losing any attached
context. This commit updates error highlighting to only augment the
single error found in the chain that's being highlighted (in the most
common case). This required a small refactoring of the `Error` type and
changes all existing users to a method-based constructor rather than
explicit struct-based construction.
Nothing uses the results of parsing yet, that's going to come in a
future commit.
Will be used for errors in a future commit.
This commit pushes stability attributes through the resolution process
to the next stage of AST. The top-level user-facing types in
`wit-parser` now have `Stability` annotations were they can be added.

This commit notably changes the `WorldItem::Interface` enum variant to
contain a stability attribute in addition to the id listed.
This finishes support for `@unstable` and `@since` in `Resolve` by
handling all items there and specifically filtering out any disabled
items.
This involved a number of refactorings and "tricks" to get this to work
out. Namely when possible the old format of the custom section is still
emitted to ensure older/newer tools can interoperate when possible.
@ydnar
Copy link
Contributor

ydnar commented Apr 26, 2024

Would this PR update the JSON fixtures in the wit-parser crate?

@alexcrichton
Copy link
Member Author

It does, yes. You can see examples in the *.json files in this PR diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants