Skip to content

revert #48337 (--explain usage note) #48621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
53 changes: 7 additions & 46 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::io::prelude::*;
use std::io;
use std::rc::Rc;
use term;
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use std::cmp::min;
use unicode_width;

Expand Down Expand Up @@ -109,7 +109,6 @@ pub struct EmitterWriter {
cm: Option<Rc<CodeMapper>>,
short_message: bool,
teach: bool,
error_codes: HashSet<String>,
ui_testing: bool,
}

Expand All @@ -119,33 +118,6 @@ struct FileWithAnnotatedLines {
multiline_depth: usize,
}

impl Drop for EmitterWriter {
fn drop(&mut self) {
if !self.short_message && !self.error_codes.is_empty() {
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[..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 {}\"",
&error_codes[0]).expect("failed to give tips...");
} else {
writeln!(self.dst,
"If you want more information on this error, try using \
\"rustc --explain {}\"",
&error_codes[0]).expect("failed to give tips...");
}
self.dst.flush().expect("failed to emit errors");
}
}
}

impl EmitterWriter {
pub fn stderr(color_config: ColorConfig,
code_map: Option<Rc<CodeMapper>>,
Expand All @@ -159,7 +131,6 @@ impl EmitterWriter {
cm: code_map,
short_message,
teach,
error_codes: HashSet::new(),
ui_testing: false,
}
} else {
Expand All @@ -168,7 +139,6 @@ impl EmitterWriter {
cm: code_map,
short_message,
teach,
error_codes: HashSet::new(),
ui_testing: false,
}
}
Expand All @@ -184,7 +154,6 @@ impl EmitterWriter {
cm: code_map,
short_message,
teach,
error_codes: HashSet::new(),
ui_testing: false,
}
}
Expand Down Expand Up @@ -1025,14 +994,12 @@ impl EmitterWriter {
if primary_span != &&DUMMY_SP {
(cm.lookup_char_pos(primary_span.lo()), cm)
} else {
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message,
&mut self.error_codes)?;
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
return Ok(());
}
} else {
// If we don't have span information, emit and exit
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message,
&mut self.error_codes)?;
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
return Ok(());
};
if let Ok(pos) =
Expand Down Expand Up @@ -1205,8 +1172,7 @@ impl EmitterWriter {
}

// final step: take our styled buffer, render it, then output it
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message,
&mut self.error_codes)?;
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;

Ok(())

Expand Down Expand Up @@ -1294,8 +1260,7 @@ impl EmitterWriter {
let msg = format!("and {} other candidates", suggestions.len() - MAX_SUGGESTIONS);
buffer.puts(row_num, 0, &msg, Style::NoStyle);
}
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message,
&mut self.error_codes)?;
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
}
Ok(())
}
Expand Down Expand Up @@ -1326,7 +1291,7 @@ impl EmitterWriter {
draw_col_separator_no_space(&mut buffer, 0, max_line_num_len + 1);
}
match emit_to_destination(&buffer.render(), level, &mut self.dst,
self.short_message, &mut self.error_codes) {
self.short_message) {
Ok(()) => (),
Err(e) => panic!("failed to emit error: {}", e)
}
Expand Down Expand Up @@ -1419,8 +1384,7 @@ fn overlaps(a1: &Annotation, a2: &Annotation, padding: usize) -> bool {
fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>,
lvl: &Level,
dst: &mut Destination,
short_message: bool,
error_codes: &mut HashSet<String>)
short_message: bool)
-> io::Result<()> {
use lock;

Expand All @@ -1441,9 +1405,6 @@ fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>,
for part in line {
dst.apply_style(lvl.clone(), part.style)?;
write!(dst, "{}", part.text)?;
if !short_message && part.text.len() == 12 && part.text.starts_with("error[E") {
error_codes.insert(part.text[6..11].to_owned());
}
dst.reset_attrs()?;
}
if !short_message {
Expand Down
1 change: 0 additions & 1 deletion src/test/ui-fulldeps/lint-plugin-forbid-attrs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ LL | #[allow(test_lint)]

error: aborting due to 2 previous errors

If you want more information on this error, try using "rustc --explain E0453"
1 change: 0 additions & 1 deletion src/test/ui-fulldeps/proc-macro/signature.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ LL | | }

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0308"
1 change: 0 additions & 1 deletion src/test/ui/anonymous-higher-ranked-lifetime.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,3 @@ LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<Fn(&())>, &'t0 (), fn(&(), &()

error: aborting due to 11 previous errors

If you want more information on this error, try using "rustc --explain E0631"
1 change: 0 additions & 1 deletion src/test/ui/arbitrary-self-types-not-object-safe.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ LL | let x = Box::new(5usize) as Box<Foo>;

error: aborting due to 2 previous errors

If you want more information on this error, try using "rustc --explain E0038"
1 change: 0 additions & 1 deletion src/test/ui/asm-out-assign-imm.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ LL | asm!("mov $1, $0" : "=r"(x) : "r"(5));

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0384"
1 change: 0 additions & 1 deletion src/test/ui/associated-const-impl-wrong-lifetime.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ LL | impl<'a> Foo for &'a () {

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0308"
1 change: 0 additions & 1 deletion src/test/ui/associated-const-impl-wrong-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ LL | const BAR: i32 = -1;

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0326"
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,3 @@ LL | fn paint<C:BoxCar>(c: C, d: C::Color) {

error: aborting due to 4 previous errors

You've got a few errors: E0191, E0221
If you want more information on an error, try using "rustc --explain E0191"
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ LL | r = r + a;

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0277"
1 change: 0 additions & 1 deletion src/test/ui/associated-types-in-ambiguous-context.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ LL | fn grab(&self) -> Grab::Value;

error: aborting due to 3 previous errors

If you want more information on this error, try using "rustc --explain E0223"
1 change: 0 additions & 1 deletion src/test/ui/attr-usage-repr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ LL | enum ESimd { A, B }

error: aborting due to 5 previous errors

If you want more information on this error, try using "rustc --explain E0517"
2 changes: 0 additions & 2 deletions src/test/ui/augmented-assignments.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ LL | x; //~ value moved here

error: aborting due to 2 previous errors

You've got a few errors: E0382, E0596
If you want more information on an error, try using "rustc --explain E0382"
1 change: 0 additions & 1 deletion src/test/ui/binary-op-on-double-ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ LL | x % 2 == 0

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0369"
1 change: 0 additions & 1 deletion src/test/ui/blind-item-item-shadow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ LL | use foo::foo as other_foo;

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0255"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ LL | true //~ ERROR mismatched types

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0308"
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ LL | true //~ ERROR mismatched types

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0308"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ LL | true //~ ERROR mismatched types

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0308"
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ LL | | }

error: aborting due to 2 previous errors

If you want more information on this error, try using "rustc --explain E0308"
1 change: 0 additions & 1 deletion src/test/ui/block-result/issue-11714.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ LL | | }

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0308"
1 change: 0 additions & 1 deletion src/test/ui/block-result/issue-13428.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ LL | | }

error: aborting due to 2 previous errors

If you want more information on this error, try using "rustc --explain E0308"
1 change: 0 additions & 1 deletion src/test/ui/block-result/issue-13624.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ LL | a::Enum::EnumStructVariant { x, y, z } => {

error: aborting due to 2 previous errors

If you want more information on this error, try using "rustc --explain E0308"
2 changes: 0 additions & 2 deletions src/test/ui/block-result/issue-20862.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ LL | let x = foo(5)(2);

error: aborting due to 2 previous errors

You've got a few errors: E0308, E0618
If you want more information on an error, try using "rustc --explain E0308"
2 changes: 0 additions & 2 deletions src/test/ui/block-result/issue-22645.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ LL | b + 3 //~ ERROR E0277

error: aborting due to 2 previous errors

You've got a few errors: E0277, E0308
If you want more information on an error, try using "rustc --explain E0277"
1 change: 0 additions & 1 deletion src/test/ui/block-result/issue-3563.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ LL | || self.b()

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0599"
1 change: 0 additions & 1 deletion src/test/ui/block-result/issue-5500.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ LL | &panic!()

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0308"
1 change: 0 additions & 1 deletion src/test/ui/block-result/unexpected-return-on-unit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ LL | fn bar() -> usize {

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0308"
1 change: 0 additions & 1 deletion src/test/ui/bogus-tag.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ LL | color::hsl(h, s, l) => { println!("hsl"); }

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0599"
2 changes: 0 additions & 2 deletions src/test/ui/borrowck/borrowck-box-insensitivity.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,3 @@ LL | }

error: aborting due to 16 previous errors

You've got a few errors: E0382, E0502, E0503, E0505
If you want more information on an error, try using "rustc --explain E0382"
1 change: 0 additions & 1 deletion src/test/ui/borrowck/borrowck-closures-two-mut.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,3 @@ LL | }

error: aborting due to 10 previous errors

If you want more information on this error, try using "rustc --explain E0499"
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ LL | spawn(move || books.push(4));

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0373"
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ LL | Box::new(move || books.push(4))

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0373"
1 change: 0 additions & 1 deletion src/test/ui/borrowck/borrowck-in-static.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0507"
2 changes: 0 additions & 2 deletions src/test/ui/borrowck/borrowck-move-error-with-note.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,3 @@ LL | n => {

error: aborting due to 3 previous errors

You've got a few errors: E0507, E0509
If you want more information on an error, try using "rustc --explain E0507"
1 change: 0 additions & 1 deletion src/test/ui/borrowck/borrowck-move-out-of-vec-tail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ LL | | Foo { string: b }] => {

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0508"
1 change: 0 additions & 1 deletion src/test/ui/borrowck/borrowck-reinit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ LL | let _ = (1,x); //~ ERROR use of moved value: `x` (Ast)

error: aborting due to 2 previous errors

If you want more information on this error, try using "rustc --explain E0382"
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ LL | };

error: aborting due to 3 previous errors

You've got a few errors: E0499, E0502
If you want more information on an error, try using "rustc --explain E0499"
2 changes: 0 additions & 2 deletions src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,3 @@ LL | let a = vec[0]; //~ ERROR cannot move out

error: aborting due to 8 previous errors

You've got a few errors: E0506, E0508
If you want more information on an error, try using "rustc --explain E0506"
1 change: 0 additions & 1 deletion src/test/ui/borrowck/immutable-arg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ LL | _x = 4;

error: aborting due to 2 previous errors

If you want more information on this error, try using "rustc --explain E0384"
1 change: 0 additions & 1 deletion src/test/ui/borrowck/issue-41962.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ LL | if let Some(thing) = maybe {

error: aborting due to 5 previous errors

If you want more information on this error, try using "rustc --explain E0382"
1 change: 0 additions & 1 deletion src/test/ui/borrowck/mut-borrow-in-loop.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ LL | }

error: aborting due to 3 previous errors

If you want more information on this error, try using "rustc --explain E0499"
1 change: 0 additions & 1 deletion src/test/ui/borrowck/mut-borrow-outside-loop.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ LL | }

error: aborting due to 2 previous errors

If you want more information on this error, try using "rustc --explain E0499"
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,3 @@ LL | fn another_bound<'x: 't>(self, x: Inv<'x>, y: Inv<'t>) {

error: aborting due to 4 previous errors

You've got a few errors: E0195, E0276, E0308
If you want more information on an error, try using "rustc --explain E0195"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ LL | y.into_iter();

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0507"
1 change: 0 additions & 1 deletion src/test/ui/cast-as-bool.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ LL | let u = 5 as bool;

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0054"
1 change: 0 additions & 1 deletion src/test/ui/cast-errors-issue-43825.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ LL | let error = error; //~ ERROR cannot find value `error`

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0425"
1 change: 0 additions & 1 deletion src/test/ui/cast-rfc0401-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ LL | let _ = 3 as bool;

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0054"
1 change: 0 additions & 1 deletion src/test/ui/cast-to-unsized-trait-object-suggestion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ LL | Box::new(1) as Send; //~ ERROR cast to unsized

error: aborting due to 2 previous errors

If you want more information on this error, try using "rustc --explain E0620"
1 change: 0 additions & 1 deletion src/test/ui/casts-differing-anon.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ LL | b_raw = f_raw as *mut _; //~ ERROR is invalid

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0606"
1 change: 0 additions & 1 deletion src/test/ui/casts-issue-46365.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ LL | ipsum: Ipsum //~ ERROR cannot find type `Ipsum`

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0412"
1 change: 0 additions & 1 deletion src/test/ui/changing-crates.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ LL | extern crate b; //~ ERROR: found possibly newer version of crate `a` which

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0460"
Loading