Add short message-format
This commit is contained in:
parent
c0e0a38101
commit
83bca40350
10 changed files with 224 additions and 150 deletions
|
@ -156,6 +156,7 @@ impl OutputType {
|
||||||
pub enum ErrorOutputType {
|
pub enum ErrorOutputType {
|
||||||
HumanReadable(ColorConfig),
|
HumanReadable(ColorConfig),
|
||||||
Json,
|
Json,
|
||||||
|
Short(ColorConfig),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ErrorOutputType {
|
impl Default for ErrorOutputType {
|
||||||
|
@ -1362,7 +1363,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
|
||||||
opt::multi("Z", "", "Set internal debugging options", "FLAG"),
|
opt::multi("Z", "", "Set internal debugging options", "FLAG"),
|
||||||
opt::opt_s("", "error-format",
|
opt::opt_s("", "error-format",
|
||||||
"How errors and other messages are produced",
|
"How errors and other messages are produced",
|
||||||
"human|json"),
|
"human|json|short"),
|
||||||
opt::opt_s("", "color", "Configure coloring of output:
|
opt::opt_s("", "color", "Configure coloring of output:
|
||||||
auto = colorize, if output goes to a tty (default);
|
auto = colorize, if output goes to a tty (default);
|
||||||
always = always colorize output;
|
always = always colorize output;
|
||||||
|
@ -1431,13 +1432,14 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
|
||||||
match matches.opt_str("error-format").as_ref().map(|s| &s[..]) {
|
match matches.opt_str("error-format").as_ref().map(|s| &s[..]) {
|
||||||
Some("human") => ErrorOutputType::HumanReadable(color),
|
Some("human") => ErrorOutputType::HumanReadable(color),
|
||||||
Some("json") => ErrorOutputType::Json,
|
Some("json") => ErrorOutputType::Json,
|
||||||
|
Some("short") => ErrorOutputType::Short(color),
|
||||||
|
|
||||||
None => ErrorOutputType::HumanReadable(color),
|
None => ErrorOutputType::HumanReadable(color),
|
||||||
|
|
||||||
Some(arg) => {
|
Some(arg) => {
|
||||||
early_error(ErrorOutputType::HumanReadable(color),
|
early_error(ErrorOutputType::HumanReadable(color),
|
||||||
&format!("argument for --error-format must be human or json (instead \
|
&format!("argument for --error-format must be `human`, `json` or \
|
||||||
was `{}`)",
|
`short` (instead was `{}`)",
|
||||||
arg))
|
arg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -711,12 +711,10 @@ pub fn build_session_with_codemap(sopts: config::Options,
|
||||||
|
|
||||||
let emitter: Box<Emitter> = match (sopts.error_format, emitter_dest) {
|
let emitter: Box<Emitter> = match (sopts.error_format, emitter_dest) {
|
||||||
(config::ErrorOutputType::HumanReadable(color_config), None) => {
|
(config::ErrorOutputType::HumanReadable(color_config), None) => {
|
||||||
Box::new(EmitterWriter::stderr(color_config,
|
Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), false))
|
||||||
Some(codemap.clone())))
|
|
||||||
}
|
}
|
||||||
(config::ErrorOutputType::HumanReadable(_), Some(dst)) => {
|
(config::ErrorOutputType::HumanReadable(_), Some(dst)) => {
|
||||||
Box::new(EmitterWriter::new(dst,
|
Box::new(EmitterWriter::new(dst, Some(codemap.clone()), false))
|
||||||
Some(codemap.clone())))
|
|
||||||
}
|
}
|
||||||
(config::ErrorOutputType::Json, None) => {
|
(config::ErrorOutputType::Json, None) => {
|
||||||
Box::new(JsonEmitter::stderr(Some(registry), codemap.clone()))
|
Box::new(JsonEmitter::stderr(Some(registry), codemap.clone()))
|
||||||
|
@ -724,6 +722,12 @@ pub fn build_session_with_codemap(sopts: config::Options,
|
||||||
(config::ErrorOutputType::Json, Some(dst)) => {
|
(config::ErrorOutputType::Json, Some(dst)) => {
|
||||||
Box::new(JsonEmitter::new(dst, Some(registry), codemap.clone()))
|
Box::new(JsonEmitter::new(dst, Some(registry), codemap.clone()))
|
||||||
}
|
}
|
||||||
|
(config::ErrorOutputType::Short(color_config), None) => {
|
||||||
|
Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), true))
|
||||||
|
}
|
||||||
|
(config::ErrorOutputType::Short(_), Some(dst)) => {
|
||||||
|
Box::new(EmitterWriter::new(dst, Some(codemap.clone()), true))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let diagnostic_handler =
|
let diagnostic_handler =
|
||||||
|
@ -867,10 +871,12 @@ pub enum IncrCompSession {
|
||||||
pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
|
pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
|
||||||
let emitter: Box<Emitter> = match output {
|
let emitter: Box<Emitter> = match output {
|
||||||
config::ErrorOutputType::HumanReadable(color_config) => {
|
config::ErrorOutputType::HumanReadable(color_config) => {
|
||||||
Box::new(EmitterWriter::stderr(color_config,
|
Box::new(EmitterWriter::stderr(color_config, None, false))
|
||||||
None))
|
|
||||||
}
|
}
|
||||||
config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()),
|
config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()),
|
||||||
|
config::ErrorOutputType::Short(color_config) => {
|
||||||
|
Box::new(EmitterWriter::stderr(color_config, None, true))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let handler = errors::Handler::with_emitter(true, false, emitter);
|
let handler = errors::Handler::with_emitter(true, false, emitter);
|
||||||
handler.emit(&MultiSpan::new(), msg, errors::Level::Fatal);
|
handler.emit(&MultiSpan::new(), msg, errors::Level::Fatal);
|
||||||
|
@ -880,10 +886,12 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
|
||||||
pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
|
pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
|
||||||
let emitter: Box<Emitter> = match output {
|
let emitter: Box<Emitter> = match output {
|
||||||
config::ErrorOutputType::HumanReadable(color_config) => {
|
config::ErrorOutputType::HumanReadable(color_config) => {
|
||||||
Box::new(EmitterWriter::stderr(color_config,
|
Box::new(EmitterWriter::stderr(color_config, None, false))
|
||||||
None))
|
|
||||||
}
|
}
|
||||||
config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()),
|
config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()),
|
||||||
|
config::ErrorOutputType::Short(color_config) => {
|
||||||
|
Box::new(EmitterWriter::stderr(color_config, None, true))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let handler = errors::Handler::with_emitter(true, false, emitter);
|
let handler = errors::Handler::with_emitter(true, false, emitter);
|
||||||
handler.emit(&MultiSpan::new(), msg, errors::Level::Warning);
|
handler.emit(&MultiSpan::new(), msg, errors::Level::Warning);
|
||||||
|
|
|
@ -138,7 +138,9 @@ pub fn run<F>(run_compiler: F) -> isize
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let emitter =
|
let emitter =
|
||||||
errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None);
|
errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
|
||||||
|
None,
|
||||||
|
true);
|
||||||
let handler = errors::Handler::with_emitter(true, false, Box::new(emitter));
|
let handler = errors::Handler::with_emitter(true, false, Box::new(emitter));
|
||||||
handler.emit(&MultiSpan::new(),
|
handler.emit(&MultiSpan::new(),
|
||||||
"aborting due to previous error(s)",
|
"aborting due to previous error(s)",
|
||||||
|
@ -1208,7 +1210,9 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
|
||||||
// Thread panicked without emitting a fatal diagnostic
|
// Thread panicked without emitting a fatal diagnostic
|
||||||
if !value.is::<errors::FatalError>() {
|
if !value.is::<errors::FatalError>() {
|
||||||
let emitter =
|
let emitter =
|
||||||
Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None));
|
Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
|
||||||
|
None,
|
||||||
|
false));
|
||||||
let handler = errors::Handler::with_emitter(true, false, emitter);
|
let handler = errors::Handler::with_emitter(true, false, emitter);
|
||||||
|
|
||||||
// a .span_bug or .bug call has already printed what
|
// a .span_bug or .bug call has already printed what
|
||||||
|
|
|
@ -107,6 +107,7 @@ impl ColorConfig {
|
||||||
pub struct EmitterWriter {
|
pub struct EmitterWriter {
|
||||||
dst: Destination,
|
dst: Destination,
|
||||||
cm: Option<Rc<CodeMapper>>,
|
cm: Option<Rc<CodeMapper>>,
|
||||||
|
short_message: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FileWithAnnotatedLines {
|
struct FileWithAnnotatedLines {
|
||||||
|
@ -116,25 +117,34 @@ struct FileWithAnnotatedLines {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EmitterWriter {
|
impl EmitterWriter {
|
||||||
pub fn stderr(color_config: ColorConfig, code_map: Option<Rc<CodeMapper>>) -> EmitterWriter {
|
pub fn stderr(color_config: ColorConfig,
|
||||||
|
code_map: Option<Rc<CodeMapper>>,
|
||||||
|
short_message: bool)
|
||||||
|
-> EmitterWriter {
|
||||||
if color_config.use_color() {
|
if color_config.use_color() {
|
||||||
let dst = Destination::from_stderr();
|
let dst = Destination::from_stderr();
|
||||||
EmitterWriter {
|
EmitterWriter {
|
||||||
dst,
|
dst,
|
||||||
cm: code_map,
|
cm: code_map,
|
||||||
|
short_message: short_message,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EmitterWriter {
|
EmitterWriter {
|
||||||
dst: Raw(Box::new(io::stderr())),
|
dst: Raw(Box::new(io::stderr())),
|
||||||
cm: code_map,
|
cm: code_map,
|
||||||
|
short_message: short_message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(dst: Box<Write + Send>, code_map: Option<Rc<CodeMapper>>) -> EmitterWriter {
|
pub fn new(dst: Box<Write + Send>,
|
||||||
|
code_map: Option<Rc<CodeMapper>>,
|
||||||
|
short_message: bool)
|
||||||
|
-> EmitterWriter {
|
||||||
EmitterWriter {
|
EmitterWriter {
|
||||||
dst: Raw(dst),
|
dst: Raw(dst),
|
||||||
cm: code_map,
|
cm: code_map,
|
||||||
|
short_message: short_message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,7 +681,7 @@ impl EmitterWriter {
|
||||||
Style::LabelSecondary
|
Style::LabelSecondary
|
||||||
};
|
};
|
||||||
Some((p, style))
|
Some((p, style))
|
||||||
},
|
}
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -689,6 +699,7 @@ impl EmitterWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !self.short_message {
|
||||||
for span_label in msp.span_labels() {
|
for span_label in msp.span_labels() {
|
||||||
if span_label.span != DUMMY_SP {
|
if span_label.span != DUMMY_SP {
|
||||||
let hi = cm.lookup_char_pos(span_label.span.hi());
|
let hi = cm.lookup_char_pos(span_label.span.hi());
|
||||||
|
@ -698,6 +709,7 @@ impl EmitterWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
max
|
max
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -881,7 +893,8 @@ impl EmitterWriter {
|
||||||
-> io::Result<()> {
|
-> io::Result<()> {
|
||||||
let mut buffer = StyledBuffer::new();
|
let mut buffer = StyledBuffer::new();
|
||||||
|
|
||||||
if msp.primary_spans().is_empty() && msp.span_labels().is_empty() && is_secondary {
|
if msp.primary_spans().is_empty() && msp.span_labels().is_empty() && is_secondary
|
||||||
|
&& !self.short_message {
|
||||||
// This is a secondary message with no span info
|
// This is a secondary message with no span info
|
||||||
for _ in 0..max_line_num_len {
|
for _ in 0..max_line_num_len {
|
||||||
buffer.prepend(0, " ", Style::NoStyle);
|
buffer.prepend(0, " ", Style::NoStyle);
|
||||||
|
@ -916,12 +929,12 @@ impl EmitterWriter {
|
||||||
if primary_span != &&DUMMY_SP {
|
if primary_span != &&DUMMY_SP {
|
||||||
(cm.lookup_char_pos(primary_span.lo()), cm)
|
(cm.lookup_char_pos(primary_span.lo()), cm)
|
||||||
} else {
|
} else {
|
||||||
emit_to_destination(&buffer.render(), level, &mut self.dst)?;
|
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If we don't have span information, emit and exit
|
// If we don't have span information, emit and exit
|
||||||
emit_to_destination(&buffer.render(), level, &mut self.dst)?;
|
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
if let Ok(pos) =
|
if let Ok(pos) =
|
||||||
|
@ -940,11 +953,12 @@ impl EmitterWriter {
|
||||||
// to do this, we need to know if this span will be primary
|
// to do this, we need to know if this span will be primary
|
||||||
let is_primary = primary_lo.file.name == annotated_file.file.name;
|
let is_primary = primary_lo.file.name == annotated_file.file.name;
|
||||||
if is_primary {
|
if is_primary {
|
||||||
|
let loc = primary_lo.clone();
|
||||||
|
if !self.short_message {
|
||||||
// remember where we are in the output buffer for easy reference
|
// remember where we are in the output buffer for easy reference
|
||||||
let buffer_msg_line_offset = buffer.num_lines();
|
let buffer_msg_line_offset = buffer.num_lines();
|
||||||
|
|
||||||
buffer.prepend(buffer_msg_line_offset, "--> ", Style::LineNumber);
|
buffer.prepend(buffer_msg_line_offset, "--> ", Style::LineNumber);
|
||||||
let loc = primary_lo.clone();
|
|
||||||
buffer.append(buffer_msg_line_offset,
|
buffer.append(buffer_msg_line_offset,
|
||||||
&format!("{}:{}:{}", loc.file.name, loc.line, loc.col.0 + 1),
|
&format!("{}:{}:{}", loc.file.name, loc.line, loc.col.0 + 1),
|
||||||
Style::LineAndColumn);
|
Style::LineAndColumn);
|
||||||
|
@ -952,6 +966,11 @@ impl EmitterWriter {
|
||||||
buffer.prepend(buffer_msg_line_offset, " ", Style::NoStyle);
|
buffer.prepend(buffer_msg_line_offset, " ", Style::NoStyle);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
buffer.prepend(0,
|
||||||
|
&format!("{}:{}:{} - ", loc.file.name, loc.line, loc.col.0 + 1),
|
||||||
|
Style::LineAndColumn);
|
||||||
|
}
|
||||||
|
} else if !self.short_message {
|
||||||
// remember where we are in the output buffer for easy reference
|
// remember where we are in the output buffer for easy reference
|
||||||
let buffer_msg_line_offset = buffer.num_lines();
|
let buffer_msg_line_offset = buffer.num_lines();
|
||||||
|
|
||||||
|
@ -968,9 +987,12 @@ impl EmitterWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.short_message {
|
||||||
// Put in the spacer between the location and annotated source
|
// Put in the spacer between the location and annotated source
|
||||||
let buffer_msg_line_offset = buffer.num_lines();
|
let buffer_msg_line_offset = buffer.num_lines();
|
||||||
draw_col_separator_no_space(&mut buffer, buffer_msg_line_offset, max_line_num_len + 1);
|
draw_col_separator_no_space(&mut buffer,
|
||||||
|
buffer_msg_line_offset,
|
||||||
|
max_line_num_len + 1);
|
||||||
|
|
||||||
// Contains the vertical lines' positions for active multiline annotations
|
// Contains the vertical lines' positions for active multiline annotations
|
||||||
let mut multilines = HashMap::new();
|
let mut multilines = HashMap::new();
|
||||||
|
@ -1042,7 +1064,9 @@ impl EmitterWriter {
|
||||||
&(annotated_file.lines[line_idx + 1].line_index - 1)
|
&(annotated_file.lines[line_idx + 1].line_index - 1)
|
||||||
.to_string(),
|
.to_string(),
|
||||||
Style::LineNumber);
|
Style::LineNumber);
|
||||||
draw_col_separator(&mut buffer, last_buffer_line_num, 1 + max_line_num_len);
|
draw_col_separator(&mut buffer,
|
||||||
|
last_buffer_line_num,
|
||||||
|
1 + max_line_num_len);
|
||||||
buffer.puts(last_buffer_line_num,
|
buffer.puts(last_buffer_line_num,
|
||||||
code_offset,
|
code_offset,
|
||||||
&unannotated_line,
|
&unannotated_line,
|
||||||
|
@ -1061,11 +1085,13 @@ impl EmitterWriter {
|
||||||
multilines.extend(&to_add);
|
multilines.extend(&to_add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// final step: take our styled buffer, render it, then output it
|
// final step: take our styled buffer, render it, then output it
|
||||||
emit_to_destination(&buffer.render(), level, &mut self.dst)?;
|
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
||||||
}
|
}
|
||||||
fn emit_suggestion_default(&mut self,
|
fn emit_suggestion_default(&mut self,
|
||||||
suggestion: &CodeSuggestion,
|
suggestion: &CodeSuggestion,
|
||||||
|
@ -1141,7 +1167,7 @@ impl EmitterWriter {
|
||||||
let msg = format!("and {} other candidates", suggestions.len() - MAX_SUGGESTIONS);
|
let msg = format!("and {} other candidates", suggestions.len() - MAX_SUGGESTIONS);
|
||||||
buffer.puts(row_num, 0, &msg, Style::NoStyle);
|
buffer.puts(row_num, 0, &msg, Style::NoStyle);
|
||||||
}
|
}
|
||||||
emit_to_destination(&buffer.render(), level, &mut self.dst)?;
|
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1158,12 +1184,16 @@ impl EmitterWriter {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
if !children.is_empty() {
|
if !children.is_empty() {
|
||||||
let mut buffer = StyledBuffer::new();
|
let mut buffer = StyledBuffer::new();
|
||||||
|
if !self.short_message {
|
||||||
draw_col_separator_no_space(&mut buffer, 0, max_line_num_len + 1);
|
draw_col_separator_no_space(&mut buffer, 0, max_line_num_len + 1);
|
||||||
match emit_to_destination(&buffer.render(), level, &mut self.dst) {
|
}
|
||||||
|
match emit_to_destination(&buffer.render(), level, &mut self.dst,
|
||||||
|
self.short_message) {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
Err(e) => panic!("failed to emit error: {}", e)
|
Err(e) => panic!("failed to emit error: {}", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !self.short_message {
|
||||||
for child in children {
|
for child in children {
|
||||||
match child.render_span {
|
match child.render_span {
|
||||||
Some(FullSpan(ref msp)) => {
|
Some(FullSpan(ref msp)) => {
|
||||||
|
@ -1176,7 +1206,7 @@ impl EmitterWriter {
|
||||||
Err(e) => panic!("failed to emit error: {}", e),
|
Err(e) => panic!("failed to emit error: {}", e),
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Some(Suggestion(ref cs)) => {
|
Some(Suggestion(ref cs)) => {
|
||||||
match self.emit_suggestion_default(cs,
|
match self.emit_suggestion_default(cs,
|
||||||
&child.level,
|
&child.level,
|
||||||
|
@ -1184,7 +1214,7 @@ impl EmitterWriter {
|
||||||
Err(e) => panic!("failed to emit error: {}", e),
|
Err(e) => panic!("failed to emit error: {}", e),
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => {
|
None => {
|
||||||
match self.emit_message_default(&child.span,
|
match self.emit_message_default(&child.span,
|
||||||
&child.styled_message(),
|
&child.styled_message(),
|
||||||
|
@ -1199,6 +1229,7 @@ impl EmitterWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(e) => panic!("failed to emit error: {}", e),
|
Err(e) => panic!("failed to emit error: {}", e),
|
||||||
}
|
}
|
||||||
match write!(&mut self.dst, "\n") {
|
match write!(&mut self.dst, "\n") {
|
||||||
|
@ -1263,7 +1294,8 @@ fn overlaps(a1: &Annotation, a2: &Annotation, padding: usize) -> bool {
|
||||||
|
|
||||||
fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>,
|
fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>,
|
||||||
lvl: &Level,
|
lvl: &Level,
|
||||||
dst: &mut Destination)
|
dst: &mut Destination,
|
||||||
|
short_message: bool)
|
||||||
-> io::Result<()> {
|
-> io::Result<()> {
|
||||||
use lock;
|
use lock;
|
||||||
|
|
||||||
|
@ -1286,8 +1318,10 @@ fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>,
|
||||||
write!(dst, "{}", part.text)?;
|
write!(dst, "{}", part.text)?;
|
||||||
dst.reset_attrs()?;
|
dst.reset_attrs()?;
|
||||||
}
|
}
|
||||||
|
if !short_message {
|
||||||
write!(dst, "\n")?;
|
write!(dst, "\n")?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
dst.flush()?;
|
dst.flush()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ impl Handler {
|
||||||
treat_err_as_bug: bool,
|
treat_err_as_bug: bool,
|
||||||
cm: Option<Rc<CodeMapper>>)
|
cm: Option<Rc<CodeMapper>>)
|
||||||
-> Handler {
|
-> Handler {
|
||||||
let emitter = Box::new(EmitterWriter::stderr(color_config, cm));
|
let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false));
|
||||||
Handler::with_emitter(can_emit_warnings, treat_err_as_bug, emitter)
|
Handler::with_emitter(can_emit_warnings, treat_err_as_bug, emitter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,8 @@ fn run_test(test: &str, cratename: &str, filename: &str, cfgs: Vec<String>, libs
|
||||||
let data = Arc::new(Mutex::new(Vec::new()));
|
let data = Arc::new(Mutex::new(Vec::new()));
|
||||||
let codemap = Rc::new(CodeMap::new(sessopts.file_path_mapping()));
|
let codemap = Rc::new(CodeMap::new(sessopts.file_path_mapping()));
|
||||||
let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()),
|
let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()),
|
||||||
Some(codemap.clone()));
|
Some(codemap.clone()),
|
||||||
|
false);
|
||||||
let old = io::set_panic(Some(box Sink(data.clone())));
|
let old = io::set_panic(Some(box Sink(data.clone())));
|
||||||
let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout()));
|
let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout()));
|
||||||
|
|
||||||
|
|
|
@ -1721,7 +1721,9 @@ mod tests {
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
fn mk_sess(cm: Rc<CodeMap>) -> ParseSess {
|
fn mk_sess(cm: Rc<CodeMap>) -> ParseSess {
|
||||||
let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()), Some(cm.clone()));
|
let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()),
|
||||||
|
Some(cm.clone()),
|
||||||
|
false);
|
||||||
ParseSess {
|
ParseSess {
|
||||||
span_diagnostic: errors::Handler::with_emitter(true, false, Box::new(emitter)),
|
span_diagnostic: errors::Handler::with_emitter(true, false, Box::new(emitter)),
|
||||||
unstable_features: UnstableFeatures::from_environment(),
|
unstable_features: UnstableFeatures::from_environment(),
|
||||||
|
|
|
@ -60,7 +60,8 @@ fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &
|
||||||
}
|
}
|
||||||
|
|
||||||
let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }),
|
let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }),
|
||||||
Some(code_map.clone()));
|
Some(code_map.clone()),
|
||||||
|
false);
|
||||||
let handler = Handler::with_emitter(true, false, Box::new(emitter));
|
let handler = Handler::with_emitter(true, false, Box::new(emitter));
|
||||||
handler.span_err(msp, "foo");
|
handler.span_err(msp, "foo");
|
||||||
|
|
||||||
|
|
19
src/test/ui/short-error-format.rs
Normal file
19
src/test/ui/short-error-format.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
// compile-flags: --error-format=short
|
||||||
|
|
||||||
|
fn foo(_: u32) {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
foo("Bonjour".to_owned());
|
||||||
|
let x = 0u32;
|
||||||
|
x.salut();
|
||||||
|
}
|
3
src/test/ui/short-error-format.stderr
Normal file
3
src/test/ui/short-error-format.stderr
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
$DIR/short-error-format.rs:16:9 - error[E0308]: mismatched types
|
||||||
|
$DIR/short-error-format.rs:18:7 - error[E0599]: no method named `salut` found for type `u32` in the current scope
|
||||||
|
error: aborting due to 2 previous errors
|
Loading…
Add table
Add a link
Reference in a new issue