1
Fork 0

Update error code docs

This commit is contained in:
Jacob Pratt 2022-04-11 20:41:10 -04:00
parent e46f8b23dd
commit bfdf234fae
No known key found for this signature in database
GPG key ID: B80E19E4662B5AA4
6 changed files with 18 additions and 19 deletions

View file

@ -6,7 +6,7 @@ Erroneous code example:
#![feature(staged_api)] #![feature(staged_api)]
#![stable(since = "1.0.0", feature = "test")] #![stable(since = "1.0.0", feature = "test")]
#[rustc_deprecated(reason)] // error! #[deprecated(note)] // error!
#[unstable(feature = "deprecated_fn", issue = "123")] #[unstable(feature = "deprecated_fn", issue = "123")]
fn deprecated() {} fn deprecated() {}
@ -30,7 +30,7 @@ To fix these issues you need to give required key-value pairs.
#![feature(staged_api)] #![feature(staged_api)]
#![stable(since = "1.0.0", feature = "test")] #![stable(since = "1.0.0", feature = "test")]
#[rustc_deprecated(since = "1.39.0", reason = "reason")] // ok! #[deprecated(since = "1.39.0", note = "reason")] // ok!
#[unstable(feature = "deprecated_fn", issue = "123")] #[unstable(feature = "deprecated_fn", issue = "123")]
fn deprecated() {} fn deprecated() {}

View file

@ -13,8 +13,8 @@ fn _stable_fn() {}
const fn _stable_const_fn() {} const fn _stable_const_fn() {}
#[stable(feature = "_deprecated_fn", since = "0.1.0")] #[stable(feature = "_deprecated_fn", since = "0.1.0")]
#[rustc_deprecated( #[deprecated(
reason = "explanation for deprecation" note = "explanation for deprecation"
)] // invalid )] // invalid
fn _deprecated_fn() {} fn _deprecated_fn() {}
``` ```
@ -32,9 +32,9 @@ fn _stable_fn() {}
const fn _stable_const_fn() {} const fn _stable_const_fn() {}
#[stable(feature = "_deprecated_fn", since = "0.1.0")] #[stable(feature = "_deprecated_fn", since = "0.1.0")]
#[rustc_deprecated( #[deprecated(
since = "1.0.0", since = "1.0.0",
reason = "explanation for deprecation" note = "explanation for deprecation"
)] // ok! )] // ok!
fn _deprecated_fn() {} fn _deprecated_fn() {}
``` ```

View file

@ -1,4 +1,4 @@
The `reason` value is missing in a stability attribute. The `note` value is missing in a stability attribute.
Erroneous code example: Erroneous code example:
@ -7,22 +7,22 @@ Erroneous code example:
#![stable(since = "1.0.0", feature = "test")] #![stable(since = "1.0.0", feature = "test")]
#[stable(since = "0.1.0", feature = "_deprecated_fn")] #[stable(since = "0.1.0", feature = "_deprecated_fn")]
#[rustc_deprecated( #[deprecated(
since = "1.0.0" since = "1.0.0"
)] // invalid )] // invalid
fn _deprecated_fn() {} fn _deprecated_fn() {}
``` ```
To fix this issue, you need to provide the `reason` field. Example: To fix this issue, you need to provide the `note` field. Example:
``` ```
#![feature(staged_api)] #![feature(staged_api)]
#![stable(since = "1.0.0", feature = "test")] #![stable(since = "1.0.0", feature = "test")]
#[stable(since = "0.1.0", feature = "_deprecated_fn")] #[stable(since = "0.1.0", feature = "_deprecated_fn")]
#[rustc_deprecated( #[deprecated(
since = "1.0.0", since = "1.0.0",
reason = "explanation for deprecation" note = "explanation for deprecation"
)] // ok! )] // ok!
fn _deprecated_fn() {} fn _deprecated_fn() {}
``` ```

View file

@ -1,5 +1,5 @@
A `rustc_deprecated` attribute wasn't paired with a `stable`/`unstable` A `deprecated` attribute wasn't paired with a `stable`/`unstable` attribute with
attribute. `#![feature(staged_api)]` enabled.
Erroneous code example: Erroneous code example:
@ -7,9 +7,9 @@ Erroneous code example:
#![feature(staged_api)] #![feature(staged_api)]
#![stable(since = "1.0.0", feature = "test")] #![stable(since = "1.0.0", feature = "test")]
#[rustc_deprecated( #[deprecated(
since = "1.0.1", since = "1.0.1",
reason = "explanation for deprecation" note = "explanation for deprecation"
)] // invalid )] // invalid
fn _deprecated_fn() {} fn _deprecated_fn() {}
``` ```
@ -22,9 +22,9 @@ Example:
#![stable(since = "1.0.0", feature = "test")] #![stable(since = "1.0.0", feature = "test")]
#[stable(since = "1.0.0", feature = "test")] #[stable(since = "1.0.0", feature = "test")]
#[rustc_deprecated( #[deprecated(
since = "1.0.1", since = "1.0.1",
reason = "explanation for deprecation" note = "explanation for deprecation"
)] // ok! )] // ok!
fn _deprecated_fn() {} fn _deprecated_fn() {}
``` ```

View file

@ -3,7 +3,6 @@ A stability attribute has been used outside of the standard library.
Erroneous code example: Erroneous code example:
```compile_fail,E0734 ```compile_fail,E0734
#[rustc_deprecated(since = "b", reason = "text")] // invalid
#[stable(feature = "a", since = "b")] // invalid #[stable(feature = "a", since = "b")] // invalid
#[unstable(feature = "b", issue = "none")] // invalid #[unstable(feature = "b", issue = "none")] // invalid
fn foo(){} fn foo(){}

View file

@ -2206,7 +2206,7 @@ declare_lint! {
/// and then this lint will ensure that the item is no longer used in the /// and then this lint will ensure that the item is no longer used in the
/// standard library. See the [stability documentation] for more details. /// standard library. See the [stability documentation] for more details.
/// ///
/// [stability documentation]: https://rustc-dev-guide.rust-lang.org/stability.html#rustc_deprecated /// [stability documentation]: https://rustc-dev-guide.rust-lang.org/stability.html#deprecated
pub DEPRECATED_IN_FUTURE, pub DEPRECATED_IN_FUTURE,
Allow, Allow,
"detects use of items that will be deprecated in a future version", "detects use of items that will be deprecated in a future version",