diff options
| author | Marcus Klaas <mail@marcusklaas.nl> | 2015-11-14 21:59:04 +0100 |
|---|---|---|
| committer | Marcus Klaas <mail@marcusklaas.nl> | 2015-11-20 21:09:34 +0100 |
| commit | 7b0cceafeea2b722a941cc5456534cede9053334 (patch) | |
| tree | 3e959fb51f0784f3e7268f2da496d02e451a9a47 /src | |
| parent | 6e1f77664df56e3ebf21c35a5a8abb77e68d079c (diff) | |
Force chains to adhere to restrictions
Diffstat (limited to 'src')
| -rw-r--r-- | src/chains.rs | 21 | ||||
| -rw-r--r-- | src/items.rs | 14 |
2 files changed, 18 insertions, 17 deletions
diff --git a/src/chains.rs b/src/chains.rs index a011ad2ffef..665fb5ac073 100644 --- a/src/chains.rs +++ b/src/chains.rs @@ -21,7 +21,7 @@ use Indent; use rewrite::{Rewrite, RewriteContext}; -use utils::first_line_width; +use utils::{wrap_str, first_line_width}; use expr::rewrite_call; use config::BlockIndentStyle; @@ -58,12 +58,8 @@ pub fn rewrite_chain(mut expr: &ast::Expr, } else { match context.config.chain_indent { BlockIndentStyle::Inherit => (context.block_indent, false), - BlockIndentStyle::Tabbed => { - (context.block_indent.block_indent(context.config), false) - } - BlockIndentStyle::Visual => { - (offset + Indent::new(context.config.tab_spaces, 0), false) - } + BlockIndentStyle::Tabbed => (context.block_indent.block_indent(context.config), false), + BlockIndentStyle::Visual => (offset + Indent::new(context.config.tab_spaces, 0), false), } }; @@ -142,10 +138,13 @@ pub fn rewrite_chain(mut expr: &ast::Expr, &connector[..] }; - Some(format!("{}{}{}", - parent_rewrite, - first_connector, - rewrites.join(&connector))) + wrap_str(format!("{}{}{}", + parent_rewrite, + first_connector, + rewrites.join(&connector)), + context.config.max_width, + width, + offset) } // States whether an expression's last line exclusively consists of closing diff --git a/src/items.rs b/src/items.rs index 4f3c82ee0ab..19aec73f116 100644 --- a/src/items.rs +++ b/src/items.rs @@ -875,12 +875,14 @@ impl<'a> FmtVisitor<'a> { offset + header_str.len(), mk_sp(span.lo, body_lo))) } - None => if self.config.item_brace_style == BraceStyle::AlwaysNextLine && - !fields.is_empty() { - format!("\n{}{{", self.block_indent.to_string(self.config)) - } else { - " {".to_owned() - }, + None => { + if self.config.item_brace_style == BraceStyle::AlwaysNextLine && + !fields.is_empty() { + format!("\n{}{{", self.block_indent.to_string(self.config)) + } else { + " {".to_owned() + } + } }; result.push_str(&generics_str); |
