@@ -923,8 +923,9 @@ package-items ::= toplevel-use-item | interface-item | world-item
923
923
### Feature Gates
924
924
925
925
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.
928
929
929
930
For example, the following interface has 4 items, 3 of which are gated:
930
931
``` wit
@@ -939,6 +940,10 @@ interface foo {
939
940
940
941
@unstable(feature = fancier-foo)
941
942
d: func();
943
+
944
+ @since(version = 0.2.0)
945
+ @deprecated(version = 0.2.2)
946
+ e: func();
942
947
}
943
948
```
944
949
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
953
958
` @unstable ` gate is that toolchains will not expose ` @unstable ` features by
954
959
default unless explicitly opted-into by the developer.
955
960
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
+
956
966
Together, these gates support a development flow in which new features start
957
967
with an ` @unstable ` gate while the details are still being hashed out. Then,
958
968
once the feature is stable (and, in a WASI context, voted upon), the
@@ -968,11 +978,17 @@ enable the feature by default.
968
978
969
979
Specifically, the syntax for feature gates is:
970
980
``` wit
971
- gate ::= unstable-gate
972
- | since-gate
981
+ gate ::= gate-item*
982
+ gate-item ::= unstable-gate
983
+ | since-gate
984
+ | deprecated-gate
985
+
973
986
unstable-gate ::= '@unstable' '(' feature-field ')'
987
+ since-gate ::= '@since' '(' version-field ( ',' feature-field )? ')'
988
+ deprecated-gate ::= '@deprecated' '(' version-field ')'
989
+
974
990
feature-field ::= 'feature' '=' id
975
- since-gate ::= '@since' '(' ' version' '=' <valid semver> ( ',' feature-field )? ')'
991
+ version-field ::= 'version' '=' <valid semver>
976
992
```
977
993
978
994
As part of WIT validation, any item that refers to another gated item must also
0 commit comments