update self format

This commit is contained in:
csmoe 2018-04-29 20:22:48 +08:00
parent c9cef5db17
commit f7415bcea2
12 changed files with 100 additions and 58 deletions

View File

@ -1042,8 +1042,10 @@ Item layout inside a imports block
```rust ```rust
use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz}; use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
use foo::{aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb, cccccccccccccccccc, dddddddddddddddddd, use foo::{
eeeeeeeeeeeeeeeeee, ffffffffffffffffff}; aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb, cccccccccccccccccc, dddddddddddddddddd,
eeeeeeeeeeeeeeeeee, ffffffffffffffffff,
};
``` ```
#### `"Horizontal"`: #### `"Horizontal"`:
@ -1061,27 +1063,33 @@ use foo::{aaa, bbb, ccc, ddd, eee, fff};
```rust ```rust
use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz}; use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
use foo::{aaaaaaaaaaaaaaaaaa, use foo::{
bbbbbbbbbbbbbbbbbb, aaaaaaaaaaaaaaaaaa,
cccccccccccccccccc, bbbbbbbbbbbbbbbbbb,
dddddddddddddddddd, cccccccccccccccccc,
eeeeeeeeeeeeeeeeee, dddddddddddddddddd,
ffffffffffffffffff}; eeeeeeeeeeeeeeeeee,
ffffffffffffffffff,
};
``` ```
#### `"Vertical"`: #### `"Vertical"`:
```rust ```rust
use foo::{xxx, use foo::{
yyy, xxx,
zzz}; yyy,
zzz,
};
use foo::{aaa, use foo::{
bbb, aaa,
ccc, bbb,
ddd, ccc,
eee, ddd,
fff}; eee,
fff,
};
``` ```
## `merge_imports` ## `merge_imports`
@ -2036,7 +2044,7 @@ fn foo() {
## `required_version` ## `required_version`
Require a specific version of rustfmt. If you want to make sure that the Require a specific version of rustfmt. If you want to make sure that the
specific version of rustfmt is used in your CI, use this option. specific version of rustfmt is used in your CI, use this option.
- **Default value**: `CARGO_PKG_VERSION` - **Default value**: `CARGO_PKG_VERSION`

View File

@ -24,8 +24,10 @@ use failure::err_msg;
use getopts::{Matches, Options}; use getopts::{Matches, Options};
use rustfmt::{emit_post_matter, emit_pre_matter, load_config, CliOptions, Config, FmtResult, use rustfmt::{
WriteMode, WRITE_MODE_LIST}; emit_post_matter, emit_pre_matter, load_config, CliOptions, Config, FmtResult, WriteMode,
WRITE_MODE_LIST,
};
use rustfmt::{format_and_emit_report, FileName, Input, Summary}; use rustfmt::{format_and_emit_report, FileName, Input, Summary};
fn main() { fn main() {

View File

@ -70,8 +70,10 @@ use expr::rewrite_call;
use macros::convert_try_mac; use macros::convert_try_mac;
use rewrite::{Rewrite, RewriteContext}; use rewrite::{Rewrite, RewriteContext};
use shape::Shape; use shape::Shape;
use utils::{first_line_width, last_line_extendable, last_line_width, mk_sp, use utils::{
trimmed_last_line_width, wrap_str}; first_line_width, last_line_extendable, last_line_width, mk_sp, trimmed_last_line_width,
wrap_str,
};
use std::borrow::Cow; use std::borrow::Cow;
use std::cmp::min; use std::cmp::min;

View File

@ -19,11 +19,15 @@ use syntax::{ast, ptr};
use chains::rewrite_chain; use chains::rewrite_chain;
use closures; use closures;
use codemap::{LineRangeUtils, SpanUtils}; use codemap::{LineRangeUtils, SpanUtils};
use comment::{combine_strs_with_missing_comments, contains_comment, recover_comment_removed, use comment::{
rewrite_comment, rewrite_missing_comment, CharClasses, FindUncommented}; combine_strs_with_missing_comments, contains_comment, recover_comment_removed, rewrite_comment,
rewrite_missing_comment, CharClasses, FindUncommented,
};
use config::{Config, ControlBraceStyle, IndentStyle}; use config::{Config, ControlBraceStyle, IndentStyle};
use lists::{definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, use lists::{
struct_lit_shape, struct_lit_tactic, write_list, ListFormatting, ListItem, Separator}; definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
struct_lit_tactic, write_list, ListFormatting, ListItem, Separator,
};
use macros::{rewrite_macro, MacroArg, MacroPosition}; use macros::{rewrite_macro, MacroArg, MacroPosition};
use matches::rewrite_match; use matches::rewrite_match;
use overflow; use overflow;
@ -33,9 +37,11 @@ use shape::{Indent, Shape};
use spanned::Spanned; use spanned::Spanned;
use string::{rewrite_string, StringFormat}; use string::{rewrite_string, StringFormat};
use types::{can_be_overflowed_type, rewrite_path, PathContext}; use types::{can_be_overflowed_type, rewrite_path, PathContext};
use utils::{colon_spaces, contains_skip, count_newlines, first_line_width, inner_attributes, use utils::{
last_line_extendable, last_line_width, mk_sp, outer_attributes, paren_overhead, colon_spaces, contains_skip, count_newlines, first_line_width, inner_attributes,
ptr_vec_to_ref_vec, semicolon_for_stmt, wrap_str}; last_line_extendable, last_line_width, mk_sp, outer_attributes, paren_overhead,
ptr_vec_to_ref_vec, semicolon_for_stmt, wrap_str,
};
use vertical::rewrite_with_alignment; use vertical::rewrite_with_alignment;
use visitor::FmtVisitor; use visitor::FmtVisitor;

View File

@ -21,11 +21,15 @@ use syntax::visit;
use syntax::{ast, ptr, symbol}; use syntax::{ast, ptr, symbol};
use codemap::{LineRangeUtils, SpanUtils}; use codemap::{LineRangeUtils, SpanUtils};
use comment::{combine_strs_with_missing_comments, contains_comment, recover_comment_removed, use comment::{
recover_missing_comment_in_span, rewrite_missing_comment, FindUncommented}; combine_strs_with_missing_comments, contains_comment, recover_comment_removed,
recover_missing_comment_in_span, rewrite_missing_comment, FindUncommented,
};
use config::{BraceStyle, Config, Density, IndentStyle}; use config::{BraceStyle, Config, Density, IndentStyle};
use expr::{format_expr, is_empty_block, is_simple_block_stmt, rewrite_assign_rhs, use expr::{
rewrite_assign_rhs_with, ExprType, RhsTactics}; format_expr, is_empty_block, is_simple_block_stmt, rewrite_assign_rhs, rewrite_assign_rhs_with,
ExprType, RhsTactics,
};
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator}; use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator};
use macros::{rewrite_macro, MacroPosition}; use macros::{rewrite_macro, MacroPosition};
use overflow; use overflow;
@ -33,11 +37,13 @@ use rewrite::{Rewrite, RewriteContext};
use shape::{Indent, Shape}; use shape::{Indent, Shape};
use spanned::Spanned; use spanned::Spanned;
use types::TraitTyParamBounds; use types::TraitTyParamBounds;
use utils::{colon_spaces, contains_skip, first_line_width, format_abi, format_auto, use utils::{
format_constness, format_defaultness, format_mutability, format_unsafety, colon_spaces, contains_skip, first_line_width, format_abi, format_auto, format_constness,
format_visibility, is_attributes_extendable, last_line_contains_single_line_comment, format_defaultness, format_mutability, format_unsafety, format_visibility,
last_line_used_width, last_line_width, mk_sp, semicolon_for_expr, starts_with_newline, is_attributes_extendable, last_line_contains_single_line_comment, last_line_used_width,
stmt_expr, trimmed_last_line_width}; last_line_width, mk_sp, semicolon_for_expr, starts_with_newline, stmt_expr,
trimmed_last_line_width,
};
use vertical::rewrite_with_alignment; use vertical::rewrite_with_alignment;
use visitor::FmtVisitor; use visitor::FmtVisitor;

View File

@ -33,8 +33,10 @@ use syntax::util::ThinVec;
use syntax::{ast, ptr}; use syntax::{ast, ptr};
use codemap::SpanUtils; use codemap::SpanUtils;
use comment::{contains_comment, remove_trailing_white_spaces, CharClasses, FindUncommented, use comment::{
FullCodeCharKind, LineClasses}; contains_comment, remove_trailing_white_spaces, CharClasses, FindUncommented, FullCodeCharKind,
LineClasses,
};
use expr::rewrite_array; use expr::rewrite_array;
use lists::{itemize_list, write_list, ListFormatting}; use lists::{itemize_list, write_list, ListFormatting};
use overflow; use overflow;

View File

@ -19,14 +19,18 @@ use syntax::{ast, ptr};
use codemap::SpanUtils; use codemap::SpanUtils;
use comment::combine_strs_with_missing_comments; use comment::combine_strs_with_missing_comments;
use config::{Config, ControlBraceStyle, IndentStyle}; use config::{Config, ControlBraceStyle, IndentStyle};
use expr::{format_expr, is_empty_block, is_simple_block, is_unsafe_block, prefer_next_line, use expr::{
rewrite_multiple_patterns, ExprType, RhsTactics, ToExpr}; format_expr, is_empty_block, is_simple_block, is_unsafe_block, prefer_next_line,
rewrite_multiple_patterns, ExprType, RhsTactics, ToExpr,
};
use lists::{itemize_list, write_list, ListFormatting}; use lists::{itemize_list, write_list, ListFormatting};
use rewrite::{Rewrite, RewriteContext}; use rewrite::{Rewrite, RewriteContext};
use shape::Shape; use shape::Shape;
use spanned::Spanned; use spanned::Spanned;
use utils::{contains_skip, extra_offset, first_line_width, inner_attributes, last_line_extendable, use utils::{
mk_sp, ptr_vec_to_ref_vec, trimmed_last_line_width}; contains_skip, extra_offset, first_line_width, inner_attributes, last_line_extendable, mk_sp,
ptr_vec_to_ref_vec, trimmed_last_line_width,
};
/// A simple wrapper type against `ast::Arm`. Used inside `write_list()`. /// A simple wrapper type against `ast::Arm`. Used inside `write_list()`.
struct ArmWrapper<'a> { struct ArmWrapper<'a> {

View File

@ -23,7 +23,9 @@ use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListIte
use rewrite::{Rewrite, RewriteContext}; use rewrite::{Rewrite, RewriteContext};
use shape::Shape; use shape::Shape;
use spanned::Spanned; use spanned::Spanned;
use utils::{count_newlines, extra_offset, first_line_width, last_line_width, mk_sp, paren_overhead}; use utils::{
count_newlines, extra_offset, first_line_width, last_line_width, mk_sp, paren_overhead,
};
use std::cmp::min; use std::cmp::min;

View File

@ -15,10 +15,13 @@ use syntax::ptr;
use codemap::SpanUtils; use codemap::SpanUtils;
use comment::FindUncommented; use comment::FindUncommented;
use expr::{can_be_overflowed_expr, rewrite_pair, rewrite_unary_prefix, wrap_struct_field, use expr::{
PairParts}; can_be_overflowed_expr, rewrite_pair, rewrite_unary_prefix, wrap_struct_field, PairParts,
use lists::{itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape, };
struct_lit_tactic, write_list}; use lists::{
itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape, struct_lit_tactic,
write_list,
};
use macros::{rewrite_macro, MacroPosition}; use macros::{rewrite_macro, MacroPosition};
use overflow; use overflow;
use rewrite::{Rewrite, RewriteContext}; use rewrite::{Rewrite, RewriteContext};

View File

@ -18,16 +18,19 @@ use syntax::symbol::keywords;
use codemap::SpanUtils; use codemap::SpanUtils;
use config::{IndentStyle, TypeDensity}; use config::{IndentStyle, TypeDensity};
use expr::{rewrite_assign_rhs, rewrite_pair, rewrite_tuple, rewrite_unary_prefix, PairParts, use expr::{
ToExpr}; rewrite_assign_rhs, rewrite_pair, rewrite_tuple, rewrite_unary_prefix, PairParts, ToExpr,
};
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator}; use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
use macros::{rewrite_macro, MacroPosition}; use macros::{rewrite_macro, MacroPosition};
use overflow; use overflow;
use rewrite::{Rewrite, RewriteContext}; use rewrite::{Rewrite, RewriteContext};
use shape::Shape; use shape::Shape;
use spanned::Spanned; use spanned::Spanned;
use utils::{colon_spaces, extra_offset, first_line_width, format_abi, format_mutability, use utils::{
last_line_width, mk_sp}; colon_spaces, extra_offset, first_line_width, format_abi, format_mutability, last_line_width,
mk_sp,
};
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum PathContext { pub enum PathContext {

View File

@ -11,8 +11,10 @@
use std::borrow::Cow; use std::borrow::Cow;
use rustc_target::spec::abi; use rustc_target::spec::abi;
use syntax::ast::{self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, use syntax::ast::{
NestedMetaItemKind, Path, Visibility, VisibilityKind}; self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind, Path,
Visibility, VisibilityKind,
};
use syntax::codemap::{BytePos, Span, NO_EXPANSION}; use syntax::codemap::{BytePos, Span, NO_EXPANSION};
use syntax::ptr; use syntax::ptr;

View File

@ -17,9 +17,11 @@ use attr::*;
use codemap::{LineRangeUtils, SpanUtils}; use codemap::{LineRangeUtils, SpanUtils};
use comment::{CodeCharKind, CommentCodeSlices, FindUncommented}; use comment::{CodeCharKind, CommentCodeSlices, FindUncommented};
use config::{BraceStyle, Config}; use config::{BraceStyle, Config};
use items::{format_impl, format_trait, format_trait_alias, is_mod_decl, is_use_item, use items::{
rewrite_associated_impl_type, rewrite_associated_type, rewrite_extern_crate, format_impl, format_trait, format_trait_alias, is_mod_decl, is_use_item,
rewrite_type_alias, FnSig, StaticParts, StructParts}; rewrite_associated_impl_type, rewrite_associated_type, rewrite_extern_crate,
rewrite_type_alias, FnSig, StaticParts, StructParts,
};
use macros::{rewrite_macro, rewrite_macro_def, MacroPosition}; use macros::{rewrite_macro, rewrite_macro_def, MacroPosition};
use rewrite::{Rewrite, RewriteContext}; use rewrite::{Rewrite, RewriteContext};
use shape::{Indent, Shape}; use shape::{Indent, Shape};