Skip to content

Commit e928e94

Browse files
committed
Auto merge of #60046 - euclio:missing-error-code-descriptions, r=estebank
hide `--explain` hint if error has no extended info Fixes #59848. r? @estebank
2 parents 5d20ff4 + b6f148c commit e928e94

File tree

833 files changed

+563
-936
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

833 files changed

+563
-936
lines changed

src/librustc_errors/lib.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub use emitter::ColorConfig;
1616
use Level::*;
1717

1818
use emitter::{Emitter, EmitterWriter};
19+
use registry::Registry;
1920

2021
use rustc_data_structures::sync::{self, Lrc, Lock, AtomicUsize, AtomicBool, SeqCst};
2122
use rustc_data_structures::fx::FxHashSet;
@@ -651,7 +652,7 @@ impl Handler {
651652
self.err_count() > 0
652653
}
653654

654-
pub fn print_error_count(&self) {
655+
pub fn print_error_count(&self, registry: &Registry) {
655656
let s = match self.err_count() {
656657
0 => return,
657658
1 => "aborting due to previous error".to_string(),
@@ -666,19 +667,22 @@ impl Handler {
666667
let can_show_explain = self.emitter.borrow().should_show_explain();
667668
let are_there_diagnostics = !self.emitted_diagnostic_codes.borrow().is_empty();
668669
if can_show_explain && are_there_diagnostics {
669-
let mut error_codes =
670-
self.emitted_diagnostic_codes.borrow()
671-
.iter()
672-
.filter_map(|x| match *x {
673-
DiagnosticId::Error(ref s) => Some(s.clone()),
674-
_ => None,
675-
})
676-
.collect::<Vec<_>>();
670+
let mut error_codes = self
671+
.emitted_diagnostic_codes
672+
.borrow()
673+
.iter()
674+
.filter_map(|x| match &x {
675+
DiagnosticId::Error(s) if registry.find_description(s).is_some() => {
676+
Some(s.clone())
677+
}
678+
_ => None,
679+
})
680+
.collect::<Vec<_>>();
677681
if !error_codes.is_empty() {
678682
error_codes.sort();
679683
if error_codes.len() > 1 {
680684
let limit = if error_codes.len() > 9 { 9 } else { error_codes.len() };
681-
self.failure(&format!("Some errors occurred: {}{}",
685+
self.failure(&format!("Some errors have detailed explanations: {}{}",
682686
error_codes[..limit].join(", "),
683687
if error_codes.len() > 9 { "..." } else { "." }));
684688
self.failure(&format!("For more information about an error, try \

src/librustc_interface/interface.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ where
111111
crate_name: config.crate_name,
112112
};
113113

114-
let _sess_abort_error = OnDrop(|| compiler.sess.diagnostic().print_error_count());
114+
let _sess_abort_error = OnDrop(|| {
115+
compiler.sess.diagnostic().print_error_count(&util::diagnostics_registry());
116+
});
115117

116118
if compiler.sess.profile_queries() {
117119
profile::begin(&compiler.sess);

src/test/ui-fulldeps/hash-stable-is-unstable.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ LL | #[derive(HashStable)]
4949

5050
error: aborting due to 6 previous errors
5151

52-
Some errors occurred: E0601, E0658.
52+
Some errors have detailed explanations: E0601, E0658.
5353
For more information about an error, try `rustc --explain E0601`.

src/test/ui-fulldeps/macro-crate-rlib.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | #![plugin(rlib_crate_test)]
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0457`.

src/test/ui/E0594.ast.nll.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | NUM = 20;
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0594`.

src/test/ui/E0594.ast.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | NUM = 20;
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0594`.

src/test/ui/E0594.mir.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | NUM = 20;
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0594`.

src/test/ui/E0660.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ LL | asm!("nop" "nop" : "=r"(a));
1212

1313
error: aborting due to 2 previous errors
1414

15-
For more information about this error, try `rustc --explain E0660`.

src/test/ui/E0661.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | asm!("nop" : "r"(a));
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0661`.

src/test/ui/E0662.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | : "=test"("a")
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0662`.

src/test/ui/E0663.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | : "+test"("a")
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0663`.

src/test/ui/E0664.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | : "{eax}"
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0664`.

src/test/ui/E0665.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | #[derive(Default)]
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0665`.

src/test/ui/anonymous-higher-ranked-lifetime.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,3 @@ LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<Fn(&())>, &'t0 (), fn(&(), &()
308308

309309
error: aborting due to 22 previous errors
310310

311-
For more information about this error, try `rustc --explain E0631`.

src/test/ui/asm/asm-bad-clobber.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | asm!("xor %eax, %eax" : : : "{eax}");
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0664`.

src/test/ui/asm/asm-in-bad-modifier.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,3 @@ LL | asm!("mov $1, $0" : "=r"(y) : "+r"(5));
1212

1313
error: aborting due to 2 previous errors
1414

15-
Some errors occurred: E0662, E0663.
16-
For more information about an error, try `rustc --explain E0662`.

src/test/ui/asm/asm-out-no-modifier.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | asm!("mov $1, $0" : "r"(x) : "r"(5));
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0661`.

src/test/ui/associated-path-shl.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ LL | let 0 ..= <<A>::B>::C;
3939

4040
error: aborting due to 6 previous errors
4141

42-
Some errors occurred: E0029, E0412.
42+
Some errors have detailed explanations: E0029, E0412.
4343
For more information about an error, try `rustc --explain E0029`.

src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ LL | fn paint<C:BoxCar>(c: C, d: C::Color) {
4545

4646
error: aborting due to 4 previous errors
4747

48-
Some errors occurred: E0191, E0221.
48+
Some errors have detailed explanations: E0191, E0221.
4949
For more information about an error, try `rustc --explain E0191`.

src/test/ui/associated-types/associated-types-eq-3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ LL | baz(&a);
3333

3434
error: aborting due to 3 previous errors
3535

36-
Some errors occurred: E0271, E0308.
36+
Some errors have detailed explanations: E0271, E0308.
3737
For more information about an error, try `rustc --explain E0271`.

src/test/ui/associated-types/associated-types-eq-hr.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@ LL | | }
122122

123123
error: aborting due to 7 previous errors
124124

125-
Some errors occurred: E0271, E0277.
125+
Some errors have detailed explanations: E0271, E0277.
126126
For more information about an error, try `rustc --explain E0271`.

src/test/ui/associated-types/associated-types-overridden-binding.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ LL | trait Foo: Iterator<Item = i32> {}
1212

1313
error: aborting due to previous error
1414

15-
For more information about this error, try `rustc --explain E0284`.

src/test/ui/associated-types/associated-types-path-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ LL | pub fn f2<T: Foo + Bar>(a: T, x: T::A) {}
1818

1919
error: aborting due to 2 previous errors
2020

21-
Some errors occurred: E0220, E0221.
21+
Some errors have detailed explanations: E0220, E0221.
2222
For more information about an error, try `rustc --explain E0220`.

src/test/ui/associated-types/associated-types-path-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ LL | let _: i32 = f2(2i32);
4848

4949
error: aborting due to 6 previous errors
5050

51-
Some errors occurred: E0277, E0308.
51+
Some errors have detailed explanations: E0277, E0308.
5252
For more information about an error, try `rustc --explain E0277`.

src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ LL | let z: I::A = if cond { x } else { y };
1111

1212
error: aborting due to previous error
1313

14-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | x: I::A)
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0212`.

src/test/ui/associated-types/associated-types-project-from-hrtb-in-struct.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | field: I::A
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0212`.

src/test/ui/associated-types/associated-types-project-from-hrtb-in-trait-method.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | fn some_method(&self, arg: I::A);
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0212`.

src/test/ui/associated-types/associated-types-subtyping-1.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ LL | let _c: <T as Trait<'a>>::Type = b;
1818

1919
error: aborting due to 2 previous errors
2020

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

src/test/ui/associated-types/associated-types-unconstrained.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | let x: isize = Foo::bar();
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0284`.

src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ LL | (a, b)
2222

2323
error: aborting due to 2 previous errors
2424

25-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ LL | bar(foo, x)
2323

2424
error: aborting due to previous error
2525

26-
For more information about this error, try `rustc --explain E0495`.

src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ LL | let b = bar(foo, x);
2121

2222
error: aborting due to 2 previous errors
2323

24-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ LL | let b = bar(f, y);
1111

1212
error: aborting due to previous error
1313

14-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
1919

2020
error: aborting due to previous error
2121

22-
For more information about this error, try `rustc --explain E0495`.

src/test/ui/augmented-assignments.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ LL | y
1818

1919
error: aborting due to 2 previous errors
2020

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

src/test/ui/augmented-assignments.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ LL | x;
2020

2121
error: aborting due to 2 previous errors
2222

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

src/test/ui/auto-trait-validation.stderr

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ LL | auto trait MyTrait { fn foo() {} }
1818

1919
error: aborting due to 3 previous errors
2020

21-
Some errors occurred: E0380, E0567, E0568.
22-
For more information about an error, try `rustc --explain E0380`.
21+
For more information about this error, try `rustc --explain E0380`.

src/test/ui/await-keyword/2018-edition-error.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ LL | match await { await => () }
3636

3737
error: aborting due to 6 previous errors
3838

39-
For more information about this error, try `rustc --explain E0721`.

src/test/ui/await-keyword/post_expansion_error.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ LL | await!()
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0721`.

src/test/ui/bad/bad-env-capture.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ LL | fn bar() { log(debug, x); }
2020

2121
error: aborting due to 3 previous errors
2222

23-
Some errors occurred: E0425, E0434.
23+
Some errors have detailed explanations: E0425, E0434.
2424
For more information about an error, try `rustc --explain E0425`.

src/test/ui/bad/bad-env-capture2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ LL | fn bar() { log(debug, x); }
2020

2121
error: aborting due to 3 previous errors
2222

23-
Some errors occurred: E0425, E0434.
23+
Some errors have detailed explanations: E0425, E0434.
2424
For more information about an error, try `rustc --explain E0425`.

src/test/ui/bad/bad-env-capture3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ LL | fn bar() { log(debug, x); }
2020

2121
error: aborting due to 3 previous errors
2222

23-
Some errors occurred: E0425, E0434.
23+
Some errors have detailed explanations: E0425, E0434.
2424
For more information about an error, try `rustc --explain E0425`.

src/test/ui/bad/bad-expr-lhs.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ LL | None = Some(3);
3030

3131
error: aborting due to 5 previous errors
3232

33-
Some errors occurred: E0067, E0070.
33+
Some errors have detailed explanations: E0067, E0070.
3434
For more information about an error, try `rustc --explain E0067`.

src/test/ui/bad/bad-expr-path.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ LL | fn main(arguments: Vec<String>) {
2727

2828
error: aborting due to 4 previous errors
2929

30-
Some errors occurred: E0425, E0580.
30+
Some errors have detailed explanations: E0425, E0580.
3131
For more information about an error, try `rustc --explain E0425`.

src/test/ui/bad/bad-expr-path2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ LL | fn main(arguments: Vec<String>) {
2727

2828
error: aborting due to 4 previous errors
2929

30-
Some errors occurred: E0423, E0425, E0580.
30+
Some errors have detailed explanations: E0423, E0425, E0580.
3131
For more information about an error, try `rustc --explain E0423`.

src/test/ui/bad/bad-extern-link-attrs.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ LL | #[link(name = "foo", kind = "bar")]
2020

2121
error: aborting due to 3 previous errors
2222

23-
Some errors occurred: E0454, E0458, E0459.
23+
Some errors have detailed explanations: E0454, E0458, E0459.
2424
For more information about an error, try `rustc --explain E0454`.

src/test/ui/bad/bad-intrinsic-monomorphization.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ LL | simd_add(a, b)
1818

1919
error: aborting due to 3 previous errors
2020

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

src/test/ui/bad/bad-sized.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ LL | let x: Vec<Trait + Sized> = Vec::new();
2626

2727
error: aborting due to 3 previous errors
2828

29-
Some errors occurred: E0225, E0277.
29+
Some errors have detailed explanations: E0225, E0277.
3030
For more information about an error, try `rustc --explain E0225`.

src/test/ui/binop/binop-move-semantics.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@ LL | | &mut f;
9191

9292
error: aborting due to 8 previous errors
9393

94-
Some errors occurred: E0382, E0502, E0505, E0507.
94+
Some errors have detailed explanations: E0382, E0502, E0505, E0507.
9595
For more information about an error, try `rustc --explain E0382`.

src/test/ui/binop/binop-move-semantics.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ LL | &mut f;
7676

7777
error: aborting due to 8 previous errors
7878

79-
Some errors occurred: E0382, E0502, E0505, E0507.
79+
Some errors have detailed explanations: E0382, E0502, E0505, E0507.
8080
For more information about an error, try `rustc --explain E0382`.

src/test/ui/block-result/issue-20862.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ LL | let x = foo(5)(2);
2525

2626
error: aborting due to 2 previous errors
2727

28-
Some errors occurred: E0308, E0618.
28+
Some errors have detailed explanations: E0308, E0618.
2929
For more information about an error, try `rustc --explain E0308`.

src/test/ui/block-result/issue-22645.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ LL | b + 3
2222

2323
error: aborting due to 2 previous errors
2424

25-
Some errors occurred: E0277, E0308.
25+
Some errors have detailed explanations: E0277, E0308.
2626
For more information about an error, try `rustc --explain E0277`.

src/test/ui/borrowck/borrow-immutable-upvar-mutation.nll.stderr

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,4 @@ LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); })
7272

7373
error: aborting due to 6 previous errors
7474

75-
Some errors occurred: E0594, E0596.
76-
For more information about an error, try `rustc --explain E0594`.
75+
For more information about this error, try `rustc --explain E0596`.

src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,5 @@ LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); })
7474

7575
error: aborting due to 6 previous errors
7676

77-
Some errors occurred: E0387, E0594, E0596.
77+
Some errors have detailed explanations: E0387, E0596.
7878
For more information about an error, try `rustc --explain E0387`.

src/test/ui/borrowck/borrow-tuple-fields.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ LL | a.use_mut();
6161

6262
error: aborting due to 6 previous errors
6363

64-
Some errors occurred: E0499, E0502, E0505.
64+
Some errors have detailed explanations: E0499, E0502, E0505.
6565
For more information about an error, try `rustc --explain E0499`.

src/test/ui/borrowck/borrow-tuple-fields.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ LL | }
6060

6161
error: aborting due to 6 previous errors
6262

63-
Some errors occurred: E0499, E0502, E0505.
63+
Some errors have detailed explanations: E0499, E0502, E0505.
6464
For more information about an error, try `rustc --explain E0499`.

src/test/ui/borrowck/borrowck-access-permissions.ast.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ LL | let _y = &mut *foo_ref.f;
4242

4343
error: aborting due to 6 previous errors
4444

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

0 commit comments

Comments
 (0)