Skip to content

Commit 502ecca

Browse files
committed
Merge pull request #1423 from durka/patch-1
Amend RFC 1270 to describe actual implementation
2 parents 667f316 + b29c3f7 commit 502ecca

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

text/1270-deprecation.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Summary
77

88
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
1010
compiler can then warn on deprecated items, while `rustdoc` can document their
1111
deprecation accordingly.
1212

@@ -32,12 +32,11 @@ possible fields are optional:
3232
deprecating the item, following the semver scheme. Rustc does not know about
3333
versions, thus the content of this field is not checked (but will be by external
3434
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.
4140

4241
On use of a *deprecated* item, `rustc` will `warn` of the deprecation. Note
4342
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
5150
the scope of this RFC.
5251

5352
`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.
5554

5655
The language reference will be extended to describe this feature as outlined
5756
in this RFC. Authors shall be advised to leave their users enough time to react
@@ -74,16 +73,16 @@ prefix to the `Foo` type:
7473
```
7574
extern crate rust_foo;
7675
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")]
7978
struct Foo { .. }
8079
```
8180

8281
Users of her crate will see the following once they `cargo update` and `build`:
8382

8483
```
8584
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
8786
```
8887

8988
Rust-clippy will likely gain more sophisticated checks for deprecation:
@@ -108,7 +107,7 @@ deprecation checks.
108107
* make the `since` field required and check that it's a single version
109108
* require either `reason` or `use` be present
110109
* `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!**)
112111
* add a `note` field and make `reason` a field with specific meaning, perhaps
113112
even predefine a number of valid reason strings, as JEP277 currently does
114113
* Add a `use` field containing a plain text of what to use instead

0 commit comments

Comments
 (0)