@@ -12,13 +12,13 @@ use std::borrow::Cow;
12
12
use std:: cmp:: min;
13
13
14
14
use config:: lists:: * ;
15
- use syntax:: codemap :: { BytePos , CodeMap , Span } ;
15
+ use syntax:: source_map :: { BytePos , SourceMap , Span } ;
16
16
use syntax:: parse:: token:: DelimToken ;
17
17
use syntax:: { ast, ptr} ;
18
18
19
19
use chains:: rewrite_chain;
20
20
use closures;
21
- use codemap :: { LineRangeUtils , SpanUtils } ;
21
+ use source_map :: { LineRangeUtils , SpanUtils } ;
22
22
use comment:: {
23
23
combine_strs_with_missing_comments, contains_comment, recover_comment_removed, rewrite_comment,
24
24
rewrite_missing_comment, CharClasses , FindUncommented ,
@@ -425,7 +425,7 @@ fn rewrite_empty_block(
425
425
return None ;
426
426
}
427
427
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
429
429
{
430
430
return Some ( format ! ( "{}{}{{}}" , prefix, label_str) ) ;
431
431
}
@@ -483,7 +483,7 @@ fn rewrite_single_line_block(
483
483
label : Option < ast:: Label > ,
484
484
shape : Shape ,
485
485
) -> Option < String > {
486
- if is_simple_block ( block, attrs, context. codemap ) {
486
+ if is_simple_block ( block, attrs, context. source_map ) {
487
487
let expr_shape = shape. offset_left ( last_line_width ( prefix) ) ?;
488
488
let expr_str = block. stmts [ 0 ] . rewrite ( context, expr_shape) ?;
489
489
let label_str = rewrite_label ( label) ;
@@ -769,8 +769,8 @@ impl<'a> ControlFlow<'a> {
769
769
let fixed_cost = self . keyword . len ( ) + " { } else { }" . len ( ) ;
770
770
771
771
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 )
774
774
|| pat_expr_str. contains ( '\n' )
775
775
{
776
776
return None ;
@@ -1113,8 +1113,8 @@ fn extract_comment(span: Span, context: &RewriteContext, shape: Shape) -> Option
1113
1113
}
1114
1114
}
1115
1115
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 ( ) ;
1118
1118
contains_comment ( & snippet)
1119
1119
}
1120
1120
@@ -1125,11 +1125,11 @@ pub fn block_contains_comment(block: &ast::Block, codemap: &CodeMap) -> bool {
1125
1125
pub fn is_simple_block (
1126
1126
block : & ast:: Block ,
1127
1127
attrs : Option < & [ ast:: Attribute ] > ,
1128
- codemap : & CodeMap ,
1128
+ source_map : & SourceMap ,
1129
1129
) -> bool {
1130
1130
( block. stmts . len ( ) == 1
1131
1131
&& stmt_is_expr ( & block. stmts [ 0 ] )
1132
- && !block_contains_comment ( block, codemap )
1132
+ && !block_contains_comment ( block, source_map )
1133
1133
&& attrs. map_or ( true , |a| a. is_empty ( ) ) )
1134
1134
}
1135
1135
@@ -1138,10 +1138,10 @@ pub fn is_simple_block(
1138
1138
pub fn is_simple_block_stmt (
1139
1139
block : & ast:: Block ,
1140
1140
attrs : Option < & [ ast:: Attribute ] > ,
1141
- codemap : & CodeMap ,
1141
+ source_map : & SourceMap ,
1142
1142
) -> bool {
1143
1143
block. stmts . len ( ) <= 1
1144
- && !block_contains_comment ( block, codemap )
1144
+ && !block_contains_comment ( block, source_map )
1145
1145
&& attrs. map_or ( true , |a| a. is_empty ( ) )
1146
1146
}
1147
1147
@@ -1150,10 +1150,10 @@ pub fn is_simple_block_stmt(
1150
1150
pub fn is_empty_block (
1151
1151
block : & ast:: Block ,
1152
1152
attrs : Option < & [ ast:: Attribute ] > ,
1153
- codemap : & CodeMap ,
1153
+ source_map : & SourceMap ,
1154
1154
) -> bool {
1155
1155
block. stmts . is_empty ( )
1156
- && !block_contains_comment ( block, codemap )
1156
+ && !block_contains_comment ( block, source_map )
1157
1157
&& attrs. map_or ( true , |a| inner_attributes ( a) . is_empty ( ) )
1158
1158
}
1159
1159
0 commit comments