about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-02-24 15:48:53 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2018-02-25 12:15:05 +0100
commit16fb6b082da3c9e8805c86ef56ccfb44adb397a9 (patch)
tree3badba265d9f902a42224c78832f8fe2d12f42df /src
parent5747fd6611a77d297d9559f2365a554bd3dd6610 (diff)
downloadrust-16fb6b082da3c9e8805c86ef56ccfb44adb397a9.tar.gz
rust-16fb6b082da3c9e8805c86ef56ccfb44adb397a9.zip
Reduce error codes length when too much are thrown
Diffstat (limited to 'src')
-rw-r--r--src/librustc_errors/emitter.rs7
-rw-r--r--src/test/ui-fulldeps/custom-derive/issue-36935.stderr2
-rw-r--r--src/test/ui-fulldeps/proc-macro/load-panic.stderr2
-rw-r--r--src/test/ui/error-festival.rs53
-rw-r--r--src/test/ui/error-festival.stderr76
-rw-r--r--src/test/ui/mismatched_types/closure-arg-count-expected-type-issue-47244.stderr1
-rw-r--r--src/test/ui/span/issue-42234-unknown-receiver-type.stderr2
7 files changed, 136 insertions, 7 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index 18900de9733..86e77d404ff 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -122,9 +122,12 @@ impl Drop for EmitterWriter {
             let mut error_codes = self.error_codes.clone().into_iter().collect::<Vec<_>>();
             error_codes.sort();
             if error_codes.len() > 1 {
+                let limit = if error_codes.len() > 9 { 9 } else { error_codes.len() };
                 writeln!(self.dst,
-                         "You've got a few errors: {}",
-                         error_codes.join(", ")).expect("failed to give tips...");
+                         "You've got a few errors: {}{}",
+                         error_codes[..limit].join(", "),
+                         if error_codes.len() > 9 { "..." } else { "" }
+                        ).expect("failed to give tips...");
                 writeln!(self.dst,
                          "If you want more information on an error, try using \
                           \"rustc --explain {}\"",
diff --git a/src/test/ui-fulldeps/custom-derive/issue-36935.stderr b/src/test/ui-fulldeps/custom-derive/issue-36935.stderr
index 91e9f3055ce..55848c6553c 100644
--- a/src/test/ui-fulldeps/custom-derive/issue-36935.stderr
+++ b/src/test/ui-fulldeps/custom-derive/issue-36935.stderr
@@ -1,5 +1,3 @@
-thread 'rustc' panicked at 'lolnope', $DIR/auxiliary/plugin.rs:27:5
-note: Run with `RUST_BACKTRACE=1` for a backtrace.
 error: proc-macro derive panicked
   --> $DIR/issue-36935.rs:18:15
    |
diff --git a/src/test/ui-fulldeps/proc-macro/load-panic.stderr b/src/test/ui-fulldeps/proc-macro/load-panic.stderr
index 3e885ffc72c..ab2ab84315a 100644
--- a/src/test/ui-fulldeps/proc-macro/load-panic.stderr
+++ b/src/test/ui-fulldeps/proc-macro/load-panic.stderr
@@ -1,5 +1,3 @@
-thread 'rustc' panicked at 'nope!', $DIR/auxiliary/derive-panic.rs:22:5
-note: Run with `RUST_BACKTRACE=1` for a backtrace.
 error: proc-macro derive panicked
   --> $DIR/load-panic.rs:17:10
    |
diff --git a/src/test/ui/error-festival.rs b/src/test/ui/error-festival.rs
new file mode 100644
index 00000000000..c17e3c878b8
--- /dev/null
+++ b/src/test/ui/error-festival.rs
@@ -0,0 +1,53 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+enum Question {
+    Yes,
+    No,
+}
+
+mod foo {
+    const FOO: u32 = 0;
+}
+
+fn main() {
+    let x = "a";
+    x += 2;
+    //~^ ERROR E0368
+    y = 2;
+    //~^ ERROR E0425
+    x.z();
+    //~^ ERROR E0599
+
+    !Question::Yes;
+    //~^ ERROR E0600
+
+    foo::FOO;
+    //~^ ERROR E0603
+
+    0u32 as char;
+    //~^ ERROR E0604
+
+    let x = 0u8;
+    x as Vec<u8>;
+    //~^ ERROR E0605
+
+    let x = 5;
+    let x_is_nonzero = x as bool;
+    //~^ ERROR E0054
+
+    let x = &0u8;
+    let y: u32 = x as u32;
+    //~^ ERROR E0606
+
+    let v = 0 as *const u8;
+    v as *const [u8];
+    //~^ ERROR E0607
+}
diff --git a/src/test/ui/error-festival.stderr b/src/test/ui/error-festival.stderr
new file mode 100644
index 00000000000..35a35430fe1
--- /dev/null
+++ b/src/test/ui/error-festival.stderr
@@ -0,0 +1,76 @@
+error[E0425]: cannot find value `y` in this scope
+  --> $DIR/error-festival.rs:24:5
+   |
+24 |     y = 2;
+   |     ^ did you mean `x`?
+
+error[E0603]: constant `FOO` is private
+  --> $DIR/error-festival.rs:32:5
+   |
+32 |     foo::FOO;
+   |     ^^^^^^^^
+
+error[E0368]: binary assignment operation `+=` cannot be applied to type `&str`
+  --> $DIR/error-festival.rs:22:5
+   |
+22 |     x += 2;
+   |     -^^^^^
+   |     |
+   |     cannot use `+=` on type `&str`
+
+error[E0599]: no method named `z` found for type `&str` in the current scope
+  --> $DIR/error-festival.rs:26:7
+   |
+26 |     x.z();
+   |       ^
+
+error[E0600]: cannot apply unary operator `!` to type `Question`
+  --> $DIR/error-festival.rs:29:5
+   |
+29 |     !Question::Yes;
+   |     ^^^^^^^^^^^^^^
+
+error[E0604]: only `u8` can be cast as `char`, not `u32`
+  --> $DIR/error-festival.rs:35:5
+   |
+35 |     0u32 as char;
+   |     ^^^^^^^^^^^^
+
+error[E0605]: non-primitive cast: `u8` as `std::vec::Vec<u8>`
+  --> $DIR/error-festival.rs:39:5
+   |
+39 |     x as Vec<u8>;
+   |     ^^^^^^^^^^^^
+   |
+   = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
+
+error[E0054]: cannot cast as `bool`
+  --> $DIR/error-festival.rs:43:24
+   |
+43 |     let x_is_nonzero = x as bool;
+   |                        ^^^^^^^^^ unsupported cast
+   |
+   = help: compare with zero instead
+
+error[E0606]: casting `&u8` as `u32` is invalid
+  --> $DIR/error-festival.rs:47:18
+   |
+47 |     let y: u32 = x as u32;
+   |                  ^^^^^^^^ cannot cast `&u8` as `u32`
+   |
+help: did you mean `*x`?
+  --> $DIR/error-festival.rs:47:18
+   |
+47 |     let y: u32 = x as u32;
+   |                  ^
+
+error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]`
+  --> $DIR/error-festival.rs:51:5
+   |
+51 |     v as *const [u8];
+   |     ^^^^^^^^^^^^^^^^
+
+error: aborting due to 10 previous errors
+
+You've got a few errors: E0054, E0368, E0425, E0599, E0600, E0603, E0604, E0605, E0606...
+If you want more information on an error, try using "rustc --explain E0054"
diff --git a/src/test/ui/mismatched_types/closure-arg-count-expected-type-issue-47244.stderr b/src/test/ui/mismatched_types/closure-arg-count-expected-type-issue-47244.stderr
index 34934b8d195..1ab2a8c872a 100644
--- a/src/test/ui/mismatched_types/closure-arg-count-expected-type-issue-47244.stderr
+++ b/src/test/ui/mismatched_types/closure-arg-count-expected-type-issue-47244.stderr
@@ -12,3 +12,4 @@ help: change the closure to accept a tuple instead of individual arguments
 
 error: aborting due to previous error
 
+If you want more information on this error, try using "rustc --explain E0593"
diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
index d962f2b75c2..567d8f33ed6 100644
--- a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
+++ b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
@@ -15,4 +15,4 @@ error[E0282]: type annotations needed
 
 error: aborting due to 2 previous errors
 
-If you want more information on this error, try using "rustc --explain E0619"
+If you want more information on this error, try using "rustc --explain E0282"