File tree 2 files changed +14
-16
lines changed
2 files changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -1477,7 +1477,11 @@ impl EmitterWriter {
1477
1477
Some ( ref sm) => sm,
1478
1478
None => return Ok ( ( ) ) ,
1479
1479
} ;
1480
- if !suggestion. has_valid_spans ( & * * sm) {
1480
+
1481
+ // Render the replacements for each suggestion
1482
+ let suggestions = suggestion. splice_lines ( & * * sm) ;
1483
+
1484
+ if suggestions. is_empty ( ) {
1481
1485
// Suggestions coming from macros can have malformed spans. This is a heavy handed
1482
1486
// approach to avoid ICEs by ignoring the suggestion outright.
1483
1487
return Ok ( ( ) ) ;
@@ -1499,9 +1503,6 @@ impl EmitterWriter {
1499
1503
Some ( Style :: HeaderMsg ) ,
1500
1504
) ;
1501
1505
1502
- // Render the replacements for each suggestion
1503
- let suggestions = suggestion. splice_lines ( & * * sm) ;
1504
-
1505
1506
let mut row_num = 2 ;
1506
1507
let mut notice_capitalization = false ;
1507
1508
for ( complete, parts, only_capitalization) in suggestions. iter ( ) . take ( MAX_SUGGESTIONS ) {
Original file line number Diff line number Diff line change @@ -144,18 +144,6 @@ pub struct SubstitutionPart {
144
144
}
145
145
146
146
impl CodeSuggestion {
147
- /// Suggestions coming from macros can have malformed spans. This is a heavy handed approach
148
- /// to avoid ICEs by ignoring the suggestion outright.
149
- pub fn has_valid_spans ( & self , cm : & SourceMap ) -> bool {
150
- !self . substitutions . iter ( ) . any ( |subst| {
151
- let invalid = subst. parts . iter ( ) . any ( |item| cm. is_valid_span ( item. span ) . is_err ( ) ) ;
152
- if invalid {
153
- debug ! ( "malformed span in suggestion: {:?}" , subst) ;
154
- }
155
- invalid
156
- } )
157
- }
158
-
159
147
/// Returns the assembled code suggestions, whether they should be shown with an underline
160
148
/// and whether the substitution only differs in capitalization.
161
149
pub fn splice_lines ( & self , cm : & SourceMap ) -> Vec < ( String , Vec < SubstitutionPart > , bool ) > {
@@ -187,6 +175,15 @@ impl CodeSuggestion {
187
175
188
176
self . substitutions
189
177
. iter ( )
178
+ . filter ( |subst| {
179
+ // Suggestions coming from macros can have malformed spans. This is a heavy
180
+ // handed approach to avoid ICEs by ignoring the suggestion outright.
181
+ let invalid = subst. parts . iter ( ) . any ( |item| cm. is_valid_span ( item. span ) . is_err ( ) ) ;
182
+ if invalid {
183
+ debug ! ( "splice_lines: suggestion contains an invalid span: {:?}" , subst) ;
184
+ }
185
+ !invalid
186
+ } )
190
187
. cloned ( )
191
188
. map ( |mut substitution| {
192
189
// Assumption: all spans are in the same file, and all spans
You can’t perform that action at this time.
0 commit comments