Skip to content

Commit 04d804c

Browse files
committed
Rename CodeMap/FileMap to SourceMap/SourceFile
#2946
1 parent 693c7d6 commit 04d804c

34 files changed

+203
-203
lines changed

Cargo.lock

Lines changed: 35 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ env_logger = "0.5"
4747
getopts = "0.2"
4848
derive-new = "0.5"
4949
cargo_metadata = "0.6"
50-
rustc-ap-rustc_target = "230.0.0"
51-
rustc-ap-syntax = "230.0.0"
52-
rustc-ap-syntax_pos = "230.0.0"
50+
rustc-ap-rustc_target = "235.0.0"
51+
rustc-ap-syntax = "235.0.0"
52+
rustc-ap-syntax_pos = "235.0.0"
5353
failure = "0.1.1"
5454

5555
[dev-dependencies]

src/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use utils::{count_newlines, mk_sp};
2222

2323
use std::borrow::Cow;
2424
use syntax::ast;
25-
use syntax::codemap::{BytePos, Span, DUMMY_SP};
25+
use syntax::source_map::{BytePos, Span, DUMMY_SP};
2626

2727
/// Returns attributes on the given statement.
2828
pub fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {

src/chains.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
//! .qux
6666
//! ```
6767
68-
use codemap::SpanUtils;
68+
use source_map::SpanUtils;
6969
use comment::rewrite_comment;
7070
use config::IndentStyle;
7171
use expr::rewrite_call;
@@ -82,7 +82,7 @@ use std::borrow::Cow;
8282
use std::cmp::min;
8383
use std::iter;
8484

85-
use syntax::codemap::{BytePos, Span};
85+
use syntax::source_map::{BytePos, Span};
8686
use syntax::{ast, ptr};
8787

8888
pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -> Option<String> {

src/closures.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// except according to those terms.
1010

1111
use config::lists::*;
12-
use syntax::codemap::Span;
12+
use syntax::source_map::Span;
1313
use syntax::parse::classify;
1414
use syntax::{ast, ptr};
1515

16-
use codemap::SpanUtils;
16+
use source_map::SpanUtils;
1717
use expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond, ToExpr};
1818
use items::{span_hi_for_arg, span_lo_for_arg};
1919
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
@@ -51,7 +51,7 @@ pub fn rewrite_closure(
5151

5252
if let ast::ExprKind::Block(ref block, _) = body.node {
5353
// The body of the closure is an empty block.
54-
if block.stmts.is_empty() && !block_contains_comment(block, context.codemap) {
54+
if block.stmts.is_empty() && !block_contains_comment(block, context.source_map) {
5555
return body
5656
.rewrite(context, shape)
5757
.map(|s| format!("{} {}", prefix, s));
@@ -114,7 +114,7 @@ fn get_inner_expr<'a>(
114114
fn needs_block(block: &ast::Block, prefix: &str, context: &RewriteContext) -> bool {
115115
is_unsafe_block(block)
116116
|| block.stmts.len() > 1
117-
|| block_contains_comment(block, context.codemap)
117+
|| block_contains_comment(block, context.source_map)
118118
|| prefix.contains('\n')
119119
}
120120

@@ -304,7 +304,7 @@ pub fn rewrite_last_closure(
304304
let body = match body.node {
305305
ast::ExprKind::Block(ref block, _)
306306
if !is_unsafe_block(block)
307-
&& is_simple_block(block, Some(&body.attrs), context.codemap) =>
307+
&& is_simple_block(block, Some(&body.attrs), context.source_map) =>
308308
{
309309
stmt_expr(&block.stmts[0]).unwrap_or(body)
310310
}

src/comment.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use std::{self, borrow::Cow, iter};
1414

1515
use itertools::{multipeek, MultiPeek};
16-
use syntax::codemap::Span;
16+
use syntax::source_map::Span;
1717

1818
use config::Config;
1919
use rewrite::RewriteContext;
@@ -1151,10 +1151,10 @@ pub fn recover_comment_removed(
11511151
// We missed some comments. Warn and keep the original text.
11521152
if context.config.error_on_unformatted() {
11531153
context.report.append(
1154-
context.codemap.span_to_filename(span).into(),
1154+
context.source_map.span_to_filename(span).into(),
11551155
vec![FormattingError::from_span(
11561156
&span,
1157-
&context.codemap,
1157+
&context.source_map,
11581158
ErrorKind::LostComment,
11591159
)],
11601160
);

src/config/file_lines.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ use serde::de::{Deserialize, Deserializer};
1919
use serde::ser::{self, Serialize, Serializer};
2020
use serde_json as json;
2121

22-
use syntax::codemap::{self, FileMap};
22+
use syntax::source_map::{self, SourceFile};
2323

2424
/// A range of lines in a file, inclusive of both ends.
2525
pub struct LineRange {
26-
pub file: Rc<FileMap>,
26+
pub file: Rc<SourceFile>,
2727
pub lo: usize,
2828
pub hi: usize,
2929
}
@@ -35,11 +35,11 @@ pub enum FileName {
3535
Stdin,
3636
}
3737

38-
impl From<codemap::FileName> for FileName {
39-
fn from(name: codemap::FileName) -> FileName {
38+
impl From<source_map::FileName> for FileName {
39+
fn from(name: source_map::FileName) -> FileName {
4040
match name {
41-
codemap::FileName::Real(p) => FileName::Real(p),
42-
codemap::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
41+
source_map::FileName::Real(p) => FileName::Real(p),
42+
source_map::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
4343
_ => unreachable!(),
4444
}
4545
}

src/expr.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ use std::borrow::Cow;
1212
use std::cmp::min;
1313

1414
use config::lists::*;
15-
use syntax::codemap::{BytePos, CodeMap, Span};
15+
use syntax::source_map::{BytePos, SourceMap, Span};
1616
use syntax::parse::token::DelimToken;
1717
use syntax::{ast, ptr};
1818

1919
use chains::rewrite_chain;
2020
use closures;
21-
use codemap::{LineRangeUtils, SpanUtils};
21+
use source_map::{LineRangeUtils, SpanUtils};
2222
use 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 {
11251125
pub 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(
11381138
pub 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(
11501150
pub 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

Comments
 (0)