Skip to content

Commit de2bc23

Browse files
authored
Merge pull request #377 from yoshuawuyts/deprecated-gate
Add support for `@deprecated` gates to WIT
2 parents abeee91 + 75d3a0f commit de2bc23

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

design/mvp/WIT.md

+21-5
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,10 @@ interface foo {
939940
940941
@unstable(feature = fancier-foo)
941942
d: func();
943+
944+
@since(version = 0.2.0)
945+
@deprecated(version = 0.2.2)
946+
e: func();
942947
}
943948
```
944949
The `@since` gate indicates that `b` and `c` were added as part of the `0.2.1`
@@ -953,6 +958,11 @@ change type or be removed at any time. An important expectation set by the
953958
`@unstable` gate is that toolchains will not expose `@unstable` features by
954959
default unless explicitly opted-into by the developer.
955960

961+
Finally, the `@deprecated` gate on `e` indicates that `e` should no longer be
962+
used starting version `0.2.2`. Both toolchains and host runtimes may warn users
963+
if they detect an `@deprecated` API is being used. An `@deprecated` gate is
964+
required to always be paired up with either a `@since` or `@deprecated` gate.
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
@@ -968,11 +978,17 @@ enable the feature by default.
968978

969979
Specifically, the syntax for feature gates is:
970980
```wit
971-
gate ::= unstable-gate
972-
| since-gate
981+
gate ::= gate-item*
982+
gate-item ::= unstable-gate
983+
| since-gate
984+
| deprecated-gate
985+
973986
unstable-gate ::= '@unstable' '(' feature-field ')'
987+
since-gate ::= '@since' '(' version-field ( ',' feature-field )? ')'
988+
deprecated-gate ::= '@deprecated' '(' version-field ')'
989+
974990
feature-field ::= 'feature' '=' id
975-
since-gate ::= '@since' '(' 'version' '=' <valid semver> ( ',' feature-field )? ')'
991+
version-field ::= 'version' '=' <valid semver>
976992
```
977993

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

0 commit comments

Comments
 (0)