Skip to content

Commit

Permalink
Rollup merge of rust-lang#64763 - GuillaumeGomez:long-err-explanation…
Browse files Browse the repository at this point in the history
…-E0734, r=estebank

Add E0734 and its long explanation

Part of rust-lang#61137
  • Loading branch information
Centril committed Sep 28, 2019
2 parents 05881d0 + ecfe92f commit 01075d8
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 32 deletions.
17 changes: 17 additions & 0 deletions src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,23 @@ Examples of erroneous code:
static X: u32 = 42;
```
"##,

E0734: r##"
A stability attribute has been used outside of the standard library.
Erroneous code examples:
```compile_fail,E0734
#[rustc_deprecated(since = "b", reason = "text")] // invalid
#[stable(feature = "a", since = "b")] // invalid
#[unstable(feature = "b", issue = "0")] // invalid
fn foo(){}
```
These attributes are meant to only be used by the standard library and are
rejected in your own crates.
"##,

;
// E0006, // merged with E0005
// E0101, // replaced with E0282
Expand Down
8 changes: 6 additions & 2 deletions src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,12 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
let name = attr.name_or_empty();
if [sym::unstable, sym::stable, sym::rustc_deprecated].contains(&name) {
attr::mark_used(attr);
self.tcx.sess.span_err(attr.span, "stability attributes may not be used \
outside of the standard library");
struct_span_err!(
self.tcx.sess,
attr.span,
E0734,
"stability attributes may not be used outside of the standard library",
).emit();
}
}

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

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

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

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

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

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

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

error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0734`.
15 changes: 8 additions & 7 deletions src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
error: stability attributes may not be used outside of the standard library
error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:7:1
|
LL | #![stable()]
| ^^^^^^^^^^^^

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

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

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

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

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

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

error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0734`.
15 changes: 8 additions & 7 deletions src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
error: stability attributes may not be used outside of the standard library
error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:7:1
|
LL | #![unstable()]
| ^^^^^^^^^^^^^^

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

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

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

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

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

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

error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0734`.
5 changes: 3 additions & 2 deletions src/test/ui/feature-gates/feature-gate-staged_api.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
error: stability attributes may not be used outside of the standard library
error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/feature-gate-staged_api.rs:1:1
|
LL | #![stable(feature = "a", since = "b")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

error: aborting due to 2 previous errors

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

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

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

error: aborting due to 3 previous errors

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

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

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

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0734`.
2 changes: 1 addition & 1 deletion src/tools/tidy/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ fn map_lib_features(base_src_path: &Path,
let file = entry.path();
let filename = file.file_name().unwrap().to_string_lossy();
if !filename.ends_with(".rs") || filename == "features.rs" ||
filename == "diagnostic_list.rs" {
filename == "diagnostic_list.rs" || filename == "error_codes.rs" {
return;
}

Expand Down

0 comments on commit 01075d8

Please sign in to comment.