6
6
# Summary
7
7
8
8
This RFC proposes to allow library authors to use a ` #[deprecated] ` attribute,
9
- with optional ` since = " ` * version* ` " ` and ` reason = "` * free text* ` " ` fields. The
9
+ with optional ` since = " ` * version* ` " ` and ` note = "` * free text* ` " ` fields. The
10
10
compiler can then warn on deprecated items, while ` rustdoc ` can document their
11
11
deprecation accordingly.
12
12
@@ -32,12 +32,11 @@ possible fields are optional:
32
32
deprecating the item, following the semver scheme. Rustc does not know about
33
33
versions, thus the content of this field is not checked (but will be by external
34
34
lints, e.g. [ rust-clippy] ( https://github.com/Manishearth/rust-clippy ) .
35
- * ` reason ` should contain a human-readable string outlining the reason for
36
- deprecating the item. While this field is not required, library authors are
37
- strongly advised to make use of it to convey the reason for the deprecation to
38
- users of their library. The string is interpreted as plain unformatted text
39
- (for now) so that rustdoc can include it in the item's documentation without
40
- messing up the formatting.
35
+ * ` note ` should contain a human-readable string outlining the reason for
36
+ deprecating the item and/or what to use instead. While this field is not required,
37
+ library authors are strongly advised to make use of it. The string is interpreted
38
+ as plain unformatted text (for now) so that rustdoc can include it in the item's
39
+ documentation without messing up the formatting.
41
40
42
41
On use of a * deprecated* item, ` rustc ` will ` warn ` of the deprecation. Note
43
42
that during Cargo builds, warnings on dependencies get silenced. While this has
@@ -51,7 +50,7 @@ to warn on use of deprecated items in library crates, however this is outside
51
50
the scope of this RFC.
52
51
53
52
` rustdoc ` will show deprecation on items, with a ` [deprecated] ` box that may
54
- optionally show the version and reason where available.
53
+ optionally show the version and note where available.
55
54
56
55
The language reference will be extended to describe this feature as outlined
57
56
in this RFC. Authors shall be advised to leave their users enough time to react
@@ -74,16 +73,16 @@ prefix to the `Foo` type:
74
73
```
75
74
extern crate rust_foo;
76
75
77
- #[deprecated(since = "0.2.1", use="rust_foo::Foo",
78
- reason ="The rust_foo version is more advanced, and this crates' will likely be discontinued")]
76
+ #[deprecated(since = "0.2.1",
77
+ note ="The rust_foo version is more advanced, and this crate's will likely be discontinued")]
79
78
struct Foo { .. }
80
79
```
81
80
82
81
Users of her crate will see the following once they ` cargo update ` and ` build ` :
83
82
84
83
```
85
84
src/foo_use.rs:27:5: 27:8 warning: Foo is marked deprecated as of version 0.2.1
86
- src/foo_use.rs:27:5: 27:8 note: The rust_foo version is more advanced, and this crates' will likely be discontinued
85
+ src/foo_use.rs:27:5: 27:8 note: The rust_foo version is more advanced, and this crate's will likely be discontinued
87
86
```
88
87
89
88
Rust-clippy will likely gain more sophisticated checks for deprecation:
@@ -108,7 +107,7 @@ deprecation checks.
108
107
* make the ` since ` field required and check that it's a single version
109
108
* require either ` reason ` or ` use ` be present
110
109
* ` reason ` could include markdown formatting
111
- * rename the ` reason ` field to ` note ` to clarify it's broader usage.
110
+ * rename the ` reason ` field to ` note ` to clarify its broader usage. ( ** done! ** )
112
111
* add a ` note ` field and make ` reason ` a field with specific meaning, perhaps
113
112
even predefine a number of valid reason strings, as JEP277 currently does
114
113
* Add a ` use ` field containing a plain text of what to use instead
0 commit comments