Compiletest should parse suggestions from the spans
This commit is contained in:
parent
7bb05dbdef
commit
014100df49
2 changed files with 11 additions and 10 deletions
|
@ -14,7 +14,7 @@ fn main() {
|
|||
let _ = tup[0];
|
||||
//~^ ERROR cannot index into a value of type
|
||||
//~| HELP to access tuple elements, use
|
||||
//~| SUGGESTION let _ = tup.0
|
||||
//~| SUGGESTION tup.0
|
||||
|
||||
// the case where we show just a general hint
|
||||
let i = 0_usize;
|
||||
|
|
|
@ -36,6 +36,7 @@ struct DiagnosticSpan {
|
|||
column_end: usize,
|
||||
is_primary: bool,
|
||||
label: Option<String>,
|
||||
suggested_replacement: Option<String>,
|
||||
expansion: Option<Box<DiagnosticSpanMacroExpansion>>,
|
||||
}
|
||||
|
||||
|
@ -164,15 +165,15 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
|
|||
}
|
||||
|
||||
// If the message has a suggestion, register that.
|
||||
if let Some(ref rendered) = diagnostic.rendered {
|
||||
let start_line = primary_spans.iter().map(|s| s.line_start).min().expect("\
|
||||
every suggestion should have at least one span");
|
||||
for (index, line) in rendered.lines().enumerate() {
|
||||
expected_errors.push(Error {
|
||||
line_num: start_line + index,
|
||||
kind: Some(ErrorKind::Suggestion),
|
||||
msg: line.to_string(),
|
||||
});
|
||||
for span in primary_spans {
|
||||
if let Some(ref suggested_replacement) = span.suggested_replacement {
|
||||
for (index, line) in suggested_replacement.lines().enumerate() {
|
||||
expected_errors.push(Error {
|
||||
line_num: span.line_start + index,
|
||||
kind: Some(ErrorKind::Suggestion),
|
||||
msg: line.to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue