Skip to content

Commit c41fe68

Browse files
committed
Add support for @deprecated gates to WIT
1 parent cdad9c3 commit c41fe68

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

design/mvp/WIT.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,8 +923,9 @@ package-items ::= toplevel-use-item | interface-item | world-item
923923
### Feature Gates
924924

925925
Various WIT items can be "gated", to reflect the fact that the item is part of
926-
an unstable feature or that the item was added as part of a minor version
927-
update and shouldn't be used when targeting an earlier minor version.
926+
an unstable feature, that the item was added as part of a minor version
927+
update and shouldn't be used when targeting an earlier minor version, or that a
928+
feature has been deprecated and should no longer be used.
928929

929930
For example, the following interface has 4 items, 3 of which are gated:
930931
```wit
@@ -939,6 +940,9 @@ interface foo {
939940
940941
@unstable(feature = fancier-foo)
941942
d: func();
943+
944+
@deprecated(version = 0.2.1)
945+
e: func();
942946
}
943947
```
944948
The `@since` gate indicates that `b` and `c` were added as part of the `0.2.1`
@@ -953,6 +957,12 @@ change type or be removed at any time. An important expectation set by the
953957
`@unstable` gate is that toolchains will not expose `@unstable` features by
954958
default unless explicitly opted-into by the developer.
955959

960+
Finally, the `@deprecated` gate on `e` indicates that `e` should no longer be
961+
used starting version `0.2.1`. `@deprecated` gates can carry an optional
962+
"message" field which can be used to elaborate why the feature should no longer
963+
be used and which feature to use instead. Both toolchains and host runtimes may
964+
warn users if they detect an `@deprecated` API is being used.
965+
956966
Together, these gates support a development flow in which new features start
957967
with an `@unstable` gate while the details are still being hashed out. Then,
958968
once the feature is stable (and, in a WASI context, voted upon), the
@@ -970,9 +980,15 @@ Specifically, the syntax for feature gates is:
970980
```wit
971981
gate ::= unstable-gate
972982
| since-gate
983+
| deprecated-gate
984+
973985
unstable-gate ::= '@unstable' '(' feature-field ')'
986+
since-gate ::= '@since' '(' version-field ( ',' feature-field )? ')'
987+
deprecated-gate ::= '@deprecated' '(' version-field ( ',' message-field )? ')'
988+
974989
feature-field ::= 'feature' '=' id
975-
since-gate ::= '@since' '(' 'version' '=' <valid semver> ( ',' feature-field )? ')'
990+
version-field ::= 'version' '=' <valid semver>
991+
message-field ::= 'message' '=' message
976992
```
977993

978994
As part of WIT validation, any item that refers to another gated item must also

0 commit comments

Comments
 (0)