Skip to content

Commit

Permalink
Merge pull request #2950 from CAD97/master
Browse files Browse the repository at this point in the history
Rename CodeMap/FileMap to SourceMap/SourceFile
  • Loading branch information
nrc authored Aug 23, 2018
2 parents 693c7d6 + fc1909d commit f009252
Show file tree
Hide file tree
Showing 34 changed files with 210 additions and 204 deletions.
70 changes: 35 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ env_logger = "0.5"
getopts = "0.2"
derive-new = "0.5"
cargo_metadata = "0.6"
rustc-ap-rustc_target = "230.0.0"
rustc-ap-syntax = "230.0.0"
rustc-ap-syntax_pos = "230.0.0"
rustc-ap-rustc_target = "235.0.0"
rustc-ap-syntax = "235.0.0"
rustc-ap-syntax_pos = "235.0.0"
failure = "0.1.1"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use utils::{count_newlines, mk_sp};

use std::borrow::Cow;
use syntax::ast;
use syntax::codemap::{BytePos, Span, DUMMY_SP};
use syntax::source_map::{BytePos, Span, DUMMY_SP};

/// Returns attributes on the given statement.
pub fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
Expand Down
4 changes: 2 additions & 2 deletions src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@
//! .qux
//! ```
use codemap::SpanUtils;
use comment::rewrite_comment;
use config::IndentStyle;
use expr::rewrite_call;
use lists::{extract_post_comment, extract_pre_comment, get_comment_end};
use macros::convert_try_mac;
use rewrite::{Rewrite, RewriteContext};
use shape::Shape;
use source_map::SpanUtils;
use utils::{
first_line_width, last_line_extendable, last_line_width, mk_sp, trimmed_last_line_width,
wrap_str,
Expand All @@ -82,7 +82,7 @@ use std::borrow::Cow;
use std::cmp::min;
use std::iter;

use syntax::codemap::{BytePos, Span};
use syntax::source_map::{BytePos, Span};
use syntax::{ast, ptr};

pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -> Option<String> {
Expand Down
10 changes: 5 additions & 5 deletions src/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
// except according to those terms.

use config::lists::*;
use syntax::codemap::Span;
use syntax::parse::classify;
use syntax::source_map::Span;
use syntax::{ast, ptr};

use codemap::SpanUtils;
use expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond, ToExpr};
use items::{span_hi_for_arg, span_lo_for_arg};
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
use rewrite::{Rewrite, RewriteContext};
use shape::Shape;
use source_map::SpanUtils;
use utils::{last_line_width, left_most_sub_expr, stmt_expr};

// This module is pretty messy because of the rules around closures and blocks:
Expand Down Expand Up @@ -51,7 +51,7 @@ pub fn rewrite_closure(

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

Expand Down Expand Up @@ -304,7 +304,7 @@ pub fn rewrite_last_closure(
let body = match body.node {
ast::ExprKind::Block(ref block, _)
if !is_unsafe_block(block)
&& is_simple_block(block, Some(&body.attrs), context.codemap) =>
&& is_simple_block(block, Some(&body.attrs), context.source_map) =>
{
stmt_expr(&block.stmts[0]).unwrap_or(body)
}
Expand Down
6 changes: 3 additions & 3 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use std::{self, borrow::Cow, iter};

use itertools::{multipeek, MultiPeek};
use syntax::codemap::Span;
use syntax::source_map::Span;

use config::Config;
use rewrite::RewriteContext;
Expand Down Expand Up @@ -1151,10 +1151,10 @@ pub fn recover_comment_removed(
// We missed some comments. Warn and keep the original text.
if context.config.error_on_unformatted() {
context.report.append(
context.codemap.span_to_filename(span).into(),
context.source_map.span_to_filename(span).into(),
vec![FormattingError::from_span(
&span,
&context.codemap,
&context.source_map,
ErrorKind::LostComment,
)],
);
Expand Down
12 changes: 6 additions & 6 deletions src/config/file_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ use serde::de::{Deserialize, Deserializer};
use serde::ser::{self, Serialize, Serializer};
use serde_json as json;

use syntax::codemap::{self, FileMap};
use syntax::source_map::{self, SourceFile};

/// A range of lines in a file, inclusive of both ends.
pub struct LineRange {
pub file: Rc<FileMap>,
pub file: Rc<SourceFile>,
pub lo: usize,
pub hi: usize,
}
Expand All @@ -35,11 +35,11 @@ pub enum FileName {
Stdin,
}

impl From<codemap::FileName> for FileName {
fn from(name: codemap::FileName) -> FileName {
impl From<source_map::FileName> for FileName {
fn from(name: source_map::FileName) -> FileName {
match name {
codemap::FileName::Real(p) => FileName::Real(p),
codemap::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
source_map::FileName::Real(p) => FileName::Real(p),
source_map::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
_ => unreachable!(),
}
}
Expand Down
Loading

0 comments on commit f009252

Please sign in to comment.