File tree 2 files changed +11
-10
lines changed
2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ fn main() {
14
14
let _ = tup[ 0 ] ;
15
15
//~^ ERROR cannot index into a value of type
16
16
//~| HELP to access tuple elements, use
17
- //~| SUGGESTION let _ = tup.0
17
+ //~| SUGGESTION tup.0
18
18
19
19
// the case where we show just a general hint
20
20
let i = 0_usize ;
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ struct DiagnosticSpan {
36
36
column_end : usize ,
37
37
is_primary : bool ,
38
38
label : Option < String > ,
39
+ suggested_replacement : Option < String > ,
39
40
expansion : Option < Box < DiagnosticSpanMacroExpansion > > ,
40
41
}
41
42
@@ -164,15 +165,15 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
164
165
}
165
166
166
167
// 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
+ }
176
177
}
177
178
}
178
179
You can’t perform that action at this time.
0 commit comments