Skip to content

Commit ce1dba9

Browse files
authored
Rollup merge of #71808 - unexge:long-err-expl-for-e0539, r=GuillaumeGomez
Add long error explanation for E0539 since this error is similar to [E0551](https://github.com/rust-lang/rust/blob/master/src/librustc_error_codes/error_codes/E0551.md) most of the content was copied from it. part of #61137.
2 parents 44e678b + ef813ca commit ce1dba9

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ E0535: include_str!("./error_codes/E0535.md"),
281281
E0536: include_str!("./error_codes/E0536.md"),
282282
E0537: include_str!("./error_codes/E0537.md"),
283283
E0538: include_str!("./error_codes/E0538.md"),
284+
E0539: include_str!("./error_codes/E0539.md"),
284285
E0541: include_str!("./error_codes/E0541.md"),
285286
E0550: include_str!("./error_codes/E0550.md"),
286287
E0551: include_str!("./error_codes/E0551.md"),
@@ -570,7 +571,6 @@ E0753: include_str!("./error_codes/E0753.md"),
570571
E0521, // borrowed data escapes outside of closure
571572
E0523,
572573
// E0526, // shuffle indices are not constant
573-
E0539, // incorrect meta item
574574
E0540, // multiple rustc_deprecated attributes
575575
E0542, // missing 'since'
576576
E0543, // missing 'reason'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
An invalid meta-item was used inside an attribute.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0539
6+
#![feature(staged_api)]
7+
#![stable(since = "1.0.0", feature = "test")]
8+
9+
#[rustc_deprecated(reason)] // error!
10+
#[unstable(feature = "deprecated_fn", issue = "123")]
11+
fn deprecated() {}
12+
13+
#[unstable(feature = "unstable_struct", issue)] // error!
14+
struct Unstable;
15+
16+
#[rustc_const_unstable(feature)] // error!
17+
const fn unstable_fn() {}
18+
19+
#[stable(feature = "stable_struct", since)] // error!
20+
struct Stable;
21+
22+
#[rustc_const_stable(feature)] // error!
23+
const fn stable_fn() {}
24+
```
25+
26+
Meta items are the key-value pairs inside of an attribute.
27+
To fix these issues you need to give required key-value pairs.
28+
29+
```
30+
#![feature(staged_api)]
31+
#![stable(since = "1.0.0", feature = "test")]
32+
33+
#[rustc_deprecated(since = "1.39.0", reason = "reason")] // ok!
34+
#[unstable(feature = "deprecated_fn", issue = "123")]
35+
fn deprecated() {}
36+
37+
#[unstable(feature = "unstable_struct", issue = "123")] // ok!
38+
struct Unstable;
39+
40+
#[rustc_const_unstable(feature = "unstable_fn", issue = "124")] // ok!
41+
const fn unstable_fn() {}
42+
43+
#[stable(feature = "stable_struct", since = "1.39.0")] // ok!
44+
struct Stable;
45+
46+
#[rustc_const_stable(feature = "stable_fn", since = "1.39.0")] // ok!
47+
const fn stable_fn() {}
48+
```

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,5 @@ LL | fn deprecated_without_unstable_or_stable() { }
108108

109109
error: aborting due to 18 previous errors
110110

111-
For more information about this error, try `rustc --explain E0541`.
111+
Some errors have detailed explanations: E0539, E0541.
112+
For more information about an error, try `rustc --explain E0539`.

0 commit comments

Comments
 (0)