File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ fn main() {
1414 let _ = tup[ 0 ] ;
1515 //~^ ERROR cannot index into a value of type
1616 //~| HELP to access tuple elements, use
17- //~| SUGGESTION let _ = tup.0
17+ //~| SUGGESTION tup.0
1818
1919 // the case where we show just a general hint
2020 let i = 0_usize ;
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ struct DiagnosticSpan {
3636 column_end : usize ,
3737 is_primary : bool ,
3838 label : Option < String > ,
39+ suggested_replacement : Option < String > ,
3940 expansion : Option < Box < DiagnosticSpanMacroExpansion > > ,
4041}
4142
@@ -164,15 +165,15 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
164165 }
165166
166167 // If the message has a suggestion, register that.
167- if let Some ( ref rendered ) = diagnostic . rendered {
168- let start_line = primary_spans . iter ( ) . map ( |s| s . line_start ) . min ( ) . expect ( " \
169- every suggestion should have at least one span" ) ;
170- for ( index , line ) in rendered . lines ( ) . enumerate ( ) {
171- expected_errors . push ( Error {
172- line_num : start_line + index ,
173- kind : Some ( ErrorKind :: Suggestion ) ,
174- msg : line . to_string ( ) ,
175- } ) ;
168+ for span in primary_spans {
169+ if let Some ( ref suggested_replacement ) = span . suggested_replacement {
170+ for ( index , line ) in suggested_replacement . lines ( ) . enumerate ( ) {
171+ expected_errors . push ( Error {
172+ line_num : span . line_start + index ,
173+ kind : Some ( ErrorKind :: Suggestion ) ,
174+ msg : line . to_string ( ) ,
175+ } ) ;
176+ }
176177 }
177178 }
178179
You can’t perform that action at this time.
0 commit comments