Skip to content

Commit

Permalink
hide --explain hint if error has no extended info
Browse files Browse the repository at this point in the history
  • Loading branch information
euclio committed Apr 18, 2019
1 parent e577e49 commit b6f148c
Show file tree
Hide file tree
Showing 833 changed files with 563 additions and 936 deletions.
24 changes: 14 additions & 10 deletions src/librustc_errors/lib.rs
Expand Up @@ -16,6 +16,7 @@ pub use emitter::ColorConfig;
use Level::*;

use emitter::{Emitter, EmitterWriter};
use registry::Registry;

use rustc_data_structures::sync::{self, Lrc, Lock, AtomicUsize, AtomicBool, SeqCst};
use rustc_data_structures::fx::FxHashSet;
Expand Down Expand Up @@ -651,7 +652,7 @@ impl Handler {
self.err_count() > 0
}

pub fn print_error_count(&self) {
pub fn print_error_count(&self, registry: &Registry) {
let s = match self.err_count() {
0 => return,
1 => "aborting due to previous error".to_string(),
Expand All @@ -666,19 +667,22 @@ impl Handler {
let can_show_explain = self.emitter.borrow().should_show_explain();
let are_there_diagnostics = !self.emitted_diagnostic_codes.borrow().is_empty();
if can_show_explain && are_there_diagnostics {
let mut error_codes =
self.emitted_diagnostic_codes.borrow()
.iter()
.filter_map(|x| match *x {
DiagnosticId::Error(ref s) => Some(s.clone()),
_ => None,
})
.collect::<Vec<_>>();
let mut error_codes = self
.emitted_diagnostic_codes
.borrow()
.iter()
.filter_map(|x| match &x {
DiagnosticId::Error(s) if registry.find_description(s).is_some() => {
Some(s.clone())
}
_ => None,
})
.collect::<Vec<_>>();
if !error_codes.is_empty() {
error_codes.sort();
if error_codes.len() > 1 {
let limit = if error_codes.len() > 9 { 9 } else { error_codes.len() };
self.failure(&format!("Some errors occurred: {}{}",
self.failure(&format!("Some errors have detailed explanations: {}{}",
error_codes[..limit].join(", "),
if error_codes.len() > 9 { "..." } else { "." }));
self.failure(&format!("For more information about an error, try \
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_interface/interface.rs
Expand Up @@ -111,7 +111,9 @@ where
crate_name: config.crate_name,
};

let _sess_abort_error = OnDrop(|| compiler.sess.diagnostic().print_error_count());
let _sess_abort_error = OnDrop(|| {
compiler.sess.diagnostic().print_error_count(&util::diagnostics_registry());
});

if compiler.sess.profile_queries() {
profile::begin(&compiler.sess);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/hash-stable-is-unstable.stderr
Expand Up @@ -49,5 +49,5 @@ LL | #[derive(HashStable)]

error: aborting due to 6 previous errors

Some errors occurred: E0601, E0658.
Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.
1 change: 0 additions & 1 deletion src/test/ui-fulldeps/macro-crate-rlib.stderr
Expand Up @@ -6,4 +6,3 @@ LL | #![plugin(rlib_crate_test)]

error: aborting due to previous error

For more information about this error, try `rustc --explain E0457`.
1 change: 0 additions & 1 deletion src/test/ui/E0594.ast.nll.stderr
Expand Up @@ -6,4 +6,3 @@ LL | NUM = 20;

error: aborting due to previous error

For more information about this error, try `rustc --explain E0594`.
1 change: 0 additions & 1 deletion src/test/ui/E0594.ast.stderr
Expand Up @@ -6,4 +6,3 @@ LL | NUM = 20;

error: aborting due to previous error

For more information about this error, try `rustc --explain E0594`.
1 change: 0 additions & 1 deletion src/test/ui/E0594.mir.stderr
Expand Up @@ -6,4 +6,3 @@ LL | NUM = 20;

error: aborting due to previous error

For more information about this error, try `rustc --explain E0594`.
1 change: 0 additions & 1 deletion src/test/ui/E0660.stderr
Expand Up @@ -12,4 +12,3 @@ LL | asm!("nop" "nop" : "=r"(a));

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0660`.
1 change: 0 additions & 1 deletion src/test/ui/E0661.stderr
Expand Up @@ -6,4 +6,3 @@ LL | asm!("nop" : "r"(a));

error: aborting due to previous error

For more information about this error, try `rustc --explain E0661`.
1 change: 0 additions & 1 deletion src/test/ui/E0662.stderr
Expand Up @@ -6,4 +6,3 @@ LL | : "=test"("a")

error: aborting due to previous error

For more information about this error, try `rustc --explain E0662`.
1 change: 0 additions & 1 deletion src/test/ui/E0663.stderr
Expand Up @@ -6,4 +6,3 @@ LL | : "+test"("a")

error: aborting due to previous error

For more information about this error, try `rustc --explain E0663`.
1 change: 0 additions & 1 deletion src/test/ui/E0664.stderr
Expand Up @@ -6,4 +6,3 @@ LL | : "{eax}"

error: aborting due to previous error

For more information about this error, try `rustc --explain E0664`.
1 change: 0 additions & 1 deletion src/test/ui/E0665.stderr
Expand Up @@ -6,4 +6,3 @@ LL | #[derive(Default)]

error: aborting due to previous error

For more information about this error, try `rustc --explain E0665`.
1 change: 0 additions & 1 deletion src/test/ui/anonymous-higher-ranked-lifetime.stderr
Expand Up @@ -308,4 +308,3 @@ LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<Fn(&())>, &'t0 (), fn(&(), &()

error: aborting due to 22 previous errors

For more information about this error, try `rustc --explain E0631`.
1 change: 0 additions & 1 deletion src/test/ui/asm/asm-bad-clobber.stderr
Expand Up @@ -6,4 +6,3 @@ LL | asm!("xor %eax, %eax" : : : "{eax}");

error: aborting due to previous error

For more information about this error, try `rustc --explain E0664`.
2 changes: 0 additions & 2 deletions src/test/ui/asm/asm-in-bad-modifier.stderr
Expand Up @@ -12,5 +12,3 @@ LL | asm!("mov $1, $0" : "=r"(y) : "+r"(5));

error: aborting due to 2 previous errors

Some errors occurred: E0662, E0663.
For more information about an error, try `rustc --explain E0662`.
1 change: 0 additions & 1 deletion src/test/ui/asm/asm-out-no-modifier.stderr
Expand Up @@ -6,4 +6,3 @@ LL | asm!("mov $1, $0" : "r"(x) : "r"(5));

error: aborting due to previous error

For more information about this error, try `rustc --explain E0661`.
2 changes: 1 addition & 1 deletion src/test/ui/associated-path-shl.stderr
Expand Up @@ -39,5 +39,5 @@ LL | let 0 ..= <<A>::B>::C;

error: aborting due to 6 previous errors

Some errors occurred: E0029, E0412.
Some errors have detailed explanations: E0029, E0412.
For more information about an error, try `rustc --explain E0029`.
Expand Up @@ -45,5 +45,5 @@ LL | fn paint<C:BoxCar>(c: C, d: C::Color) {

error: aborting due to 4 previous errors

Some errors occurred: E0191, E0221.
Some errors have detailed explanations: E0191, E0221.
For more information about an error, try `rustc --explain E0191`.
2 changes: 1 addition & 1 deletion src/test/ui/associated-types/associated-types-eq-3.stderr
Expand Up @@ -33,5 +33,5 @@ LL | baz(&a);

error: aborting due to 3 previous errors

Some errors occurred: E0271, E0308.
Some errors have detailed explanations: E0271, E0308.
For more information about an error, try `rustc --explain E0271`.
2 changes: 1 addition & 1 deletion src/test/ui/associated-types/associated-types-eq-hr.stderr
Expand Up @@ -122,5 +122,5 @@ LL | | }

error: aborting due to 7 previous errors

Some errors occurred: E0271, E0277.
Some errors have detailed explanations: E0271, E0277.
For more information about an error, try `rustc --explain E0271`.
Expand Up @@ -12,4 +12,3 @@ LL | trait Foo: Iterator<Item = i32> {}

error: aborting due to previous error

For more information about this error, try `rustc --explain E0284`.
Expand Up @@ -18,5 +18,5 @@ LL | pub fn f2<T: Foo + Bar>(a: T, x: T::A) {}

error: aborting due to 2 previous errors

Some errors occurred: E0220, E0221.
Some errors have detailed explanations: E0220, E0221.
For more information about an error, try `rustc --explain E0220`.
Expand Up @@ -48,5 +48,5 @@ LL | let _: i32 = f2(2i32);

error: aborting due to 6 previous errors

Some errors occurred: E0277, E0308.
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
Expand Up @@ -11,4 +11,3 @@ LL | let z: I::A = if cond { x } else { y };

error: aborting due to previous error

For more information about this error, try `rustc --explain E0623`.
Expand Up @@ -6,4 +6,3 @@ LL | x: I::A)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0212`.
Expand Up @@ -6,4 +6,3 @@ LL | field: I::A

error: aborting due to previous error

For more information about this error, try `rustc --explain E0212`.
Expand Up @@ -6,4 +6,3 @@ LL | fn some_method(&self, arg: I::A);

error: aborting due to previous error

For more information about this error, try `rustc --explain E0212`.
Expand Up @@ -18,4 +18,3 @@ LL | let _c: <T as Trait<'a>>::Type = b;

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0623`.
Expand Up @@ -6,4 +6,3 @@ LL | let x: isize = Foo::bar();

error: aborting due to previous error

For more information about this error, try `rustc --explain E0284`.
Expand Up @@ -22,4 +22,3 @@ LL | (a, b)

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0623`.
Expand Up @@ -23,4 +23,3 @@ LL | bar(foo, x)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0495`.
Expand Up @@ -21,4 +21,3 @@ LL | let b = bar(foo, x);

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0623`.
Expand Up @@ -11,4 +11,3 @@ LL | let b = bar(f, y);

error: aborting due to previous error

For more information about this error, try `rustc --explain E0623`.
Expand Up @@ -19,4 +19,3 @@ LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {

error: aborting due to previous error

For more information about this error, try `rustc --explain E0495`.
2 changes: 1 addition & 1 deletion src/test/ui/augmented-assignments.nll.stderr
Expand Up @@ -18,5 +18,5 @@ LL | y

error: aborting due to 2 previous errors

Some errors occurred: E0505, E0596.
Some errors have detailed explanations: E0505, E0596.
For more information about an error, try `rustc --explain E0505`.
2 changes: 1 addition & 1 deletion src/test/ui/augmented-assignments.stderr
Expand Up @@ -20,5 +20,5 @@ LL | x;

error: aborting due to 2 previous errors

Some errors occurred: E0382, E0596.
Some errors have detailed explanations: E0382, E0596.
For more information about an error, try `rustc --explain E0382`.
3 changes: 1 addition & 2 deletions src/test/ui/auto-trait-validation.stderr
Expand Up @@ -18,5 +18,4 @@ LL | auto trait MyTrait { fn foo() {} }

error: aborting due to 3 previous errors

Some errors occurred: E0380, E0567, E0568.
For more information about an error, try `rustc --explain E0380`.
For more information about this error, try `rustc --explain E0380`.
1 change: 0 additions & 1 deletion src/test/ui/await-keyword/2018-edition-error.stderr
Expand Up @@ -36,4 +36,3 @@ LL | match await { await => () }

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0721`.
1 change: 0 additions & 1 deletion src/test/ui/await-keyword/post_expansion_error.stderr
Expand Up @@ -6,4 +6,3 @@ LL | await!()

error: aborting due to previous error

For more information about this error, try `rustc --explain E0721`.
2 changes: 1 addition & 1 deletion src/test/ui/bad/bad-env-capture.stderr
Expand Up @@ -20,5 +20,5 @@ LL | fn bar() { log(debug, x); }

error: aborting due to 3 previous errors

Some errors occurred: E0425, E0434.
Some errors have detailed explanations: E0425, E0434.
For more information about an error, try `rustc --explain E0425`.
2 changes: 1 addition & 1 deletion src/test/ui/bad/bad-env-capture2.stderr
Expand Up @@ -20,5 +20,5 @@ LL | fn bar() { log(debug, x); }

error: aborting due to 3 previous errors

Some errors occurred: E0425, E0434.
Some errors have detailed explanations: E0425, E0434.
For more information about an error, try `rustc --explain E0425`.
2 changes: 1 addition & 1 deletion src/test/ui/bad/bad-env-capture3.stderr
Expand Up @@ -20,5 +20,5 @@ LL | fn bar() { log(debug, x); }

error: aborting due to 3 previous errors

Some errors occurred: E0425, E0434.
Some errors have detailed explanations: E0425, E0434.
For more information about an error, try `rustc --explain E0425`.
2 changes: 1 addition & 1 deletion src/test/ui/bad/bad-expr-lhs.stderr
Expand Up @@ -30,5 +30,5 @@ LL | None = Some(3);

error: aborting due to 5 previous errors

Some errors occurred: E0067, E0070.
Some errors have detailed explanations: E0067, E0070.
For more information about an error, try `rustc --explain E0067`.
2 changes: 1 addition & 1 deletion src/test/ui/bad/bad-expr-path.stderr
Expand Up @@ -27,5 +27,5 @@ LL | fn main(arguments: Vec<String>) {

error: aborting due to 4 previous errors

Some errors occurred: E0425, E0580.
Some errors have detailed explanations: E0425, E0580.
For more information about an error, try `rustc --explain E0425`.
2 changes: 1 addition & 1 deletion src/test/ui/bad/bad-expr-path2.stderr
Expand Up @@ -27,5 +27,5 @@ LL | fn main(arguments: Vec<String>) {

error: aborting due to 4 previous errors

Some errors occurred: E0423, E0425, E0580.
Some errors have detailed explanations: E0423, E0425, E0580.
For more information about an error, try `rustc --explain E0423`.
2 changes: 1 addition & 1 deletion src/test/ui/bad/bad-extern-link-attrs.stderr
Expand Up @@ -20,5 +20,5 @@ LL | #[link(name = "foo", kind = "bar")]

error: aborting due to 3 previous errors

Some errors occurred: E0454, E0458, E0459.
Some errors have detailed explanations: E0454, E0458, E0459.
For more information about an error, try `rustc --explain E0454`.
1 change: 0 additions & 1 deletion src/test/ui/bad/bad-intrinsic-monomorphization.stderr
Expand Up @@ -18,4 +18,3 @@ LL | simd_add(a, b)

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0511`.
2 changes: 1 addition & 1 deletion src/test/ui/bad/bad-sized.stderr
Expand Up @@ -26,5 +26,5 @@ LL | let x: Vec<Trait + Sized> = Vec::new();

error: aborting due to 3 previous errors

Some errors occurred: E0225, E0277.
Some errors have detailed explanations: E0225, E0277.
For more information about an error, try `rustc --explain E0225`.
2 changes: 1 addition & 1 deletion src/test/ui/binop/binop-move-semantics.nll.stderr
Expand Up @@ -91,5 +91,5 @@ LL | | &mut f;

error: aborting due to 8 previous errors

Some errors occurred: E0382, E0502, E0505, E0507.
Some errors have detailed explanations: E0382, E0502, E0505, E0507.
For more information about an error, try `rustc --explain E0382`.
2 changes: 1 addition & 1 deletion src/test/ui/binop/binop-move-semantics.stderr
Expand Up @@ -76,5 +76,5 @@ LL | &mut f;

error: aborting due to 8 previous errors

Some errors occurred: E0382, E0502, E0505, E0507.
Some errors have detailed explanations: E0382, E0502, E0505, E0507.
For more information about an error, try `rustc --explain E0382`.
2 changes: 1 addition & 1 deletion src/test/ui/block-result/issue-20862.stderr
Expand Up @@ -25,5 +25,5 @@ LL | let x = foo(5)(2);

error: aborting due to 2 previous errors

Some errors occurred: E0308, E0618.
Some errors have detailed explanations: E0308, E0618.
For more information about an error, try `rustc --explain E0308`.
2 changes: 1 addition & 1 deletion src/test/ui/block-result/issue-22645.stderr
Expand Up @@ -22,5 +22,5 @@ LL | b + 3

error: aborting due to 2 previous errors

Some errors occurred: E0277, E0308.
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
Expand Up @@ -72,5 +72,4 @@ LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); })

error: aborting due to 6 previous errors

Some errors occurred: E0594, E0596.
For more information about an error, try `rustc --explain E0594`.
For more information about this error, try `rustc --explain E0596`.
Expand Up @@ -74,5 +74,5 @@ LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); })

error: aborting due to 6 previous errors

Some errors occurred: E0387, E0594, E0596.
Some errors have detailed explanations: E0387, E0596.
For more information about an error, try `rustc --explain E0387`.
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/borrow-tuple-fields.nll.stderr
Expand Up @@ -61,5 +61,5 @@ LL | a.use_mut();

error: aborting due to 6 previous errors

Some errors occurred: E0499, E0502, E0505.
Some errors have detailed explanations: E0499, E0502, E0505.
For more information about an error, try `rustc --explain E0499`.
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/borrow-tuple-fields.stderr
Expand Up @@ -60,5 +60,5 @@ LL | }

error: aborting due to 6 previous errors

Some errors occurred: E0499, E0502, E0505.
Some errors have detailed explanations: E0499, E0502, E0505.
For more information about an error, try `rustc --explain E0499`.
Expand Up @@ -42,5 +42,5 @@ LL | let _y = &mut *foo_ref.f;

error: aborting due to 6 previous errors

Some errors occurred: E0389, E0596.
Some errors have detailed explanations: E0389, E0596.
For more information about an error, try `rustc --explain E0389`.

0 comments on commit b6f148c

Please sign in to comment.