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)]
#![stable(since = "1.0.0", feature = "test")]
#[rustc_deprecated(reason)] // error!
#[deprecated(note)] // error!
#[unstable(feature = "deprecated_fn", issue = "123")]
fn deprecated() {}
@ -30,7 +30,7 @@ To fix these issues you need to give required key-value pairs.
#![feature(staged_api)]
#![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")]
fn deprecated() {}

View file

@ -13,8 +13,8 @@ fn _stable_fn() {}
const fn _stable_const_fn() {}
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
#[rustc_deprecated(
reason = "explanation for deprecation"
#[deprecated(
note = "explanation for deprecation"
)] // invalid
fn _deprecated_fn() {}
```
@ -32,9 +32,9 @@ fn _stable_fn() {}
const fn _stable_const_fn() {}
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
#[rustc_deprecated(
#[deprecated(
since = "1.0.0",
reason = "explanation for deprecation"
note = "explanation for deprecation"
)] // ok!
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:
@ -7,22 +7,22 @@ Erroneous code example:
#![stable(since = "1.0.0", feature = "test")]
#[stable(since = "0.1.0", feature = "_deprecated_fn")]
#[rustc_deprecated(
#[deprecated(
since = "1.0.0"
)] // invalid
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)]
#![stable(since = "1.0.0", feature = "test")]
#[stable(since = "0.1.0", feature = "_deprecated_fn")]
#[rustc_deprecated(
#[deprecated(
since = "1.0.0",
reason = "explanation for deprecation"
note = "explanation for deprecation"
)] // ok!
fn _deprecated_fn() {}
```

View file

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

View file

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