@@ -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,9 @@ interface foo {
939
940
940
941
@unstable(feature = fancier-foo)
941
942
d: func();
943
+
944
+ @deprecated(version = 0.2.1)
945
+ e: func();
942
946
}
943
947
```
944
948
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
953
957
` @unstable ` gate is that toolchains will not expose ` @unstable ` features by
954
958
default unless explicitly opted-into by the developer.
955
959
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
+
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
@@ -970,9 +980,15 @@ Specifically, the syntax for feature gates is:
970
980
``` wit
971
981
gate ::= unstable-gate
972
982
| since-gate
983
+ | deprecated-gate
984
+
973
985
unstable-gate ::= '@unstable' '(' feature-field ')'
986
+ since-gate ::= '@since' '(' version-field ( ',' feature-field )? ')'
987
+ deprecated-gate ::= '@deprecated' '(' version-field ( ',' message-field )? ')'
988
+
974
989
feature-field ::= 'feature' '=' id
975
- since-gate ::= '@since' '(' 'version' '=' <valid semver> ( ',' feature-field )? ')'
990
+ version-field ::= 'version' '=' <valid semver>
991
+ message-field ::= 'message' '=' message
976
992
```
977
993
978
994
As part of WIT validation, any item that refers to another gated item must also
0 commit comments