Skip to content

Commit fc1909d

Browse files
committed
Reformat
1 parent 04d804c commit fc1909d

21 files changed

+41
-35
lines changed

src/chains.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@
6565
//! .qux
6666
//! ```
6767
68-
use source_map::SpanUtils;
6968
use comment::rewrite_comment;
7069
use config::IndentStyle;
7170
use expr::rewrite_call;
7271
use lists::{extract_post_comment, extract_pre_comment, get_comment_end};
7372
use macros::convert_try_mac;
7473
use rewrite::{Rewrite, RewriteContext};
7574
use shape::Shape;
75+
use source_map::SpanUtils;
7676
use utils::{
7777
first_line_width, last_line_extendable, last_line_width, mk_sp, trimmed_last_line_width,
7878
wrap_str,

src/closures.rs

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

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

16-
use source_map::SpanUtils;
1716
use expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond, ToExpr};
1817
use items::{span_hi_for_arg, span_lo_for_arg};
1918
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
2019
use rewrite::{Rewrite, RewriteContext};
2120
use shape::Shape;
21+
use source_map::SpanUtils;
2222
use utils::{last_line_width, left_most_sub_expr, stmt_expr};
2323

2424
// This module is pretty messy because of the rules around closures and blocks:

src/expr.rs

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

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

1919
use chains::rewrite_chain;
2020
use closures;
21-
use source_map::{LineRangeUtils, SpanUtils};
2221
use comment::{
2322
combine_strs_with_missing_comments, contains_comment, recover_comment_removed, rewrite_comment,
2423
rewrite_missing_comment, CharClasses, FindUncommented,
@@ -35,6 +34,7 @@ use pairs::{rewrite_all_pairs, rewrite_pair, PairParts};
3534
use patterns::{can_be_overflowed_pat, is_short_pattern, TuplePatField};
3635
use rewrite::{Rewrite, RewriteContext};
3736
use shape::{Indent, Shape};
37+
use source_map::{LineRangeUtils, SpanUtils};
3838
use spanned::Spanned;
3939
use string::{rewrite_string, StringFormat};
4040
use types::{can_be_overflowed_type, rewrite_path, PathContext};
@@ -425,7 +425,9 @@ fn rewrite_empty_block(
425425
return None;
426426
}
427427

428-
if block.stmts.is_empty() && !block_contains_comment(block, context.source_map) && shape.width >= 2
428+
if block.stmts.is_empty()
429+
&& !block_contains_comment(block, context.source_map)
430+
&& shape.width >= 2
429431
{
430432
return Some(format!("{}{}{{}}", prefix, label_str));
431433
}

src/formatting.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ use std::rc::Rc;
77
use std::time::{Duration, Instant};
88

99
use syntax::ast;
10-
use syntax::source_map::{SourceMap, FilePathMapping, Span};
1110
use syntax::errors::emitter::{ColorConfig, EmitterWriter};
1211
use syntax::errors::Handler;
1312
use syntax::parse::{self, ParseSess};
13+
use syntax::source_map::{FilePathMapping, SourceMap, Span};
1414

1515
use comment::{CharClasses, FullCodeCharKind};
1616
use config::{Config, FileName, Verbosity};
1717
use issues::BadIssueSeeker;
1818
use visitor::{FmtVisitor, SnippetProvider};
19-
use {source_file, modules, ErrorKind, FormatReport, Input, Session};
19+
use {modules, source_file, ErrorKind, FormatReport, Input, Session};
2020

2121
// A map of the files of a crate, with their new content
2222
pub(crate) type SourceFile = Vec<FileRecord>;
@@ -223,7 +223,11 @@ pub(crate) struct FormattingError {
223223
}
224224

225225
impl FormattingError {
226-
pub(crate) fn from_span(span: &Span, source_map: &SourceMap, kind: ErrorKind) -> FormattingError {
226+
pub(crate) fn from_span(
227+
span: &Span,
228+
source_map: &SourceMap,
229+
kind: ErrorKind,
230+
) -> FormattingError {
227231
FormattingError {
228232
line: source_map.lookup_char_pos(span.lo()).line,
229233
is_comment: kind.is_comment(),

src/imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ use config::lists::*;
1414
use syntax::ast::{self, UseTreeKind};
1515
use syntax::source_map::{self, BytePos, Span, DUMMY_SP};
1616

17-
use source_map::SpanUtils;
1817
use comment::combine_strs_with_missing_comments;
1918
use config::IndentStyle;
2019
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator};
2120
use rewrite::{Rewrite, RewriteContext};
2221
use shape::Shape;
22+
use source_map::SpanUtils;
2323
use spanned::Spanned;
2424
use utils::{is_same_visibility, mk_sp, rewrite_ident};
2525
use visitor::FmtVisitor;

src/items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use syntax::source_map::{self, BytePos, Span};
2020
use syntax::visit;
2121
use syntax::{ast, ptr, symbol};
2222

23-
use source_map::{LineRangeUtils, SpanUtils};
2423
use comment::{
2524
combine_strs_with_missing_comments, contains_comment, recover_comment_removed,
2625
recover_missing_comment_in_span, rewrite_missing_comment, FindUncommented,
@@ -35,6 +34,7 @@ use macros::{rewrite_macro, MacroPosition};
3534
use overflow;
3635
use rewrite::{Rewrite, RewriteContext};
3736
use shape::{Indent, Shape};
37+
use source_map::{LineRangeUtils, SpanUtils};
3838
use spanned::Spanned;
3939
use utils::*;
4040
use vertical::rewrite_with_alignment;

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use syntax::ast;
4949

5050
use comment::LineClasses;
5151
use failure::Fail;
52-
use formatting::{SourceFile, FormatErrorMap, FormattingError, ReportedErrors};
52+
use formatting::{FormatErrorMap, FormattingError, ReportedErrors, SourceFile};
5353
use issues::Issue;
5454
use shape::Indent;
5555

@@ -65,11 +65,9 @@ mod attr;
6565
mod chains;
6666
pub(crate) mod checkstyle;
6767
mod closures;
68-
pub(crate) mod source_map;
6968
mod comment;
7069
pub(crate) mod config;
7170
mod expr;
72-
pub(crate) mod source_file;
7371
pub(crate) mod formatting;
7472
mod imports;
7573
mod issues;
@@ -86,6 +84,8 @@ mod reorder;
8684
mod rewrite;
8785
pub(crate) mod rustfmt_diff;
8886
mod shape;
87+
pub(crate) mod source_file;
88+
pub(crate) mod source_map;
8989
mod spanned;
9090
mod string;
9191
#[cfg(test)]

src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@
2222
use std::collections::HashMap;
2323

2424
use config::lists::*;
25-
use syntax::source_map::{BytePos, Span};
2625
use syntax::parse::new_parser_from_tts;
2726
use syntax::parse::parser::Parser;
2827
use syntax::parse::token::{BinOpToken, DelimToken, Token};
2928
use syntax::print::pprust;
29+
use syntax::source_map::{BytePos, Span};
3030
use syntax::symbol;
3131
use syntax::tokenstream::{Cursor, ThinTokenStream, TokenStream, TokenTree};
3232
use syntax::ThinVec;
3333
use syntax::{ast, ptr};
3434

35-
use source_map::SpanUtils;
3635
use comment::{
3736
contains_comment, remove_trailing_white_spaces, CharClasses, FindUncommented, FullCodeCharKind,
3837
LineClasses,
@@ -42,6 +41,7 @@ use lists::{itemize_list, write_list, ListFormatting};
4241
use overflow;
4342
use rewrite::{Rewrite, RewriteContext};
4443
use shape::{Indent, Shape};
44+
use source_map::SpanUtils;
4545
use spanned::Spanned;
4646
use utils::{format_visibility, mk_sp, rewrite_ident, wrap_str};
4747

src/matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use config::lists::*;
1616
use syntax::source_map::{BytePos, Span};
1717
use syntax::{ast, ptr};
1818

19-
use source_map::SpanUtils;
2019
use comment::{combine_strs_with_missing_comments, rewrite_comment};
2120
use config::{Config, ControlBraceStyle, IndentStyle};
2221
use expr::{
@@ -26,6 +25,7 @@ use expr::{
2625
use lists::{itemize_list, write_list, ListFormatting};
2726
use rewrite::{Rewrite, RewriteContext};
2827
use shape::Shape;
28+
use source_map::SpanUtils;
2929
use spanned::Spanned;
3030
use utils::{
3131
contains_skip, extra_offset, first_line_width, inner_attributes, last_line_extendable, mk_sp,

src/missed_spans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use std::borrow::Cow;
1212

1313
use syntax::source_map::{BytePos, Pos, Span};
1414

15-
use source_map::LineRangeUtils;
1615
use comment::{rewrite_comment, CodeCharKind, CommentCodeSlices};
1716
use config::{EmitMode, FileName};
1817
use shape::{Indent, Shape};
18+
use source_map::LineRangeUtils;
1919
use utils::{count_newlines, last_line_width, mk_sp};
2020
use visitor::FmtVisitor;
2121

src/modules.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use std::io;
1313
use std::path::{Path, PathBuf};
1414

1515
use syntax::ast;
16-
use syntax::source_map;
1716
use syntax::parse::{parser, DirectoryOwnership};
17+
use syntax::source_map;
1818
use syntax_pos::symbol::Symbol;
1919

2020
use config::FileName;
@@ -66,8 +66,8 @@ fn list_submodules<'a>(
6666
for item in &module.items {
6767
if let ast::ItemKind::Mod(ref sub_mod) = item.node {
6868
if !contains_skip(&item.attrs) {
69-
let is_internal =
70-
source_map.span_to_filename(item.span) == source_map.span_to_filename(sub_mod.inner);
69+
let is_internal = source_map.span_to_filename(item.span)
70+
== source_map.span_to_filename(sub_mod.inner);
7171
let (dir_path, relative) = if is_internal {
7272
if let Some(path) = find_path_value(&item.attrs) {
7373
(search_dir.join(&path.as_str()), None)

src/overflow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414
use config::lists::*;
1515
use syntax::ast;
16-
use syntax::source_map::Span;
1716
use syntax::parse::token::DelimToken;
17+
use syntax::source_map::Span;
1818

1919
use closures;
20-
use source_map::SpanUtils;
2120
use expr::{is_every_expr_simple, is_method_call, is_nested_call, maybe_get_args_offset, ToExpr};
2221
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator};
2322
use rewrite::{Rewrite, RewriteContext};
2423
use shape::Shape;
24+
use source_map::SpanUtils;
2525
use spanned::Spanned;
2626
use utils::{count_newlines, extra_offset, first_line_width, last_line_width, mk_sp};
2727

src/patterns.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010

1111
use config::lists::*;
1212
use syntax::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax};
13-
use syntax::source_map::{self, BytePos, Span};
1413
use syntax::ptr;
14+
use syntax::source_map::{self, BytePos, Span};
1515

16-
use source_map::SpanUtils;
1716
use comment::FindUncommented;
1817
use expr::{can_be_overflowed_expr, rewrite_unary_prefix, wrap_struct_field};
1918
use lists::{
@@ -25,6 +24,7 @@ use overflow;
2524
use pairs::{rewrite_pair, PairParts};
2625
use rewrite::{Rewrite, RewriteContext};
2726
use shape::Shape;
27+
use source_map::SpanUtils;
2828
use spanned::Spanned;
2929
use types::{rewrite_path, PathContext};
3030
use utils::{format_mutability, mk_sp, rewrite_ident};

src/reorder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ use config::Config;
2020
use syntax::{ast, attr, source_map::Span};
2121

2222
use attr::filter_inline_attrs;
23-
use source_map::LineRangeUtils;
2423
use comment::combine_strs_with_missing_comments;
2524
use imports::{merge_use_trees, UseTree};
2625
use items::{is_mod_decl, rewrite_extern_crate, rewrite_mod};
2726
use lists::{itemize_list, write_list, ListFormatting, ListItem};
2827
use rewrite::{Rewrite, RewriteContext};
2928
use shape::Shape;
29+
use source_map::LineRangeUtils;
3030
use spanned::Spanned;
3131
use utils::mk_sp;
3232
use visitor::FmtVisitor;

src/rewrite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
// A generic trait to abstract the rewriting of an element (of the AST).
1212

13-
use syntax::source_map::{SourceMap, Span};
1413
use syntax::parse::ParseSess;
14+
use syntax::source_map::{SourceMap, Span};
1515

1616
use config::{Config, IndentStyle};
1717
use shape::Shape;

src/source_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! This module contains utilities that work with the `SourceMap` from `libsyntax` / `syntex_syntax`.
11+
//! This module contains utilities that work with the `SourceMap` from `libsyntax`/`syntex_syntax`.
1212
//! This includes extension traits and methods for looking up spans and line ranges for AST nodes.
1313
1414
use config::file_lines::LineRange;

src/test/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use std::path::{Path, PathBuf};
2020
use std::str::Chars;
2121

2222
use config::{Color, Config, EmitMode, FileName, ReportTactic};
23-
use source_file;
24-
use formatting::{SourceFile, ModifiedChunk};
23+
use formatting::{ModifiedChunk, SourceFile};
2524
use rustfmt_diff::{make_diff, print_diff, DiffLine, Mismatch, OutputWriter};
25+
use source_file;
2626
use {FormatReport, Input, Session};
2727

2828
const DIFF_CONTEXT_SIZE: usize = 3;

src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use syntax::ast::{self, FunctionRetTy, Mutability};
1616
use syntax::source_map::{self, BytePos, Span};
1717
use syntax::symbol::keywords;
1818

19-
use source_map::SpanUtils;
2019
use config::{IndentStyle, TypeDensity};
2120
use expr::{rewrite_assign_rhs, rewrite_tuple, rewrite_unary_prefix, ToExpr};
2221
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
@@ -25,6 +24,7 @@ use overflow;
2524
use pairs::{rewrite_pair, PairParts};
2625
use rewrite::{Rewrite, RewriteContext};
2726
use shape::Shape;
27+
use source_map::SpanUtils;
2828
use spanned::Spanned;
2929
use utils::{
3030
colon_spaces, extra_offset, first_line_width, format_abi, format_mutability,

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use syntax::ast::{
1515
self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind, Path,
1616
Visibility, VisibilityKind,
1717
};
18-
use syntax::source_map::{BytePos, Span, NO_EXPANSION};
1918
use syntax::ptr;
19+
use syntax::source_map::{BytePos, Span, NO_EXPANSION};
2020

2121
use comment::filter_normal_code;
2222
use rewrite::RewriteContext;

src/vertical.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ use config::lists::*;
1616
use syntax::ast;
1717
use syntax::source_map::{BytePos, Span};
1818

19-
use source_map::SpanUtils;
2019
use comment::{combine_strs_with_missing_comments, contains_comment};
2120
use expr::rewrite_field;
2221
use items::{rewrite_struct_field, rewrite_struct_field_prefix};
2322
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
2423
use rewrite::{Rewrite, RewriteContext};
2524
use shape::{Indent, Shape};
25+
use source_map::SpanUtils;
2626
use spanned::Spanned;
2727
use utils::{contains_skip, is_attributes_extendable, mk_sp, rewrite_ident};
2828

src/visitor.rs

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

1111
use syntax::attr::HasAttrs;
12-
use syntax::source_map::{self, BytePos, SourceMap, Pos, Span};
1312
use syntax::parse::ParseSess;
13+
use syntax::source_map::{self, BytePos, Pos, SourceMap, Span};
1414
use syntax::{ast, visit};
1515

1616
use attr::*;
17-
use source_map::{LineRangeUtils, SpanUtils};
1817
use comment::{CodeCharKind, CommentCodeSlices, FindUncommented};
1918
use config::{BraceStyle, Config};
2019
use items::{
@@ -26,6 +25,7 @@ use items::{
2625
use macros::{rewrite_macro, rewrite_macro_def, MacroPosition};
2726
use rewrite::{Rewrite, RewriteContext};
2827
use shape::{Indent, Shape};
28+
use source_map::{LineRangeUtils, SpanUtils};
2929
use spanned::Spanned;
3030
use utils::{
3131
self, contains_skip, count_newlines, inner_attributes, mk_sp, ptr_vec_to_ref_vec,

0 commit comments

Comments
 (0)