]> git.lizzy.rs Git - rust.git/commitdiff
Cargo fmt
authorSeiichi Uchida <seuchida@gmail.com>
Mon, 22 Jan 2018 04:05:18 +0000 (13:05 +0900)
committerSeiichi Uchida <seuchida@gmail.com>
Mon, 22 Jan 2018 04:05:18 +0000 (13:05 +0900)
18 files changed:
src/bin/rustfmt.rs
src/closures.rs
src/comment.rs
src/expr.rs
src/file_lines.rs
src/imports.rs
src/issues.rs
src/items.rs
src/lib.rs
src/lists.rs
src/rustfmt_diff.rs
src/shape.rs
src/string.rs
src/types.rs
src/vertical.rs
src/visitor.rs
tests/target/closure.rs
tests/target/impl.rs

index ba586e1fd913db3d6d5c82b08843c2b8af4ff936..66ee49297a3649182bc4a5e71f6d62038ca9b5f2 100644 (file)
@@ -453,7 +453,7 @@ fn determine_operation(matches: &Matches) -> FmtResult<Operation> {
 
         return Ok(Operation::Stdin {
             input: buffer,
-            config_path: config_path,
+            config_path,
         });
     }
 
@@ -469,8 +469,8 @@ fn determine_operation(matches: &Matches) -> FmtResult<Operation> {
         .collect();
 
     Ok(Operation::Format {
-        files: files,
-        config_path: config_path,
-        minimal_config_path: minimal_config_path,
+        files,
+        config_path,
+        minimal_config_path,
     })
 }
index f63242f635540102530a9e9137eb3c6b6a05ba38..fcb985ebf1247c8b73c9b868f49379210231d347 100644 (file)
@@ -244,7 +244,7 @@ fn rewrite_closure_fn_decl(
     };
 
     let fmt = ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: ",",
         trailing_separator: SeparatorTactic::Never,
         separator_place: SeparatorPlace::Back,
index eb9e96f2509f1bf3f40204fb85bceef38ce18ecd..edcd5153fc37b0e617e0f1a84fbc566e4fbeea2c 100644 (file)
@@ -285,11 +285,11 @@ fn rewrite_comment_inner(
     let mut fmt = StringFormat {
         opener: "",
         closer: "",
-        line_start: line_start,
+        line_start,
         line_end: "",
         shape: Shape::legacy(max_chars, fmt_indent),
         trim_end: true,
-        config: config,
+        config,
     };
 
     let line_breaks = count_newlines(orig.trim_right());
@@ -895,7 +895,7 @@ pub struct CommentCodeSlices<'a> {
 impl<'a> CommentCodeSlices<'a> {
     pub fn new(slice: &'a str) -> CommentCodeSlices<'a> {
         CommentCodeSlices {
-            slice: slice,
+            slice,
             last_slice_kind: CodeCharKind::Comment,
             last_slice_end: 0,
         }
@@ -1019,7 +1019,7 @@ fn new(comment: &'a str) -> CommentReducer<'a> {
         let is_block = comment.starts_with("/*");
         let comment = remove_comment_header(comment);
         CommentReducer {
-            is_block: is_block,
+            is_block,
             at_start_line: false, // There are no supplementary '*' on the first line
             iter: comment.chars(),
         }
index 09917ca088b5d22c0c0f6e970a070a0b5b08e937..d59e383389ff9498f3df8346a54d820f3ff0fc5d 100644 (file)
@@ -441,7 +441,7 @@ pub fn rewrite_array<T: Rewrite + Spanned + ToExpr>(
     let ends_with_newline = tactic.ends_with_newline(context.config.indent_style());
 
     let fmt = ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: ",",
         trailing_separator: if trailing_comma {
             SeparatorTactic::Always
@@ -462,7 +462,7 @@ pub fn rewrite_array<T: Rewrite + Spanned + ToExpr>(
         },
         separator_place: SeparatorPlace::Back,
         shape: nested_shape,
-        ends_with_newline: ends_with_newline,
+        ends_with_newline,
         preserve_newline: false,
         config: context.config,
     };
@@ -779,19 +779,19 @@ fn new_if(
     ) -> ControlFlow<'a> {
         ControlFlow {
             cond: Some(cond),
-            block: block,
-            else_block: else_block,
+            block,
+            else_block,
             label: None,
-            pat: pat,
+            pat,
             keyword: "if",
             matcher: match pat {
                 Some(..) => "let",
                 None => "",
             },
             connector: " =",
-            allow_single_line: allow_single_line,
-            nested_if: nested_if,
-            span: span,
+            allow_single_line,
+            nested_if,
+            span,
         }
     }
 
@@ -802,16 +802,16 @@ fn new_loop(
     ) -> ControlFlow<'a> {
         ControlFlow {
             cond: None,
-            block: block,
+            block,
             else_block: None,
-            label: label,
+            label,
             pat: None,
             keyword: "loop",
             matcher: "",
             connector: "",
             allow_single_line: false,
             nested_if: false,
-            span: span,
+            span,
         }
     }
 
@@ -824,10 +824,10 @@ fn new_while(
     ) -> ControlFlow<'a> {
         ControlFlow {
             cond: Some(cond),
-            block: block,
+            block,
             else_block: None,
-            label: label,
-            pat: pat,
+            label,
+            pat,
             keyword: "while",
             matcher: match pat {
                 Some(..) => "let",
@@ -836,7 +836,7 @@ fn new_while(
             connector: " =",
             allow_single_line: false,
             nested_if: false,
-            span: span,
+            span,
         }
     }
 
@@ -849,16 +849,16 @@ fn new_for(
     ) -> ControlFlow<'a> {
         ControlFlow {
             cond: Some(cond),
-            block: block,
+            block,
             else_block: None,
-            label: label,
+            label,
             pat: Some(pat),
             keyword: "for",
             matcher: "",
             connector: " in",
             allow_single_line: false,
             nested_if: false,
-            span: span,
+            span,
         }
     }
 
@@ -1484,7 +1484,7 @@ fn rewrite_match_pattern(
         )
     };
     let fmt = ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: " |",
         trailing_separator: SeparatorTactic::Never,
         separator_place: context.config.binop_separator(),
@@ -1988,7 +1988,7 @@ fn rewrite_call_args<'a, T>(
     );
 
     let fmt = ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: ",",
         trailing_separator: if force_trailing_comma {
             SeparatorTactic::Always
@@ -2671,11 +2671,11 @@ fn rewrite_tuple_in_visual_indent_style<'a, T>(
         nested_shape.width,
     );
     let fmt = ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: ",",
         trailing_separator: SeparatorTactic::Never,
         separator_place: SeparatorPlace::Back,
-        shape: shape,
+        shape,
         ends_with_newline: false,
         preserve_newline: false,
         config: context.config,
index 7f2273c6f6926a481a8e31c0156641ae3225ac8a..028c631b1b97eed86216efbf096e8b06b3d9858a 100644 (file)
@@ -34,7 +34,7 @@ fn from(range: &'a LineRange) -> Range {
 
 impl Range {
     pub fn new(lo: usize, hi: usize) -> Range {
-        Range { lo: lo, hi: hi }
+        Range { lo, hi }
     }
 
     fn is_empty(self) -> bool {
index c49a95b6ff796b725f058ebc728d86d1876de86c..2fd851430444740f7c1b6a9c9af34ed3fbeae10e 100644 (file)
@@ -284,7 +284,7 @@ fn rewrite_imports(
         separator: "",
         trailing_separator: SeparatorTactic::Never,
         separator_place: SeparatorPlace::Back,
-        shape: shape,
+        shape,
         ends_with_newline: true,
         preserve_newline: false,
         config: context.config,
@@ -537,7 +537,7 @@ fn rewrite_nested_use_tree(
         && tactic != DefinitiveListTactic::Horizontal;
 
     let fmt = ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: ",",
         trailing_separator: if ends_with_newline {
             context.config.trailing_comma()
@@ -546,7 +546,7 @@ fn rewrite_nested_use_tree(
         },
         separator_place: SeparatorPlace::Back,
         shape: nested_shape,
-        ends_with_newline: ends_with_newline,
+        ends_with_newline,
         preserve_newline: true,
         config: context.config,
     };
index 6cd0586f3e458d1fc6d0cb3c258ca33b3ac2eab2..2efd61a3d7d458851c4f05770134a368b15264b9 100644 (file)
@@ -90,8 +90,8 @@ pub fn new(report_todo: ReportTactic, report_fixme: ReportTactic) -> BadIssueSee
                 todo_idx: 0,
                 fixme_idx: 0,
             },
-            report_todo: report_todo,
-            report_fixme: report_fixme,
+            report_todo,
+            report_fixme,
         }
     }
 
@@ -169,8 +169,8 @@ fn inspect_issue(&mut self, c: char, mut todo_idx: usize, mut fixme_idx: usize)
         }
 
         Seeking::Issue {
-            todo_idx: todo_idx,
-            fixme_idx: fixme_idx,
+            todo_idx,
+            fixme_idx,
         }
     }
 
@@ -213,10 +213,7 @@ fn inspect_number(
             NumberPart::CloseParen => {}
         }
 
-        self.state = Seeking::Number {
-            part: part,
-            issue: issue,
-        };
+        self.state = Seeking::Number { part, issue };
 
         IssueClassification::None
     }
index fcf545a37bd9ba49813579f7c8d9c362b0c11ef9..fdd769ef2895d63932deeda047195dc37acec407 100644 (file)
@@ -138,7 +138,7 @@ fn from_foreign_mod(fm: &'a ast::ForeignMod, span: Span, config: &Config) -> Ite
                 .iter()
                 .map(|i| BodyElement::ForeignItem(i))
                 .collect(),
-            span: span,
+            span,
         }
     }
 }
@@ -169,8 +169,8 @@ pub fn new(
         vis: ast::Visibility,
     ) -> FnSig<'a> {
         FnSig {
-            decl: decl,
-            generics: generics,
+            decl,
+            generics,
             abi: abi::Abi::Rust,
             constness: ast::Constness::NotConst,
             defaultness: ast::Defaultness::Final,
@@ -189,7 +189,7 @@ pub fn from_method_sig(
             defaultness: ast::Defaultness::Final,
             abi: method_sig.abi,
             decl: &*method_sig.decl,
-            generics: generics,
+            generics,
             visibility: ast::Visibility::Inherited,
         }
     }
@@ -202,12 +202,12 @@ pub fn from_fn_kind(
     ) -> FnSig<'a> {
         match *fn_kind {
             visit::FnKind::ItemFn(_, unsafety, constness, abi, visibility, _) => FnSig {
-                decl: decl,
-                generics: generics,
-                abi: abi,
+                decl,
+                generics,
+                abi,
                 constness: constness.node,
                 defaultness: defualtness,
-                unsafety: unsafety,
+                unsafety,
                 visibility: visibility.clone(),
             },
             visit::FnKind::Method(_, method_sig, vis, _) => {
@@ -510,7 +510,7 @@ fn format_variant_list(
             separator: ",",
             trailing_separator: self.config.trailing_comma(),
             separator_place: SeparatorPlace::Back,
-            shape: shape,
+            shape,
             ends_with_newline: true,
             preserve_newline: true,
             config: self.config,
@@ -895,10 +895,10 @@ pub fn from_item(item: &'a ast::Item) -> Self {
             _ => unreachable!(),
         };
         StructParts {
-            prefix: prefix,
+            prefix,
             ident: item.ident,
             vis: &item.vis,
-            def: def,
+            def,
             generics: Some(generics),
             span: item.span,
         }
@@ -1509,11 +1509,11 @@ pub fn from_item(item: &'a ast::Item) -> Self {
             _ => unreachable!(),
         };
         StaticParts {
-            prefix: prefix,
+            prefix,
             vis: &item.vis,
             ident: item.ident,
-            ty: ty,
-            mutability: mutability,
+            ty,
+            mutability,
             expr_opt: Some(expr),
             defaultness: None,
             span: item.span,
@@ -1529,7 +1529,7 @@ pub fn from_trait_item(ti: &'a ast::TraitItem) -> Self {
             prefix: "const",
             vis: &ast::Visibility::Inherited,
             ident: ti.ident,
-            ty: ty,
+            ty,
             mutability: ast::Mutability::Immutable,
             expr_opt: expr_opt.as_ref(),
             defaultness: None,
@@ -1546,7 +1546,7 @@ pub fn from_impl_item(ii: &'a ast::ImplItem) -> Self {
             prefix: "const",
             vis: &ii.vis,
             ident: ii.ident,
-            ty: ty,
+            ty,
             mutability: ast::Mutability::Immutable,
             expr_opt: Some(expr),
             defaultness: Some(ii.defaultness),
@@ -1818,7 +1818,7 @@ fn rewrite_fn_base(
     let one_line_budget = context.budget(used_width + overhead);
     let shape = Shape {
         width: one_line_budget,
-        indent: indent,
+        indent,
         offset: used_width,
     };
     let fd = fn_sig.decl;
@@ -2085,8 +2085,8 @@ struct WhereClauseOption {
 impl WhereClauseOption {
     pub fn new(suppress_comma: bool, snuggle: bool) -> WhereClauseOption {
         WhereClauseOption {
-            suppress_comma: suppress_comma,
-            snuggle: snuggle,
+            suppress_comma,
+            snuggle,
             compress_where: false,
         }
     }
@@ -2233,7 +2233,7 @@ enum ArgumentKind<'a> {
     debug!("rewrite_args: budget: {}, tactic: {:?}", budget, tactic);
 
     let fmt = ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: ",",
         trailing_separator: if variadic {
             SeparatorTactic::Never
@@ -2404,7 +2404,7 @@ pub fn format_generics_item_list<I>(
         one_line_budget,
     );
     let fmt = ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: ",",
         trailing_separator: if context.config.indent_style() == IndentStyle::Visual {
             SeparatorTactic::Never
@@ -2412,7 +2412,7 @@ pub fn format_generics_item_list<I>(
             context.config.trailing_comma()
         },
         separator_place: SeparatorPlace::Back,
-        shape: shape,
+        shape,
         ends_with_newline: tactic.ends_with_newline(context.config.indent_style()),
         preserve_newline: true,
         config: context.config,
@@ -2637,7 +2637,7 @@ fn rewrite_where_clause(
     }
 
     let fmt = ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: ",",
         trailing_separator: comma_tactic,
         separator_place: SeparatorPlace::Back,
index 817188925cdb92c87238b94b3c9a2d351a2ad246..ec846de04dbd9dd6d298ea321155cf30d13f6f02 100644 (file)
@@ -448,7 +448,7 @@ fn format_lines(
                         line: cur_line,
                         kind: error_kind,
                         is_comment: kind.is_comment(),
-                        is_string: is_string,
+                        is_string,
                         line_buffer: line_buffer.clone(),
                     });
                 }
index 193cd4f3c32e0bb33063a32bcff0522697a67ecf..aa1e0b430ef745b851ad3ae0d42871dc128d24d7 100644 (file)
@@ -690,15 +690,15 @@ fn next(&mut self) -> Option<Self::Item> {
             };
 
             ListItem {
-                pre_comment: pre_comment,
-                pre_comment_style: pre_comment_style,
+                pre_comment,
+                pre_comment_style,
                 item: if self.inner.peek().is_none() && self.leave_last {
                     None
                 } else {
                     (self.get_item_string)(&item)
                 },
-                post_comment: post_comment,
-                new_lines: new_lines,
+                post_comment,
+                new_lines,
             }
         })
     }
@@ -724,16 +724,16 @@ pub fn itemize_list<'a, T, I, F1, F2, F3>(
     F3: Fn(&T) -> Option<String>,
 {
     ListItems {
-        codemap: codemap,
+        codemap,
         inner: inner.peekable(),
-        get_lo: get_lo,
-        get_hi: get_hi,
-        get_item_string: get_item_string,
-        prev_span_end: prev_span_end,
-        next_span_start: next_span_start,
-        terminator: terminator,
-        separator: separator,
-        leave_last: leave_last,
+        get_lo,
+        get_hi,
+        get_item_string,
+        prev_span_end,
+        next_span_start,
+        terminator,
+        separator,
+        leave_last,
     }
 }
 
@@ -841,7 +841,7 @@ pub fn struct_lit_formatting<'a>(
     let ends_with_newline = context.config.indent_style() != IndentStyle::Visual
         && tactic == DefinitiveListTactic::Vertical;
     ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: ",",
         trailing_separator: if force_no_trailing_comma {
             SeparatorTactic::Never
@@ -849,8 +849,8 @@ pub fn struct_lit_formatting<'a>(
             context.config.trailing_comma()
         },
         separator_place: SeparatorPlace::Back,
-        shape: shape,
-        ends_with_newline: ends_with_newline,
+        shape,
+        ends_with_newline,
         preserve_newline: true,
         config: context.config,
     }
index d563e6eee3c17b44438dca410c8002dedcd9c67a..1a2f570f89efdad8d2161db70107b51e7271d217 100644 (file)
@@ -31,7 +31,7 @@ pub struct Mismatch {
 impl Mismatch {
     fn new(line_number: u32) -> Mismatch {
         Mismatch {
-            line_number: line_number,
+            line_number,
             lines: Vec::new(),
         }
     }
index fffbe2b9913ea5a392c81813e1e2eff0b21557ed..8fe2e2b18c0b1e7b653a6ad485041fd0ffc1e98d 100644 (file)
@@ -29,8 +29,8 @@ pub struct Indent {
 impl Indent {
     pub fn new(block_indent: usize, alignment: usize) -> Indent {
         Indent {
-            block_indent: block_indent,
-            alignment: alignment,
+            block_indent,
+            alignment,
         }
     }
 
@@ -161,8 +161,8 @@ impl Shape {
     //        |<--->|    width
     pub fn legacy(width: usize, indent: Indent) -> Shape {
         Shape {
-            width: width,
-            indent: indent,
+            width,
+            indent,
             offset: indent.alignment,
         }
     }
@@ -170,7 +170,7 @@ pub fn legacy(width: usize, indent: Indent) -> Shape {
     pub fn indented(indent: Indent, config: &Config) -> Shape {
         Shape {
             width: config.max_width().checked_sub(indent.width()).unwrap_or(0),
-            indent: indent,
+            indent,
             offset: indent.alignment,
         }
     }
@@ -187,9 +187,9 @@ pub fn with_max_width(&self, config: &Config) -> Shape {
 
     pub fn offset(width: usize, indent: Indent, offset: usize) -> Shape {
         Shape {
-            width: width,
-            indent: indent,
-            offset: offset,
+            width,
+            indent,
+            offset,
         }
     }
 
index 43b1ccbcb937146caa602c4781e56ed46f5f664f..2386d90ec8af8e581f19f862b74f4d7530d638fb 100644 (file)
@@ -36,9 +36,9 @@ pub fn new(shape: Shape, config: &'a Config) -> StringFormat<'a> {
             closer: "\"",
             line_start: " ",
             line_end: "\\",
-            shape: shape,
+            shape,
             trim_end: false,
-            config: config,
+            config,
         }
     }
 }
index 588d9100fe6043f3d078205100653469e838dd17..a7472567a81bc246d2f02f18c30b9b039e945736 100644 (file)
@@ -352,7 +352,7 @@ enum ArgumentKind<T>
     );
 
     let fmt = ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: ",",
         trailing_separator: if !context.use_block_indent() || variadic {
             SeparatorTactic::Never
index e56410202eb92f9a6f006e5c8575c7a7ca3593e7..2ccb5d813393dab95be3a5ea60bb5f9919423a35 100644 (file)
@@ -247,7 +247,7 @@ fn rewrite_aligned_items_inner<T: AlignedItem>(
     );
 
     let fmt = ListFormatting {
-        tactic: tactic,
+        tactic,
         separator: ",",
         trailing_separator: context.config.trailing_comma(),
         separator_place: SeparatorPlace::Back,
index 2d7d140c1799bb2a04ac1b47b81d80a4da058335..83d5bca40523da77405ce61118bea6e86b6a52e0 100644 (file)
@@ -576,14 +576,14 @@ pub fn from_codemap(
         snippet_provider: &'a SnippetProvider,
     ) -> FmtVisitor<'a> {
         FmtVisitor {
-            parse_session: parse_session,
+            parse_session,
             codemap: parse_session.codemap(),
             buffer: String::with_capacity(snippet_provider.big_snippet.len() * 2),
             last_pos: BytePos(0),
             block_indent: Indent::empty(),
-            config: config,
+            config,
             is_if_else_block: false,
-            snippet_provider: snippet_provider,
+            snippet_provider,
             line_number: 0,
             skipped_range: vec![],
         }
index 5bc89d582229666f9d4a75623776e8b93b029404..54ad25b1b377619672b89d59914770b0bf40edc7 100644 (file)
@@ -147,7 +147,7 @@ fn issue470() {
                             hair::PatternRef::Hair(pattern),
                             &lvalue,
                         );
-                        ArgDecl { ty: ty }
+                        ArgDecl { ty }
                     },
                 );
             }
index 99922d406f441b9515ab5cb272808a673c5342be..5895c74bcc9f1d5dcff6a118e8778ac25c0e6fa8 100644 (file)
@@ -13,7 +13,7 @@ impl<V> Test<V>
     pub fn new(value: V) -> Self {
         Test {
             cloned_value: value.clone(),
-            value: value,
+            value,
         }
     }
 }