@@ -12,13 +12,13 @@ use std::borrow::Cow;
1212use std:: cmp:: min;
1313
1414use config:: lists:: * ;
15- use syntax:: codemap :: { BytePos , CodeMap , Span } ;
15+ use syntax:: source_map :: { BytePos , SourceMap , Span } ;
1616use syntax:: parse:: token:: DelimToken ;
1717use syntax:: { ast, ptr} ;
1818
1919use chains:: rewrite_chain;
2020use closures;
21- use codemap :: { LineRangeUtils , SpanUtils } ;
21+ use source_map :: { LineRangeUtils , SpanUtils } ;
2222use comment:: {
2323 combine_strs_with_missing_comments, contains_comment, recover_comment_removed, rewrite_comment,
2424 rewrite_missing_comment, CharClasses , FindUncommented ,
@@ -425,7 +425,7 @@ fn rewrite_empty_block(
425425 return None ;
426426 }
427427
428- if block. stmts . is_empty ( ) && !block_contains_comment ( block, context. codemap ) && shape. width >= 2
428+ if block. stmts . is_empty ( ) && !block_contains_comment ( block, context. source_map ) && shape. width >= 2
429429 {
430430 return Some ( format ! ( "{}{}{{}}" , prefix, label_str) ) ;
431431 }
@@ -483,7 +483,7 @@ fn rewrite_single_line_block(
483483 label : Option < ast:: Label > ,
484484 shape : Shape ,
485485) -> Option < String > {
486- if is_simple_block ( block, attrs, context. codemap ) {
486+ if is_simple_block ( block, attrs, context. source_map ) {
487487 let expr_shape = shape. offset_left ( last_line_width ( prefix) ) ?;
488488 let expr_str = block. stmts [ 0 ] . rewrite ( context, expr_shape) ?;
489489 let label_str = rewrite_label ( label) ;
@@ -769,8 +769,8 @@ impl<'a> ControlFlow<'a> {
769769 let fixed_cost = self . keyword . len ( ) + " { } else { }" . len ( ) ;
770770
771771 if let ast:: ExprKind :: Block ( ref else_node, _) = else_block. node {
772- if !is_simple_block ( self . block , None , context. codemap )
773- || !is_simple_block ( else_node, None , context. codemap )
772+ if !is_simple_block ( self . block , None , context. source_map )
773+ || !is_simple_block ( else_node, None , context. source_map )
774774 || pat_expr_str. contains ( '\n' )
775775 {
776776 return None ;
@@ -1113,8 +1113,8 @@ fn extract_comment(span: Span, context: &RewriteContext, shape: Shape) -> Option
11131113 }
11141114}
11151115
1116- pub fn block_contains_comment ( block : & ast:: Block , codemap : & CodeMap ) -> bool {
1117- let snippet = codemap . span_to_snippet ( block. span ) . unwrap ( ) ;
1116+ pub fn block_contains_comment ( block : & ast:: Block , source_map : & SourceMap ) -> bool {
1117+ let snippet = source_map . span_to_snippet ( block. span ) . unwrap ( ) ;
11181118 contains_comment ( & snippet)
11191119}
11201120
@@ -1125,11 +1125,11 @@ pub fn block_contains_comment(block: &ast::Block, codemap: &CodeMap) -> bool {
11251125pub fn is_simple_block (
11261126 block : & ast:: Block ,
11271127 attrs : Option < & [ ast:: Attribute ] > ,
1128- codemap : & CodeMap ,
1128+ source_map : & SourceMap ,
11291129) -> bool {
11301130 ( block. stmts . len ( ) == 1
11311131 && stmt_is_expr ( & block. stmts [ 0 ] )
1132- && !block_contains_comment ( block, codemap )
1132+ && !block_contains_comment ( block, source_map )
11331133 && attrs. map_or ( true , |a| a. is_empty ( ) ) )
11341134}
11351135
@@ -1138,10 +1138,10 @@ pub fn is_simple_block(
11381138pub fn is_simple_block_stmt (
11391139 block : & ast:: Block ,
11401140 attrs : Option < & [ ast:: Attribute ] > ,
1141- codemap : & CodeMap ,
1141+ source_map : & SourceMap ,
11421142) -> bool {
11431143 block. stmts . len ( ) <= 1
1144- && !block_contains_comment ( block, codemap )
1144+ && !block_contains_comment ( block, source_map )
11451145 && attrs. map_or ( true , |a| a. is_empty ( ) )
11461146}
11471147
@@ -1150,10 +1150,10 @@ pub fn is_simple_block_stmt(
11501150pub fn is_empty_block (
11511151 block : & ast:: Block ,
11521152 attrs : Option < & [ ast:: Attribute ] > ,
1153- codemap : & CodeMap ,
1153+ source_map : & SourceMap ,
11541154) -> bool {
11551155 block. stmts . is_empty ( )
1156- && !block_contains_comment ( block, codemap )
1156+ && !block_contains_comment ( block, source_map )
11571157 && attrs. map_or ( true , |a| inner_attributes ( a) . is_empty ( ) )
11581158}
11591159
0 commit comments