Skip to content

Commit d4d3d97

Browse files
authored
Rollup merge of #64763 - GuillaumeGomez:long-err-explanation-E0734, r=estebank
Add E0734 and its long explanation Part of #61137
2 parents f4fc2e6 + ecfe92f commit d4d3d97

9 files changed

+59
-32
lines changed

src/librustc/error_codes.rs

+17
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,23 @@ Examples of erroneous code:
22172217
static X: u32 = 42;
22182218
```
22192219
"##,
2220+
2221+
E0734: r##"
2222+
A stability attribute has been used outside of the standard library.
2223+
2224+
Erroneous code examples:
2225+
2226+
```compile_fail,E0734
2227+
#[rustc_deprecated(since = "b", reason = "text")] // invalid
2228+
#[stable(feature = "a", since = "b")] // invalid
2229+
#[unstable(feature = "b", issue = "0")] // invalid
2230+
fn foo(){}
2231+
```
2232+
2233+
These attributes are meant to only be used by the standard library and are
2234+
rejected in your own crates.
2235+
"##,
2236+
22202237
;
22212238
// E0006, // merged with E0005
22222239
// E0101, // replaced with E0282

src/librustc/middle/stability.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
199199
let name = attr.name_or_empty();
200200
if [sym::unstable, sym::stable, sym::rustc_deprecated].contains(&name) {
201201
attr::mark_used(attr);
202-
self.tcx.sess.span_err(attr.span, "stability attributes may not be used \
203-
outside of the standard library");
202+
struct_span_err!(
203+
self.tcx.sess,
204+
attr.span,
205+
E0734,
206+
"stability attributes may not be used outside of the standard library",
207+
).emit();
204208
}
205209
}
206210

Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
1-
error: stability attributes may not be used outside of the standard library
1+
error[E0734]: stability attributes may not be used outside of the standard library
22
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:7:1
33
|
44
LL | #![rustc_deprecated()]
55
| ^^^^^^^^^^^^^^^^^^^^^^
66

7-
error: stability attributes may not be used outside of the standard library
7+
error[E0734]: stability attributes may not be used outside of the standard library
88
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:10:1
99
|
1010
LL | #[rustc_deprecated()]
1111
| ^^^^^^^^^^^^^^^^^^^^^
1212

13-
error: stability attributes may not be used outside of the standard library
13+
error[E0734]: stability attributes may not be used outside of the standard library
1414
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:13:17
1515
|
1616
LL | mod inner { #![rustc_deprecated()] }
1717
| ^^^^^^^^^^^^^^^^^^^^^^
1818

19-
error: stability attributes may not be used outside of the standard library
19+
error[E0734]: stability attributes may not be used outside of the standard library
2020
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:16:5
2121
|
2222
LL | #[rustc_deprecated()] fn f() { }
2323
| ^^^^^^^^^^^^^^^^^^^^^
2424

25-
error: stability attributes may not be used outside of the standard library
25+
error[E0734]: stability attributes may not be used outside of the standard library
2626
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:19:5
2727
|
2828
LL | #[rustc_deprecated()] struct S;
2929
| ^^^^^^^^^^^^^^^^^^^^^
3030

31-
error: stability attributes may not be used outside of the standard library
31+
error[E0734]: stability attributes may not be used outside of the standard library
3232
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:22:5
3333
|
3434
LL | #[rustc_deprecated()] type T = S;
3535
| ^^^^^^^^^^^^^^^^^^^^^
3636

37-
error: stability attributes may not be used outside of the standard library
37+
error[E0734]: stability attributes may not be used outside of the standard library
3838
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:25:5
3939
|
4040
LL | #[rustc_deprecated()] impl S { }
4141
| ^^^^^^^^^^^^^^^^^^^^^
4242

4343
error: aborting due to 7 previous errors
4444

45+
For more information about this error, try `rustc --explain E0734`.
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
1-
error: stability attributes may not be used outside of the standard library
1+
error[E0734]: stability attributes may not be used outside of the standard library
22
--> $DIR/issue-43106-gating-of-stable.rs:7:1
33
|
44
LL | #![stable()]
55
| ^^^^^^^^^^^^
66

7-
error: stability attributes may not be used outside of the standard library
7+
error[E0734]: stability attributes may not be used outside of the standard library
88
--> $DIR/issue-43106-gating-of-stable.rs:10:1
99
|
1010
LL | #[stable()]
1111
| ^^^^^^^^^^^
1212

13-
error: stability attributes may not be used outside of the standard library
13+
error[E0734]: stability attributes may not be used outside of the standard library
1414
--> $DIR/issue-43106-gating-of-stable.rs:13:17
1515
|
1616
LL | mod inner { #![stable()] }
1717
| ^^^^^^^^^^^^
1818

19-
error: stability attributes may not be used outside of the standard library
19+
error[E0734]: stability attributes may not be used outside of the standard library
2020
--> $DIR/issue-43106-gating-of-stable.rs:16:5
2121
|
2222
LL | #[stable()] fn f() { }
2323
| ^^^^^^^^^^^
2424

25-
error: stability attributes may not be used outside of the standard library
25+
error[E0734]: stability attributes may not be used outside of the standard library
2626
--> $DIR/issue-43106-gating-of-stable.rs:19:5
2727
|
2828
LL | #[stable()] struct S;
2929
| ^^^^^^^^^^^
3030

31-
error: stability attributes may not be used outside of the standard library
31+
error[E0734]: stability attributes may not be used outside of the standard library
3232
--> $DIR/issue-43106-gating-of-stable.rs:22:5
3333
|
3434
LL | #[stable()] type T = S;
3535
| ^^^^^^^^^^^
3636

37-
error: stability attributes may not be used outside of the standard library
37+
error[E0734]: stability attributes may not be used outside of the standard library
3838
--> $DIR/issue-43106-gating-of-stable.rs:25:5
3939
|
4040
LL | #[stable()] impl S { }
4141
| ^^^^^^^^^^^
4242

4343
error: aborting due to 7 previous errors
4444

45+
For more information about this error, try `rustc --explain E0734`.
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
1-
error: stability attributes may not be used outside of the standard library
1+
error[E0734]: stability attributes may not be used outside of the standard library
22
--> $DIR/issue-43106-gating-of-unstable.rs:7:1
33
|
44
LL | #![unstable()]
55
| ^^^^^^^^^^^^^^
66

7-
error: stability attributes may not be used outside of the standard library
7+
error[E0734]: stability attributes may not be used outside of the standard library
88
--> $DIR/issue-43106-gating-of-unstable.rs:10:1
99
|
1010
LL | #[unstable()]
1111
| ^^^^^^^^^^^^^
1212

13-
error: stability attributes may not be used outside of the standard library
13+
error[E0734]: stability attributes may not be used outside of the standard library
1414
--> $DIR/issue-43106-gating-of-unstable.rs:13:17
1515
|
1616
LL | mod inner { #![unstable()] }
1717
| ^^^^^^^^^^^^^^
1818

19-
error: stability attributes may not be used outside of the standard library
19+
error[E0734]: stability attributes may not be used outside of the standard library
2020
--> $DIR/issue-43106-gating-of-unstable.rs:16:5
2121
|
2222
LL | #[unstable()] fn f() { }
2323
| ^^^^^^^^^^^^^
2424

25-
error: stability attributes may not be used outside of the standard library
25+
error[E0734]: stability attributes may not be used outside of the standard library
2626
--> $DIR/issue-43106-gating-of-unstable.rs:19:5
2727
|
2828
LL | #[unstable()] struct S;
2929
| ^^^^^^^^^^^^^
3030

31-
error: stability attributes may not be used outside of the standard library
31+
error[E0734]: stability attributes may not be used outside of the standard library
3232
--> $DIR/issue-43106-gating-of-unstable.rs:22:5
3333
|
3434
LL | #[unstable()] type T = S;
3535
| ^^^^^^^^^^^^^
3636

37-
error: stability attributes may not be used outside of the standard library
37+
error[E0734]: stability attributes may not be used outside of the standard library
3838
--> $DIR/issue-43106-gating-of-unstable.rs:25:5
3939
|
4040
LL | #[unstable()] impl S { }
4141
| ^^^^^^^^^^^^^
4242

4343
error: aborting due to 7 previous errors
4444

45+
For more information about this error, try `rustc --explain E0734`.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
error: stability attributes may not be used outside of the standard library
1+
error[E0734]: stability attributes may not be used outside of the standard library
22
--> $DIR/feature-gate-staged_api.rs:1:1
33
|
44
LL | #![stable(feature = "a", since = "b")]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

7-
error: stability attributes may not be used outside of the standard library
7+
error[E0734]: stability attributes may not be used outside of the standard library
88
--> $DIR/feature-gate-staged_api.rs:8:1
99
|
1010
LL | #[stable(feature = "a", since = "b")]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: aborting due to 2 previous errors
1414

15+
For more information about this error, try `rustc --explain E0734`.
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
error: stability attributes may not be used outside of the standard library
1+
error[E0734]: stability attributes may not be used outside of the standard library
22
--> $DIR/stability-attribute-non-staged-force-unstable.rs:3:1
33
|
44
LL | #[unstable()]
55
| ^^^^^^^^^^^^^
66

7-
error: stability attributes may not be used outside of the standard library
7+
error[E0734]: stability attributes may not be used outside of the standard library
88
--> $DIR/stability-attribute-non-staged-force-unstable.rs:4:1
99
|
1010
LL | #[stable()]
1111
| ^^^^^^^^^^^
1212

13-
error: stability attributes may not be used outside of the standard library
13+
error[E0734]: stability attributes may not be used outside of the standard library
1414
--> $DIR/stability-attribute-non-staged-force-unstable.rs:5:1
1515
|
1616
LL | #[rustc_deprecated()]
1717
| ^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: aborting due to 3 previous errors
2020

21+
For more information about this error, try `rustc --explain E0734`.
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
error: stability attributes may not be used outside of the standard library
1+
error[E0734]: stability attributes may not be used outside of the standard library
22
--> $DIR/stability-attribute-non-staged.rs:1:1
33
|
44
LL | #[unstable()]
55
| ^^^^^^^^^^^^^
66

7-
error: stability attributes may not be used outside of the standard library
7+
error[E0734]: stability attributes may not be used outside of the standard library
88
--> $DIR/stability-attribute-non-staged.rs:2:1
99
|
1010
LL | #[stable()]
1111
| ^^^^^^^^^^^
1212

13-
error: stability attributes may not be used outside of the standard library
13+
error[E0734]: stability attributes may not be used outside of the standard library
1414
--> $DIR/stability-attribute-non-staged.rs:3:1
1515
|
1616
LL | #[rustc_deprecated()]
1717
| ^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: aborting due to 3 previous errors
2020

21+
For more information about this error, try `rustc --explain E0734`.

src/tools/tidy/src/features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ fn map_lib_features(base_src_path: &Path,
384384
let file = entry.path();
385385
let filename = file.file_name().unwrap().to_string_lossy();
386386
if !filename.ends_with(".rs") || filename == "features.rs" ||
387-
filename == "diagnostic_list.rs" {
387+
filename == "diagnostic_list.rs" || filename == "error_codes.rs" {
388388
return;
389389
}
390390

0 commit comments

Comments
 (0)