@@ -84,7 +84,7 @@ type int8_t = i8;
84
84
85
85
[ subsystem ] : https://msdn.microsoft.com/en-us/library/fcc1zstk.aspx
86
86
87
- ### Module-only attributes
87
+ ## Module-only attributes
88
88
89
89
- ` no_implicit_prelude ` - disable injecting ` use std::prelude::* ` in this
90
90
module.
@@ -175,9 +175,6 @@ macro scope.
175
175
176
176
## Miscellaneous attributes
177
177
178
- - ` deprecated ` - mark the item as deprecated; the full attribute is
179
- ` #[deprecated(since = "crate version", note = "...") ` , where both arguments
180
- are optional.
181
178
- ` export_name ` - on statics and functions, this determines the name of the
182
179
exported symbol.
183
180
- ` link_section ` - on statics and functions, this specifies the section of the
@@ -188,6 +185,37 @@ macro scope.
188
185
assigned to a variable. You may also include an optional message by using
189
186
` #[must_use = "message"] ` which will be given alongside the warning.
190
187
188
+ ### Deprecation
189
+
190
+ The ` deprecated ` attribute marks an item as deprecated. It has two optional
191
+ fields, ` since ` and ` note ` .
192
+
193
+ - ` since ` expects a version number, as in ` #[deprecated(since = "1.4.1")] `
194
+ - ` rustc ` doesn't know anything about versions, but external tools like
195
+ ` clippy ` may check the validity of this field.
196
+ - ` note ` is a free text field, allowing you to provide an explanation about
197
+ the deprecation and preferred alternatives.
198
+
199
+ Only [ public items] ( visibility-and-privacy.html ) can be given the
200
+ ` #[deprecated] ` attribute. ` #[deprecated] ` on a module is inherited by all
201
+ child items of that module.
202
+
203
+ ` rustc ` will issue warnings on usage of ` #[deprecated] ` items. ` rustdoc ` will
204
+ show item deprecation, including the ` since ` version and ` note ` , if available.
205
+
206
+ Here's an example.
207
+
208
+ ``` rust
209
+ #[deprecated(since = " 5.2" , note = " foo was rarely used. Users should instead use bar" )]
210
+ pub fn foo () {}
211
+
212
+ pub fn bar () {}
213
+ ```
214
+
215
+ The [ RFC] [ 1270-deprecation.md ] contains motivations and more details.
216
+
217
+ [ 1270-deprecation.md ] : https://github.com/rust-lang/rfcs/blob/master/text/1270-deprecation.md
218
+
191
219
### Documentation
192
220
193
221
The ` doc ` attribute is used to document items and fields. [ Doc comments]
0 commit comments