Skip to content

Commit 6c64882

Browse files
Rollup merge of #81830 - jesusprubio:add-log-explanation-e0542, r=GuillaumeGomez
Add long error explanation for E0542 Helps with #61137
2 parents f706216 + 023c6d2 commit 6c64882

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ E0537: include_str!("./error_codes/E0537.md"),
285285
E0538: include_str!("./error_codes/E0538.md"),
286286
E0539: include_str!("./error_codes/E0539.md"),
287287
E0541: include_str!("./error_codes/E0541.md"),
288+
E0542: include_str!("./error_codes/E0542.md"),
288289
E0546: include_str!("./error_codes/E0546.md"),
289290
E0550: include_str!("./error_codes/E0550.md"),
290291
E0551: include_str!("./error_codes/E0551.md"),
@@ -602,7 +603,6 @@ E0781: include_str!("./error_codes/E0781.md"),
602603
E0523,
603604
// E0526, // shuffle indices are not constant
604605
// E0540, // multiple rustc_deprecated attributes
605-
E0542, // missing 'since'
606606
E0543, // missing 'reason'
607607
E0544, // multiple stability levels
608608
E0545, // incorrect 'issue'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
The `since` value is missing in a stability attribute.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0542
6+
#![feature(staged_api)]
7+
#![stable(since = "1.0.0", feature = "test")]
8+
9+
#[stable(feature = "_stable_fn")] // invalid
10+
fn _stable_fn() {}
11+
12+
#[rustc_const_stable(feature = "_stable_const_fn")] // invalid
13+
fn _stable_const_fn() {}
14+
15+
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
16+
#[rustc_deprecated(
17+
reason = "explanation for deprecation"
18+
)] // invalid
19+
fn _deprecated_fn() {}
20+
```
21+
22+
To fix the issue you need to provide the `since` field.
23+
24+
```
25+
#![feature(staged_api)]
26+
#![stable(since = "1.0.0", feature = "test")]
27+
28+
#[stable(feature = "_stable_fn", since = "1.0.0")] // ok!
29+
fn _stable_fn() {}
30+
31+
#[rustc_const_stable(feature = "_stable_const_fn", since = "1.0.0")] // ok!
32+
fn _stable_const_fn() {}
33+
34+
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
35+
#[rustc_deprecated(
36+
since = "1.0.0",
37+
reason = "explanation for deprecation"
38+
)] // ok!
39+
fn _deprecated_fn() {}
40+
```
41+
42+
See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix
43+
of the Book and the [Stability attributes][stability-attributes] section of the
44+
Rustc Dev Guide for more details.
45+
46+
[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
47+
[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html

src/test/ui/stability-attribute/stability-attribute-sanity.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@ LL | #[rustc_deprecated(since = "a", reason = "text")]
116116

117117
error: aborting due to 19 previous errors
118118

119-
Some errors have detailed explanations: E0539, E0541, E0546, E0550.
119+
Some errors have detailed explanations: E0539, E0541, E0542, E0546, E0550.
120120
For more information about an error, try `rustc --explain E0539`.

0 commit comments

Comments
 (0)