Skip to content

Commit

Permalink
pacify the merciless acrichto (somewhat)
Browse files Browse the repository at this point in the history
Also add a comment or two to pacify the merciless self-critic, who hates
a closure without a comment.
  • Loading branch information
nikomatsakis committed Apr 21, 2016
1 parent bf624c4 commit 28a3c88
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
23 changes: 16 additions & 7 deletions src/compiletest/json.rs
Expand Up @@ -69,8 +69,7 @@ fn parse_line(file_name: &str, line: &str) -> Vec<Error> {
expected_errors
}
Err(error) => {
println!("failed to decode compiler output as json: `{}`", error);
panic!("failed to decode compiler output as json");
panic!("failed to decode compiler output as json: `{}`", error);
}
}
} else {
Expand All @@ -82,10 +81,19 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
diagnostic: &Diagnostic,
file_name: &str) {
// We only consider messages pertaining to the current file.
let matching_spans =
|| diagnostic.spans.iter().filter(|span| span.file_name == file_name);
let with_code =
|span: &DiagnosticSpan, text: &str| match diagnostic.code {
let matching_spans = || {
diagnostic.spans.iter().filter(|span| span.file_name == file_name)
};

// We break the output into multiple lines, and then append the
// [E123] to every line in the output. This may be overkill. The
// intention was to match existing tests that do things like "//|
// found `i32` [E123]" and expect to match that somewhere, and yet
// also ensure that `//~ ERROR E123` *always* works. The
// assumption is that these multi-line error messages are on their
// way out anyhow.
let with_code = |span: &DiagnosticSpan, text: &str| {
match diagnostic.code {
Some(ref code) =>
// FIXME(#33000) -- it'd be better to use a dedicated
// UI harness than to include the line/col number like
Expand All @@ -105,7 +113,8 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
span.line_start, span.column_start,
span.line_end, span.column_end,
text),
};
}
};

// Convert multi-line messages into multiple expected
// errors. We expect to replace these with something
Expand Down
14 changes: 6 additions & 8 deletions src/libsyntax/errors/json.rs
Expand Up @@ -237,14 +237,12 @@ impl DiagnosticSpan {
None,
backtrace,
je);
let def_site_span =
bt.def_site_span
.map(|sp| {
Self::from_span_and_backtrace(sp,
None,
vec![].into_iter(),
je)
});
let def_site_span = bt.def_site_span.map(|sp| {
Self::from_span_and_backtrace(sp,
None,
vec![].into_iter(),
je)
});
Box::new(DiagnosticSpanMacroExpansion {
span: call_site,
macro_decl_name: bt.macro_decl_name,
Expand Down

0 comments on commit 28a3c88

Please sign in to comment.