@@ -144,7 +144,7 @@ pub struct SubstitutionPart {
144
144
impl CodeSuggestion {
145
145
/// Returns the assembled code suggestions, whether they should be shown with an underline
146
146
/// and whether the substitution only differs in capitalization.
147
- pub fn splice_lines ( & self , cm : & SourceMap ) -> Vec < ( String , Vec < SubstitutionPart > , bool ) > {
147
+ pub fn splice_lines ( & self , sm : & SourceMap ) -> Vec < ( String , Vec < SubstitutionPart > , bool ) > {
148
148
use rustc_span:: { CharPos , Pos } ;
149
149
150
150
fn push_trailing (
@@ -176,7 +176,7 @@ impl CodeSuggestion {
176
176
. filter ( |subst| {
177
177
// Suggestions coming from macros can have malformed spans. This is a heavy
178
178
// handed approach to avoid ICEs by ignoring the suggestion outright.
179
- let invalid = subst. parts . iter ( ) . any ( |item| cm . is_valid_span ( item. span ) . is_err ( ) ) ;
179
+ let invalid = subst. parts . iter ( ) . any ( |item| sm . is_valid_span ( item. span ) . is_err ( ) ) ;
180
180
if invalid {
181
181
debug ! ( "splice_lines: suggestion contains an invalid span: {:?}" , subst) ;
182
182
}
@@ -193,7 +193,7 @@ impl CodeSuggestion {
193
193
let hi = substitution. parts . iter ( ) . map ( |part| part. span . hi ( ) ) . max ( ) ?;
194
194
let bounding_span = Span :: with_root_ctxt ( lo, hi) ;
195
195
// The different spans might belong to different contexts, if so ignore suggestion.
196
- let lines = cm . span_to_lines ( bounding_span) . ok ( ) ?;
196
+ let lines = sm . span_to_lines ( bounding_span) . ok ( ) ?;
197
197
assert ! ( !lines. lines. is_empty( ) ) ;
198
198
199
199
// To build up the result, we do this for each span:
@@ -205,36 +205,36 @@ impl CodeSuggestion {
205
205
// - splice in the span substitution
206
206
//
207
207
// Finally push the trailing line segment of the last span
208
- let fm = & lines. file ;
209
- let mut prev_hi = cm . lookup_char_pos ( bounding_span. lo ( ) ) ;
208
+ let sf = & lines. file ;
209
+ let mut prev_hi = sm . lookup_char_pos ( bounding_span. lo ( ) ) ;
210
210
prev_hi. col = CharPos :: from_usize ( 0 ) ;
211
211
212
- let mut prev_line = fm . get_line ( lines. lines [ 0 ] . line_index ) ;
212
+ let mut prev_line = sf . get_line ( lines. lines [ 0 ] . line_index ) ;
213
213
let mut buf = String :: new ( ) ;
214
214
215
215
for part in & substitution. parts {
216
- let cur_lo = cm . lookup_char_pos ( part. span . lo ( ) ) ;
216
+ let cur_lo = sm . lookup_char_pos ( part. span . lo ( ) ) ;
217
217
if prev_hi. line == cur_lo. line {
218
218
push_trailing ( & mut buf, prev_line. as_ref ( ) , & prev_hi, Some ( & cur_lo) ) ;
219
219
} else {
220
220
push_trailing ( & mut buf, prev_line. as_ref ( ) , & prev_hi, None ) ;
221
221
// push lines between the previous and current span (if any)
222
222
for idx in prev_hi. line ..( cur_lo. line - 1 ) {
223
- if let Some ( line) = fm . get_line ( idx) {
223
+ if let Some ( line) = sf . get_line ( idx) {
224
224
buf. push_str ( line. as_ref ( ) ) ;
225
225
buf. push ( '\n' ) ;
226
226
}
227
227
}
228
- if let Some ( cur_line) = fm . get_line ( cur_lo. line - 1 ) {
228
+ if let Some ( cur_line) = sf . get_line ( cur_lo. line - 1 ) {
229
229
let end = std:: cmp:: min ( cur_line. len ( ) , cur_lo. col . to_usize ( ) ) ;
230
230
buf. push_str ( & cur_line[ ..end] ) ;
231
231
}
232
232
}
233
233
buf. push_str ( & part. snippet ) ;
234
- prev_hi = cm . lookup_char_pos ( part. span . hi ( ) ) ;
235
- prev_line = fm . get_line ( prev_hi. line - 1 ) ;
234
+ prev_hi = sm . lookup_char_pos ( part. span . hi ( ) ) ;
235
+ prev_line = sf . get_line ( prev_hi. line - 1 ) ;
236
236
}
237
- let only_capitalization = is_case_difference ( cm , & buf, bounding_span) ;
237
+ let only_capitalization = is_case_difference ( sm , & buf, bounding_span) ;
238
238
// if the replacement already ends with a newline, don't print the next line
239
239
if !buf. ends_with ( '\n' ) {
240
240
push_trailing ( & mut buf, prev_line. as_ref ( ) , & prev_hi, None ) ;
@@ -363,23 +363,23 @@ impl Handler {
363
363
color_config : ColorConfig ,
364
364
can_emit_warnings : bool ,
365
365
treat_err_as_bug : Option < usize > ,
366
- cm : Option < Lrc < SourceMap > > ,
366
+ sm : Option < Lrc < SourceMap > > ,
367
367
) -> Self {
368
368
Self :: with_tty_emitter_and_flags (
369
369
color_config,
370
- cm ,
370
+ sm ,
371
371
HandlerFlags { can_emit_warnings, treat_err_as_bug, ..Default :: default ( ) } ,
372
372
)
373
373
}
374
374
375
375
pub fn with_tty_emitter_and_flags (
376
376
color_config : ColorConfig ,
377
- cm : Option < Lrc < SourceMap > > ,
377
+ sm : Option < Lrc < SourceMap > > ,
378
378
flags : HandlerFlags ,
379
379
) -> Self {
380
380
let emitter = Box :: new ( EmitterWriter :: stderr (
381
381
color_config,
382
- cm ,
382
+ sm ,
383
383
false ,
384
384
false ,
385
385
None ,
0 commit comments