]> git.lizzy.rs Git - rust.git/blobdiff - src/items.rs
Run rustfmt on the code
[rust.git] / src / items.rs
index f4eb8123603c3fdf558550b1de32bf632447643d..0f7f44f8d99a068dcb48926d85d3cb45c8903800 100644 (file)
@@ -33,8 +33,7 @@ pub fn rewrite_fn(&mut self,
                       abi: &abi::Abi,
                       vis: ast::Visibility,
                       span: Span)
-        -> String
-    {
+                      -> String {
         let newline_brace = self.newline_for_brace(&generics.where_clause);
 
         let mut result = self.rewrite_fn_base(indent,
@@ -67,8 +66,7 @@ pub fn rewrite_required_fn(&mut self,
                                ident: ast::Ident,
                                sig: &ast::MethodSig,
                                span: Span)
-        -> String
-    {
+                               -> String {
         // Drop semicolon or it will be interpreted as comment
         let span = codemap::mk_sp(span.lo, span.hi - BytePos(1));
 
@@ -102,8 +100,7 @@ fn rewrite_fn_base(&mut self,
                        vis: ast::Visibility,
                        span: Span,
                        newline_brace: bool)
-        -> String
-    {
+                       -> String {
         // FIXME we'll lose any comments in between parts of the function decl, but anyone
         // who comments there probably deserves what they get.
 
@@ -165,9 +162,10 @@ fn rewrite_fn_base(&mut self,
                                  .last()
                                  .map(|tp| end_typaram(tp))
                                  .unwrap_or(span.lo);
-        let args_span = codemap::mk_sp(
-            span_after(codemap::mk_sp(args_start, span.hi), "(", self.codemap),
-            span_for_return(&fd.output).lo);
+        let args_span = codemap::mk_sp(span_after(codemap::mk_sp(args_start, span.hi),
+                                                  "(",
+                                                  self.codemap),
+                                       span_for_return(&fd.output).lo);
         result.push_str(&self.rewrite_args(&fd.inputs,
                                            explicit_self,
                                            one_line_budget,
@@ -229,8 +227,7 @@ fn rewrite_args(&self,
                     multi_line_budget: usize,
                     arg_indent: usize,
                     span: Span)
-        -> String
-    {
+                    -> String {
         let mut arg_item_strs: Vec<_> = args.iter().map(|a| self.rewrite_fn_input(a)).collect();
         // Account for sugary self.
         let mut min_args = 1;
@@ -308,15 +305,13 @@ fn rewrite_args(&self,
             item.item = arg;
         }
 
-        let fmt = ListFormatting {
-            tactic: ListTactic::HorizontalVertical,
-            separator: ",",
-            trailing_separator: SeparatorTactic::Never,
-            indent: arg_indent,
-            h_width: one_line_budget,
-            v_width: multi_line_budget,
-            ends_with_newline: true,
-        };
+        let fmt = ListFormatting { tactic: ListTactic::HorizontalVertical,
+                                   separator: ",",
+                                   trailing_separator: SeparatorTactic::Never,
+                                   indent: arg_indent,
+                                   h_width: one_line_budget,
+                                   v_width: multi_line_budget,
+                                   ends_with_newline: true, };
 
         write_list(&arg_items, &fmt)
     }
@@ -326,8 +321,7 @@ fn compute_budgets_for_args(&self,
                                 indent: usize,
                                 ret_str_len: usize,
                                 newline_brace: bool)
-        -> (usize, usize, usize)
-    {
+                                -> (usize, usize, usize) {
         let mut budgets = None;
 
         // Try keeping everything on the same line
@@ -384,8 +378,7 @@ pub fn visit_enum(&mut self,
                       vis: ast::Visibility,
                       enum_def: &ast::EnumDef,
                       generics: &ast::Generics,
-                      span: Span)
-    {
+                      span: Span) {
         let header_str = self.format_header("enum ", ident, vis);
         self.changes.push_str_span(span, &header_str);
 
@@ -416,11 +409,7 @@ pub fn visit_enum(&mut self,
     }
 
     // Variant of an enum
-    fn visit_variant(&mut self,
-                     field: &ast::Variant,
-                     last_field: bool,
-                     next_span_start: BytePos)
-    {
+    fn visit_variant(&mut self, field: &ast::Variant, last_field: bool, next_span_start: BytePos) {
         if self.visit_attrs(&field.node.attrs) {
             return;
         }
@@ -511,8 +500,8 @@ fn format_struct(&self,
                      struct_def: &ast::StructDef,
                      generics: Option<&ast::Generics>,
                      span: Span,
-                     offset: usize) -> String
-    {
+                     offset: usize)
+                     -> String {
         let mut result = String::with_capacity(1024);
 
         let header_str = self.format_header(item_name, ident, vis);
@@ -564,8 +553,7 @@ fn format_struct(&self,
 
         // Conservative approximation
         let single_line_cost = (span.hi - struct_def.fields[0].span.lo).0;
-        let break_line = !is_tuple ||
-                         generics_str.contains('\n') ||
+        let break_line = !is_tuple || generics_str.contains('\n') ||
                          single_line_cost as usize + used_budget > self.config.max_width;
 
         if break_line {
@@ -578,15 +566,13 @@ fn format_struct(&self,
 
         // 1 = ,
         let budget = self.config.ideal_width - offset + self.config.tab_spaces - 1;
-        let fmt = ListFormatting {
-            tactic: tactic,
-            separator: ",",
-            trailing_separator: self.config.struct_trailing_comma,
-            indent: offset + self.config.tab_spaces,
-            h_width: self.config.max_width,
-            v_width: budget,
-            ends_with_newline: false,
-        };
+        let fmt = ListFormatting { tactic: tactic,
+                                   separator: ",",
+                                   trailing_separator: self.config.struct_trailing_comma,
+                                   indent: offset + self.config.tab_spaces,
+                                   h_width: self.config.max_width,
+                                   v_width: budget,
+                                   ends_with_newline: false, };
 
         result.push_str(&write_list(&items, &fmt));
 
@@ -609,8 +595,7 @@ pub fn visit_struct(&mut self,
                         vis: ast::Visibility,
                         struct_def: &ast::StructDef,
                         generics: &ast::Generics,
-                        span: Span)
-    {
+                        span: Span) {
         let indent = self.block_indent;
         let result = self.format_struct("struct ",
                                         ident,
@@ -623,12 +608,7 @@ pub fn visit_struct(&mut self,
         self.last_pos = span.hi;
     }
 
-    fn format_header(&self,
-                     item_name: &str,
-                     ident: ast::Ident,
-                     vis: ast::Visibility)
-        -> String
-    {
+    fn format_header(&self, item_name: &str, ident: ast::Ident, vis: ast::Visibility) -> String {
         format!("{}{}{}", format_visibility(vis), item_name, &token::get_ident(ident))
     }
 
@@ -637,8 +617,7 @@ fn format_generics(&self,
                        opener: &str,
                        offset: usize,
                        span: Span)
-        -> String
-    {
+                       -> String {
         let mut result = self.rewrite_generics(generics, offset, span);
 
         if generics.where_clause.predicates.len() > 0 || result.contains('\n') {
@@ -728,15 +707,13 @@ fn rewrite_generics(&self, generics: &ast::Generics, offset: usize, span: Span)
             item.item = ty;
         }
 
-        let fmt = ListFormatting {
-            tactic: ListTactic::HorizontalVertical,
-            separator: ",",
-            trailing_separator: SeparatorTactic::Never,
-            indent: offset + 1,
-            h_width: budget,
-            v_width: budget,
-            ends_with_newline: true,
-        };
+        let fmt = ListFormatting { tactic: ListTactic::HorizontalVertical,
+                                   separator: ",",
+                                   trailing_separator: SeparatorTactic::Never,
+                                   indent: offset + 1,
+                                   h_width: budget,
+                                   v_width: budget,
+                                   ends_with_newline: true, };
         result.push_str(&write_list(&items, &fmt));
 
         result.push('>');
@@ -748,8 +725,7 @@ fn rewrite_where_clause(&self,
                             where_clause: &ast::WhereClause,
                             indent: usize,
                             span_end: BytePos)
-        -> String
-    {
+                            -> String {
         let mut result = String::new();
         if where_clause.predicates.len() == 0 {
             return result;
@@ -772,15 +748,13 @@ fn rewrite_where_clause(&self,
                                  span_end);
 
         let budget = self.config.ideal_width + self.config.leeway - indent - 10;
-        let fmt = ListFormatting {
-            tactic: ListTactic::Vertical,
-            separator: ",",
-            trailing_separator: SeparatorTactic::Never,
-            indent: indent + 10,
-            h_width: budget,
-            v_width: budget,
-            ends_with_newline: true,
-        };
+        let fmt = ListFormatting { tactic: ListTactic::Vertical,
+                                   separator: ",",
+                                   trailing_separator: SeparatorTactic::Never,
+                                   indent: indent + 10,
+                                   h_width: budget,
+                                   v_width: budget,
+                                   ends_with_newline: true, };
         result.push_str(&write_list(&items, &fmt));
 
         result