about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-09-28 22:12:02 +0200
committerGitHub <noreply@github.com>2019-09-28 22:12:02 +0200
commit01075d8f6b9e2a4f42bc45232d2a20627fc72827 (patch)
tree759bbf31cc235678b99476e98c3fa3f2a7c16d06
parent05881d046eae6eda799a2778ca6bd66477d41b80 (diff)
parentecfe92f75e7f9a6727efb13ea1c666e98de7ca90 (diff)
Rollup merge of #64763 - GuillaumeGomez:long-err-explanation-E0734, r=estebank
Add E0734 and its long explanation

Part of https://github.com/rust-lang/rust/issues/61137
-rw-r--r--src/librustc/error_codes.rs17
-rw-r--r--src/librustc/middle/stability.rs8
-rw-r--r--src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.stderr15
-rw-r--r--src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr15
-rw-r--r--src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr15
-rw-r--r--src/test/ui/feature-gates/feature-gate-staged_api.stderr5
-rw-r--r--src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr7
-rw-r--r--src/test/ui/stability-attribute/stability-attribute-non-staged.stderr7
-rw-r--r--src/tools/tidy/src/features.rs2
9 files changed, 59 insertions, 32 deletions
diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs
index f6564f1fcd4..968b0b9f2f2 100644
--- a/src/librustc/error_codes.rs
+++ b/src/librustc/error_codes.rs
@@ -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
diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs
index 9e053ce4e69..30a88d155f5 100644
--- a/src/librustc/middle/stability.rs
+++ b/src/librustc/middle/stability.rs
@@ -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();
                 }
             }
 
diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.stderr
index 4eead369103..8c6c26f7b2d 100644
--- a/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.stderr
+++ b/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.stderr
@@ -1,40 +1,40 @@
-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 { }
@@ -42,3 +42,4 @@ LL |     #[rustc_deprecated()] impl S { }
 
 error: aborting due to 7 previous errors
 
+For more information about this error, try `rustc --explain E0734`.
diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr
index 03410eabe36..09dabd293ff 100644
--- a/src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr
+++ b/src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr
@@ -1,40 +1,40 @@
-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 { }
@@ -42,3 +42,4 @@ LL |     #[stable()] impl S { }
 
 error: aborting due to 7 previous errors
 
+For more information about this error, try `rustc --explain E0734`.
diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr
index 5952b3836aa..49da2c59580 100644
--- a/src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr
+++ b/src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr
@@ -1,40 +1,40 @@
-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 { }
@@ -42,3 +42,4 @@ LL |     #[unstable()] impl S { }
 
 error: aborting due to 7 previous errors
 
+For more information about this error, try `rustc --explain E0734`.
diff --git a/src/test/ui/feature-gates/feature-gate-staged_api.stderr b/src/test/ui/feature-gates/feature-gate-staged_api.stderr
index f0db47fe8a8..a71d26ce16f 100644
--- a/src/test/ui/feature-gates/feature-gate-staged_api.stderr
+++ b/src/test/ui/feature-gates/feature-gate-staged_api.stderr
@@ -1,10 +1,10 @@
-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")]
@@ -12,3 +12,4 @@ LL | #[stable(feature = "a", since = "b")]
 
 error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0734`.
diff --git a/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr b/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr
index 77f896a86d5..32b0f405d6f 100644
--- a/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr
+++ b/src/test/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr
@@ -1,16 +1,16 @@
-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()]
@@ -18,3 +18,4 @@ LL | #[rustc_deprecated()]
 
 error: aborting due to 3 previous errors
 
+For more information about this error, try `rustc --explain E0734`.
diff --git a/src/test/ui/stability-attribute/stability-attribute-non-staged.stderr b/src/test/ui/stability-attribute/stability-attribute-non-staged.stderr
index e98f789f54c..7648effc480 100644
--- a/src/test/ui/stability-attribute/stability-attribute-non-staged.stderr
+++ b/src/test/ui/stability-attribute/stability-attribute-non-staged.stderr
@@ -1,16 +1,16 @@
-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()]
@@ -18,3 +18,4 @@ LL | #[rustc_deprecated()]
 
 error: aborting due to 3 previous errors
 
+For more information about this error, try `rustc --explain E0734`.
diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs
index 6d38cfc8630..a824546d436 100644
--- a/src/tools/tidy/src/features.rs
+++ b/src/tools/tidy/src/features.rs
@@ -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;
         }