Sort imports in alphabetical and consistent order

This commit is contained in:
topecongiro 2017-07-13 18:42:14 +09:00
parent 27b04fec1a
commit 6fd291981e
23 changed files with 147 additions and 142 deletions

View File

@ -24,10 +24,9 @@ use std::str;
use std::collections::HashSet; use std::collections::HashSet;
use std::iter::FromIterator; use std::iter::FromIterator;
use getopts::{Matches, Options};
use json::Value; use json::Value;
use getopts::{Options, Matches};
fn main() { fn main() {
let exit_status = execute(); let exit_status = execute();
std::io::stdout().flush().unwrap(); std::io::stdout().flush().unwrap();

View File

@ -17,10 +17,6 @@ extern crate toml;
extern crate env_logger; extern crate env_logger;
extern crate getopts; extern crate getopts;
use rustfmt::{run, Input, Summary};
use rustfmt::file_lines::FileLines;
use rustfmt::config::{Config, WriteMode, get_toml_path};
use std::{env, error}; use std::{env, error};
use std::fs::File; use std::fs::File;
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
@ -29,6 +25,10 @@ use std::str::FromStr;
use getopts::{Matches, Options}; use getopts::{Matches, Options};
use rustfmt::{run, Input, Summary};
use rustfmt::file_lines::FileLines;
use rustfmt::config::{get_toml_path, Config, WriteMode};
type FmtError = Box<error::Error + Send + Sync>; type FmtError = Box<error::Error + Send + Sync>;
type FmtResult<T> = std::result::Result<T, FmtError>; type FmtResult<T> = std::result::Result<T, FmtError>;

View File

@ -77,11 +77,11 @@
/// ``` /// ```
use Shape; use Shape;
use rewrite::{Rewrite, RewriteContext};
use utils::{wrap_str, first_line_width, last_line_width, mk_sp, last_line_extendable};
use expr::rewrite_call;
use config::IndentStyle; use config::IndentStyle;
use expr::rewrite_call;
use macros::convert_try_mac; use macros::convert_try_mac;
use rewrite::{Rewrite, RewriteContext};
use utils::{first_line_width, last_line_extendable, last_line_width, mk_sp, wrap_str};
use std::cmp::min; use std::cmp::min;
use std::iter; use std::iter;

View File

@ -7,10 +7,11 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use rustfmt_diff::{Mismatch, DiffLine};
use std::io::{self, Write};
use config::WriteMode;
use std::io::{self, Write};
use config::WriteMode;
use rustfmt_diff::{DiffLine, Mismatch};
pub fn output_header<T>(out: &mut T, mode: WriteMode) -> Result<(), io::Error> pub fn output_header<T>(out: &mut T, mode: WriteMode) -> Result<(), io::Error>
where where

View File

@ -17,7 +17,7 @@ use syntax::codemap::Span;
use {Indent, Shape}; use {Indent, Shape};
use config::Config; use config::Config;
use rewrite::RewriteContext; use rewrite::RewriteContext;
use string::{StringFormat, rewrite_string}; use string::{rewrite_string, StringFormat};
use utils::wrap_str; use utils::wrap_str;
fn is_custom_comment(comment: &str) -> bool { fn is_custom_comment(comment: &str) -> bool {
@ -809,8 +809,8 @@ fn remove_comment_header(comment: &str) -> &str {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::{CharClasses, CodeCharKind, FullCodeCharKind, contains_comment, rewrite_comment, use super::{contains_comment, rewrite_comment, CharClasses, CodeCharKind, CommentCodeSlices,
FindUncommented, CommentCodeSlices}; FindUncommented, FullCodeCharKind};
use {Indent, Shape}; use {Indent, Shape};
#[test] #[test]

View File

@ -10,15 +10,14 @@
extern crate toml; extern crate toml;
use std::{env, fs};
use std::cell::Cell; use std::cell::Cell;
use std::fs;
use std::fs::File; use std::fs::File;
use std::env;
use std::io::{Error, ErrorKind, Read}; use std::io::{Error, ErrorKind, Read};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use file_lines::FileLines; use file_lines::FileLines;
use lists::{SeparatorTactic, ListTactic}; use lists::{ListTactic, SeparatorTactic};
macro_rules! configuration_option_enum{ macro_rules! configuration_option_enum{
($e:ident: $( $x:ident ),+ $(,)*) => { ($e:ident: $( $x:ident ),+ $(,)*) => {

View File

@ -8,34 +8,34 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use std::cmp::{Ordering, min}; use std::cmp::{min, Ordering};
use std::iter::ExactSizeIterator;
use std::fmt::Write; use std::fmt::Write;
use std::iter::ExactSizeIterator;
use {Indent, Shape, Spanned};
use codemap::SpanUtils;
use rewrite::{Rewrite, RewriteContext};
use lists::{write_list, itemize_list, ListFormatting, SeparatorTactic, ListTactic,
DefinitiveListTactic, definitive_tactic, ListItem, struct_lit_shape,
struct_lit_tactic, shape_for_tactic, struct_lit_formatting};
use string::{StringFormat, rewrite_string};
use utils::{extra_offset, last_line_width, wrap_str, binary_search, first_line_width,
semicolon_for_stmt, trimmed_last_line_width, left_most_sub_expr, stmt_expr,
colon_spaces, contains_skip, mk_sp, last_line_extendable, paren_overhead};
use visitor::FmtVisitor;
use config::{Config, IndentStyle, MultilineStyle, ControlBraceStyle, Style};
use comment::{FindUncommented, rewrite_comment, contains_comment, recover_comment_removed};
use types::{rewrite_path, PathContext, can_be_overflowed_type};
use items::{span_lo_for_arg, span_hi_for_arg};
use chains::rewrite_chain;
use macros::{rewrite_macro, MacroPosition};
use patterns::{TuplePatField, can_be_overflowed_pat};
use vertical::rewrite_with_alignment;
use syntax::{ast, ptr}; use syntax::{ast, ptr};
use syntax::codemap::{CodeMap, Span, BytePos}; use syntax::codemap::{BytePos, CodeMap, Span};
use syntax::parse::classify; use syntax::parse::classify;
use {Indent, Shape, Spanned};
use chains::rewrite_chain;
use codemap::SpanUtils;
use comment::{contains_comment, recover_comment_removed, rewrite_comment, FindUncommented};
use config::{Config, ControlBraceStyle, IndentStyle, MultilineStyle, Style};
use items::{span_hi_for_arg, span_lo_for_arg};
use lists::{definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting,
struct_lit_shape, struct_lit_tactic, write_list, DefinitiveListTactic, ListFormatting,
ListItem, ListTactic, SeparatorTactic};
use macros::{rewrite_macro, MacroPosition};
use patterns::{can_be_overflowed_pat, TuplePatField};
use rewrite::{Rewrite, RewriteContext};
use string::{rewrite_string, StringFormat};
use types::{can_be_overflowed_type, rewrite_path, PathContext};
use utils::{binary_search, colon_spaces, contains_skip, extra_offset, first_line_width,
last_line_extendable, last_line_width, left_most_sub_expr, mk_sp, paren_overhead,
semicolon_for_stmt, stmt_expr, trimmed_last_line_width, wrap_str};
use vertical::rewrite_with_alignment;
use visitor::FmtVisitor;
impl Rewrite for ast::Expr { impl Rewrite for ast::Expr {
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> { fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
format_expr(self, ExprType::SubExpression, context, shape) format_expr(self, ExprType::SubExpression, context, shape)

View File

@ -11,14 +11,14 @@
// TODO: add tests // TODO: add tests
use std::fs::{self, File};
use std::io::{self, BufWriter, Read, Write};
use strings::string_buffer::StringBuffer; use strings::string_buffer::StringBuffer;
use std::fs::{self, File}; use checkstyle::{output_checkstyle_file, output_footer, output_header};
use std::io::{self, Write, Read, BufWriter}; use config::{Config, NewlineStyle, WriteMode};
use config::{NewlineStyle, Config, WriteMode};
use rustfmt_diff::{make_diff, print_diff, Mismatch}; use rustfmt_diff::{make_diff, print_diff, Mismatch};
use checkstyle::{output_header, output_footer, output_checkstyle_file};
// A map of the files of a crate, with their new content // A map of the files of a crate, with their new content
pub type FileMap = Vec<FileRecord>; pub type FileMap = Vec<FileRecord>;

View File

@ -8,17 +8,18 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use Shape;
use utils;
use syntax::codemap::{BytePos, Span};
use codemap::SpanUtils;
use lists::{write_list, itemize_list, ListItem, ListFormatting, SeparatorTactic, definitive_tactic};
use types::{rewrite_path, PathContext};
use rewrite::{Rewrite, RewriteContext};
use visitor::FmtVisitor;
use std::cmp::{self, Ordering}; use std::cmp::{self, Ordering};
use syntax::{ast, ptr}; use syntax::{ast, ptr};
use syntax::codemap::{BytePos, Span};
use Shape;
use codemap::SpanUtils;
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, SeparatorTactic};
use rewrite::{Rewrite, RewriteContext};
use types::{rewrite_path, PathContext};
use utils;
use visitor::FmtVisitor;
fn path_of(a: &ast::ViewPath_) -> &ast::Path { fn path_of(a: &ast::ViewPath_) -> &ast::Path {
match *a { match *a {

View File

@ -13,6 +13,7 @@
// associated issue number. // associated issue number.
use std::fmt; use std::fmt;
pub use config::ReportTactic; pub use config::ReportTactic;
const TO_DO_CHARS: &'static [char] = &['T', 'O', 'D', 'O']; const TO_DO_CHARS: &'static [char] = &['T', 'O', 'D', 'O'];

View File

@ -10,25 +10,25 @@
// Formatting top-level items - functions, structs, enums, traits, impls. // Formatting top-level items - functions, structs, enums, traits, impls.
use syntax::{abi, ast, ptr, symbol};
use syntax::ast::ImplItem;
use syntax::codemap::{BytePos, Span};
use {Indent, Shape, Spanned}; use {Indent, Shape, Spanned};
use codemap::SpanUtils; use codemap::SpanUtils;
use utils::{format_mutability, format_visibility, contains_skip, end_typaram, wrap_str, use comment::{contains_comment, recover_comment_removed, rewrite_comment, FindUncommented};
last_line_width, format_unsafety, trim_newlines, stmt_expr, semicolon_for_expr, use config::{BraceStyle, Config, Density, IndentStyle, ReturnIndent, Style};
trimmed_last_line_width, colon_spaces, mk_sp};
use lists::{write_list, itemize_list, ListItem, ListFormatting, SeparatorTactic,
DefinitiveListTactic, ListTactic, definitive_tactic};
use expr::{format_expr, is_empty_block, is_simple_block_stmt, rewrite_assign_rhs, use expr::{format_expr, is_empty_block, is_simple_block_stmt, rewrite_assign_rhs,
rewrite_call_inner, ExprType}; rewrite_call_inner, ExprType};
use comment::{FindUncommented, contains_comment, rewrite_comment, recover_comment_removed}; use lists::{definitive_tactic, itemize_list, write_list, DefinitiveListTactic, ListFormatting,
use visitor::FmtVisitor; ListItem, ListTactic, SeparatorTactic};
use rewrite::{Rewrite, RewriteContext}; use rewrite::{Rewrite, RewriteContext};
use config::{Config, IndentStyle, Density, ReturnIndent, BraceStyle, Style};
use types::join_bounds; use types::join_bounds;
use utils::{colon_spaces, contains_skip, end_typaram, format_mutability, format_unsafety,
format_visibility, last_line_width, mk_sp, semicolon_for_expr, stmt_expr,
trim_newlines, trimmed_last_line_width, wrap_str};
use vertical::rewrite_with_alignment; use vertical::rewrite_with_alignment;
use visitor::FmtVisitor;
use syntax::{ast, abi, ptr, symbol};
use syntax::codemap::{Span, BytePos};
use syntax::ast::ImplItem;
fn type_annotation_separator(config: &Config) -> &str { fn type_annotation_separator(config: &Config) -> &str {
colon_spaces( colon_spaces(

View File

@ -28,27 +28,26 @@ extern crate regex;
extern crate diff; extern crate diff;
extern crate term; extern crate term;
use errors::{Handler, DiagnosticBuilder}; use std::collections::HashMap;
use errors::emitter::{ColorConfig, EmitterWriter}; use std::fmt;
use syntax::ast;
use syntax::codemap::{CodeMap, Span, FilePathMapping};
use syntax::parse::{self, ParseSess};
use strings::string_buffer::StringBuffer;
use std::io::{self, stdout, Write}; use std::io::{self, stdout, Write};
use std::ops::{Add, Sub}; use std::ops::{Add, Sub};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::rc::Rc; use std::rc::Rc;
use std::collections::HashMap;
use std::fmt;
use issues::{BadIssueSeeker, Issue}; use errors::{DiagnosticBuilder, Handler};
use filemap::FileMap; use errors::emitter::{ColorConfig, EmitterWriter};
use visitor::FmtVisitor; use strings::string_buffer::StringBuffer;
use syntax::ast;
use syntax::codemap::{CodeMap, FilePathMapping, Span};
use syntax::parse::{self, ParseSess};
use checkstyle::{output_footer, output_header};
use config::Config; use config::Config;
use checkstyle::{output_header, output_footer}; use filemap::FileMap;
use issues::{BadIssueSeeker, Issue};
use utils::mk_sp; use utils::mk_sp;
use visitor::FmtVisitor;
pub use self::summary::Summary; pub use self::summary::Summary;
@ -78,10 +77,6 @@ mod patterns;
mod summary; mod summary;
mod vertical; mod vertical;
const MIN_STRING: usize = 10;
// When we get scoped annotations, we should have rustfmt::skip.
const SKIP_ANNOTATION: &'static str = "rustfmt_skip";
pub trait Spanned { pub trait Spanned {
fn span(&self) -> Span; fn span(&self) -> Span;
} }

View File

@ -11,7 +11,7 @@
use std::cmp; use std::cmp;
use std::iter::Peekable; use std::iter::Peekable;
use syntax::codemap::{CodeMap, BytePos}; use syntax::codemap::{BytePos, CodeMap};
use {Indent, Shape}; use {Indent, Shape};
use comment::{find_comment_end, rewrite_comment, FindUncommented}; use comment::{find_comment_end, rewrite_comment, FindUncommented};

View File

@ -21,17 +21,17 @@
use syntax::ast; use syntax::ast;
use syntax::codemap::BytePos; use syntax::codemap::BytePos;
use syntax::parse::token::Token;
use syntax::parse::new_parser_from_tts; use syntax::parse::new_parser_from_tts;
use syntax::tokenstream::TokenStream; use syntax::parse::token::Token;
use syntax::symbol; use syntax::symbol;
use syntax::tokenstream::TokenStream;
use syntax::util::ThinVec; use syntax::util::ThinVec;
use Shape; use Shape;
use codemap::SpanUtils; use codemap::SpanUtils;
use comment::{contains_comment, FindUncommented};
use expr::{rewrite_array, rewrite_call_inner};
use rewrite::{Rewrite, RewriteContext}; use rewrite::{Rewrite, RewriteContext};
use expr::{rewrite_call_inner, rewrite_array};
use comment::{FindUncommented, contains_comment};
use utils::mk_sp; use utils::mk_sp;
const FORCED_BRACKET_MACROS: &'static [&'static str] = &["vec!"]; const FORCED_BRACKET_MACROS: &'static [&'static str] = &["vec!"];

View File

@ -8,12 +8,12 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use config::WriteMode;
use visitor::FmtVisitor;
use syntax::codemap::{BytePos, Span, Pos};
use comment::{CodeCharKind, CommentCodeSlices, rewrite_comment};
use Shape; use Shape;
use comment::{rewrite_comment, CodeCharKind, CommentCodeSlices};
use config::WriteMode;
use syntax::codemap::{BytePos, Pos, Span};
use utils::mk_sp; use utils::mk_sp;
use visitor::FmtVisitor;
impl<'a> FmtVisitor<'a> { impl<'a> FmtVisitor<'a> {
fn output_at_start(&self) -> bool { fn output_at_start(&self) -> bool {

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use utils;
use std::path::{Path, PathBuf};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use syntax::ast; use syntax::ast;
use syntax::codemap; use syntax::codemap;
use syntax::parse::parser; use syntax::parse::parser;
use utils::contains_skip;
/// List all the files containing modules of a crate. /// List all the files containing modules of a crate.
/// If a file is used twice in a crate, it appears only once. /// If a file is used twice in a crate, it appears only once.
@ -46,7 +46,7 @@ fn list_submodules<'a>(
debug!("list_submodules: search_dir: {:?}", search_dir); debug!("list_submodules: search_dir: {:?}", search_dir);
for item in &module.items { for item in &module.items {
if let ast::ItemKind::Mod(ref sub_mod) = item.node { if let ast::ItemKind::Mod(ref sub_mod) = item.node {
if !utils::contains_skip(&item.attrs) { if !contains_skip(&item.attrs) {
let is_internal = let is_internal =
codemap.span_to_filename(item.span) == codemap.span_to_filename(sub_mod.inner); codemap.span_to_filename(item.span) == codemap.span_to_filename(sub_mod.inner);
let dir_path = if is_internal { let dir_path = if is_internal {

View File

@ -8,21 +8,20 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use Shape; use syntax::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd};
use codemap::SpanUtils;
use rewrite::{Rewrite, RewriteContext};
use utils::{wrap_str, format_mutability, mk_sp};
use lists::{DefinitiveListTactic, SeparatorTactic, itemize_list, struct_lit_shape,
struct_lit_tactic, shape_for_tactic, struct_lit_formatting, write_list};
use expr::{rewrite_call_inner, rewrite_unary_prefix, rewrite_pair, can_be_overflowed_expr,
wrap_struct_field};
use types::{rewrite_path, PathContext};
use super::Spanned;
use comment::FindUncommented;
use syntax::ast::{self, BindingMode, Pat, PatKind, FieldPat, RangeEnd};
use syntax::ptr;
use syntax::codemap::{self, BytePos, Span}; use syntax::codemap::{self, BytePos, Span};
use syntax::ptr;
use {Shape, Spanned};
use codemap::SpanUtils;
use comment::FindUncommented;
use expr::{can_be_overflowed_expr, rewrite_call_inner, rewrite_pair, rewrite_unary_prefix,
wrap_struct_field};
use lists::{itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
struct_lit_tactic, write_list, DefinitiveListTactic, SeparatorTactic};
use rewrite::{Rewrite, RewriteContext};
use types::{rewrite_path, PathContext};
use utils::{format_mutability, mk_sp, wrap_str};
impl Rewrite for Pat { impl Rewrite for Pat {
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> { fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {

View File

@ -1,7 +1,17 @@
use std::collections::VecDeque; // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use diff; use diff;
use term; use std::collections::VecDeque;
use std::io; use std::io;
use term;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum DiffLine { pub enum DiffLine {

View File

@ -10,14 +10,14 @@
// Format string literals. // Format string literals.
use unicode_segmentation::UnicodeSegmentation;
use regex::Regex; use regex::Regex;
use unicode_segmentation::UnicodeSegmentation;
use Shape; use Shape;
use config::Config; use config::Config;
use utils::wrap_str; use utils::wrap_str;
use MIN_STRING; const MIN_STRING: usize = 10;
pub struct StringFormat<'a> { pub struct StringFormat<'a> {
pub opener: &'a str, pub opener: &'a str,
@ -127,7 +127,7 @@ pub fn rewrite_string<'a>(orig: &str, fmt: &StringFormat<'a>) -> Option<String>
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::{StringFormat, rewrite_string}; use super::{rewrite_string, StringFormat};
#[test] #[test]
fn issue343() { fn issue343() {

View File

@ -8,24 +8,24 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use std::ops::Deref;
use std::iter::ExactSizeIterator; use std::iter::ExactSizeIterator;
use std::ops::Deref;
use syntax::abi; use syntax::abi;
use syntax::ast::{self, Mutability, FunctionRetTy}; use syntax::ast::{self, FunctionRetTy, Mutability};
use syntax::codemap::{self, Span, BytePos}; use syntax::codemap::{self, BytePos, Span};
use syntax::print::pprust; use syntax::print::pprust;
use syntax::symbol::keywords; use syntax::symbol::keywords;
use {Shape, Spanned}; use {Shape, Spanned};
use codemap::SpanUtils; use codemap::SpanUtils;
use items::{format_generics_item_list, generics_shape_from_config};
use lists::{write_list, itemize_list, ListFormatting, SeparatorTactic, ListTactic,
definitive_tactic};
use rewrite::{Rewrite, RewriteContext};
use utils::{extra_offset, format_mutability, colon_spaces, wrap_str, mk_sp, last_line_width};
use expr::{rewrite_unary_prefix, rewrite_pair, rewrite_tuple, wrap_args_with_parens};
use config::{IndentStyle, Style, TypeDensity}; use config::{IndentStyle, Style, TypeDensity};
use expr::{rewrite_pair, rewrite_tuple, rewrite_unary_prefix, wrap_args_with_parens};
use items::{format_generics_item_list, generics_shape_from_config};
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListTactic,
SeparatorTactic};
use rewrite::{Rewrite, RewriteContext};
use utils::{colon_spaces, extra_offset, format_mutability, last_line_width, mk_sp, wrap_str};
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum PathContext { pub enum PathContext {

View File

@ -11,15 +11,16 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::cmp::Ordering; use std::cmp::Ordering;
use syntax::ast::{self, Visibility, Attribute, MetaItem, MetaItemKind, NestedMetaItem,
NestedMetaItemKind, Path};
use syntax::codemap::{BytePos, Span, NO_EXPANSION};
use syntax::abi; use syntax::abi;
use syntax::ast::{self, Attribute, MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind,
Path, Visibility};
use syntax::codemap::{BytePos, Span, NO_EXPANSION};
use Shape; use Shape;
use rewrite::{Rewrite, RewriteContext}; use rewrite::{Rewrite, RewriteContext};
use SKIP_ANNOTATION; // When we get scoped annotations, we should have rustfmt::skip.
const SKIP_ANNOTATION: &'static str = "rustfmt_skip";
// Computes the length of a string's last line, minus offset. // Computes the length of a string's last line, minus offset.
pub fn extra_offset(text: &str, shape: Shape) -> usize { pub fn extra_offset(text: &str, shape: Shape) -> usize {

View File

@ -12,6 +12,9 @@
use std::cmp; use std::cmp;
use syntax::ast;
use syntax::codemap::{BytePos, Span};
use {Indent, Shape, Spanned}; use {Indent, Shape, Spanned};
use codemap::SpanUtils; use codemap::SpanUtils;
use comment::contains_comment; use comment::contains_comment;
@ -21,9 +24,6 @@ use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListTac
use rewrite::{Rewrite, RewriteContext}; use rewrite::{Rewrite, RewriteContext};
use utils::{contains_skip, mk_sp}; use utils::{contains_skip, mk_sp};
use syntax::ast;
use syntax::codemap::{Span, BytePos};
pub trait AlignedItem { pub trait AlignedItem {
fn skip(&self) -> bool; fn skip(&self) -> bool;
fn get_span(&self) -> Span; fn get_span(&self) -> Span;

View File

@ -10,24 +10,23 @@
use std::cmp; use std::cmp;
use strings::string_buffer::StringBuffer;
use syntax::{ast, ptr, visit}; use syntax::{ast, ptr, visit};
use syntax::codemap::{CodeMap, Span, BytePos}; use syntax::codemap::{BytePos, CodeMap, Span};
use syntax::parse::ParseSess; use syntax::parse::ParseSess;
use strings::string_buffer::StringBuffer;
use {Indent, Shape}; use {Indent, Shape};
use expr::{format_expr, ExprType};
use utils::{self, mk_sp};
use codemap::{LineRangeUtils, SpanUtils}; use codemap::{LineRangeUtils, SpanUtils};
use comment::{contains_comment, FindUncommented}; use comment::{contains_comment, FindUncommented};
use config::Config;
use rewrite::{Rewrite, RewriteContext};
use comment::rewrite_comment; use comment::rewrite_comment;
use macros::{rewrite_macro, MacroPosition}; use config::Config;
use items::{rewrite_static, rewrite_associated_type, rewrite_associated_impl_type, use expr::{format_expr, ExprType};
rewrite_type_alias, format_impl, format_trait}; use items::{format_impl, format_trait, rewrite_associated_impl_type, rewrite_associated_type,
rewrite_static, rewrite_type_alias};
use lists::{itemize_list, write_list, DefinitiveListTactic, ListFormatting, SeparatorTactic}; use lists::{itemize_list, write_list, DefinitiveListTactic, ListFormatting, SeparatorTactic};
use macros::{rewrite_macro, MacroPosition};
use rewrite::{Rewrite, RewriteContext};
use utils::{self, mk_sp};
fn is_use_item(item: &ast::Item) -> bool { fn is_use_item(item: &ast::Item) -> bool {
match item.node { match item.node {