diff --git a/src/test/compile-fail/issue-27842.rs b/src/test/compile-fail/issue-27842.rs index 8c71761df2fb..eb28e36dc076 100644 --- a/src/test/compile-fail/issue-27842.rs +++ b/src/test/compile-fail/issue-27842.rs @@ -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; diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 77ee93c30078..8e9cd1a12faa 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -36,6 +36,7 @@ struct DiagnosticSpan { column_end: usize, is_primary: bool, label: Option, + suggested_replacement: Option, expansion: Option>, } @@ -164,15 +165,15 @@ fn push_expected_errors(expected_errors: &mut Vec, } // 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(), + }); + } } }