@@ -144,7 +144,7 @@ pub struct SubstitutionPart {
144144impl CodeSuggestion {
145145 /// Returns the assembled code suggestions, whether they should be shown with an underline
146146 /// 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 ) > {
148148 use rustc_span:: { CharPos , Pos } ;
149149
150150 fn push_trailing (
@@ -176,7 +176,7 @@ impl CodeSuggestion {
176176 . filter ( |subst| {
177177 // Suggestions coming from macros can have malformed spans. This is a heavy
178178 // 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 ( ) ) ;
180180 if invalid {
181181 debug ! ( "splice_lines: suggestion contains an invalid span: {:?}" , subst) ;
182182 }
@@ -193,7 +193,7 @@ impl CodeSuggestion {
193193 let hi = substitution. parts . iter ( ) . map ( |part| part. span . hi ( ) ) . max ( ) ?;
194194 let bounding_span = Span :: with_root_ctxt ( lo, hi) ;
195195 // 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 ( ) ?;
197197 assert ! ( !lines. lines. is_empty( ) ) ;
198198
199199 // To build up the result, we do this for each span:
@@ -205,36 +205,36 @@ impl CodeSuggestion {
205205 // - splice in the span substitution
206206 //
207207 // 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 ( ) ) ;
210210 prev_hi. col = CharPos :: from_usize ( 0 ) ;
211211
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 ) ;
213213 let mut buf = String :: new ( ) ;
214214
215215 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 ( ) ) ;
217217 if prev_hi. line == cur_lo. line {
218218 push_trailing ( & mut buf, prev_line. as_ref ( ) , & prev_hi, Some ( & cur_lo) ) ;
219219 } else {
220220 push_trailing ( & mut buf, prev_line. as_ref ( ) , & prev_hi, None ) ;
221221 // push lines between the previous and current span (if any)
222222 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) {
224224 buf. push_str ( line. as_ref ( ) ) ;
225225 buf. push ( '\n' ) ;
226226 }
227227 }
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 ) {
229229 let end = std:: cmp:: min ( cur_line. len ( ) , cur_lo. col . to_usize ( ) ) ;
230230 buf. push_str ( & cur_line[ ..end] ) ;
231231 }
232232 }
233233 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 ) ;
236236 }
237- let only_capitalization = is_case_difference ( cm , & buf, bounding_span) ;
237+ let only_capitalization = is_case_difference ( sm , & buf, bounding_span) ;
238238 // if the replacement already ends with a newline, don't print the next line
239239 if !buf. ends_with ( '\n' ) {
240240 push_trailing ( & mut buf, prev_line. as_ref ( ) , & prev_hi, None ) ;
@@ -363,23 +363,23 @@ impl Handler {
363363 color_config : ColorConfig ,
364364 can_emit_warnings : bool ,
365365 treat_err_as_bug : Option < usize > ,
366- cm : Option < Lrc < SourceMap > > ,
366+ sm : Option < Lrc < SourceMap > > ,
367367 ) -> Self {
368368 Self :: with_tty_emitter_and_flags (
369369 color_config,
370- cm ,
370+ sm ,
371371 HandlerFlags { can_emit_warnings, treat_err_as_bug, ..Default :: default ( ) } ,
372372 )
373373 }
374374
375375 pub fn with_tty_emitter_and_flags (
376376 color_config : ColorConfig ,
377- cm : Option < Lrc < SourceMap > > ,
377+ sm : Option < Lrc < SourceMap > > ,
378378 flags : HandlerFlags ,
379379 ) -> Self {
380380 let emitter = Box :: new ( EmitterWriter :: stderr (
381381 color_config,
382- cm ,
382+ sm ,
383383 false ,
384384 false ,
385385 None ,
0 commit comments