From f2bcee9d873adaf31dfdc5aee06ff89c0373e2b3 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Thu, 16 Jul 2015 14:23:48 +1200 Subject: [PATCH] Tidy up some overrunning lines --- src/expr.rs | 4 +++- src/items.rs | 8 +++++--- src/types.rs | 21 ++++++++++++++------- src/visitor.rs | 4 +++- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index 33a82da0f29..7110d508d5d 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -315,7 +315,9 @@ fn rewrite_binary_op(context: &RewriteContext, // 1 = space between lhs expr and operator let mut result = - try_opt!(lhs.rewrite(context, context.config.max_width - offset - 1 - operator_str.len(), offset)); + try_opt!(lhs.rewrite(context, + context.config.max_width - offset - 1 - operator_str.len(), + offset)); result.push(' '); result.push_str(&operator_str); diff --git a/src/items.rs b/src/items.rs index 0f7f44f8d99..4b473dff4ba 100644 --- a/src/items.rs +++ b/src/items.rs @@ -467,8 +467,9 @@ fn visit_variant(&mut self, field: &ast::Variant, last_field: bool, next_span_st // Make sure we do not exceed column limit // 4 = " = ," - assert!(self.config.max_width >= vis.len() + name.len() + expr_snippet.len() + 4, - "Enum variant exceeded column limit"); + assert!( + self.config.max_width >= vis.len() + name.len() + expr_snippet.len() + 4, + "Enum variant exceeded column limit"); } result @@ -768,7 +769,8 @@ fn rewrite_return(&self, ret: &ast::FunctionRetTy) -> String { } } - // TODO we farm this out, but this could spill over the column limit, so we ought to handle it properly + // TODO we farm this out, but this could spill over the column limit, so we + // ought to handle it properly. fn rewrite_fn_input(&self, arg: &ast::Arg) -> String { format!("{}: {}", pprust::pat_to_string(&arg.pat), diff --git a/src/types.rs b/src/types.rs index 6880cd8bcc2..3ac82ae27ee 100644 --- a/src/types.rs +++ b/src/types.rs @@ -25,14 +25,17 @@ pub fn rewrite_pred(&self, predicate: &ast::WherePredicate) -> String { ..}) => { if bound_lifetimes.len() > 0 { format!("for<{}> {}: {}", - bound_lifetimes.iter().map(|l| self.rewrite_lifetime_def(l)).collect::>().connect(", "), + bound_lifetimes.iter().map(|l| self.rewrite_lifetime_def(l)) + .collect::>().connect(", "), pprust::ty_to_string(bounded_ty), - bounds.iter().map(|b| self.rewrite_ty_bound(b)).collect::>().connect(" + ")) + bounds.iter().map(|b| self.rewrite_ty_bound(b)) + .collect::>().connect(" + ")) } else { format!("{}: {}", pprust::ty_to_string(bounded_ty), - bounds.iter().map(|b| self.rewrite_ty_bound(b)).collect::>().connect(" + ")) + bounds.iter().map(|b| self.rewrite_ty_bound(b)) + .collect::>().connect(" + ")) } } &ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime, @@ -40,7 +43,8 @@ pub fn rewrite_pred(&self, predicate: &ast::WherePredicate) -> String { ..}) => { format!("{}: {}", pprust::lifetime_to_string(lifetime), - bounds.iter().map(|l| pprust::lifetime_to_string(l)).collect::>().connect(" + ")) + bounds.iter().map(|l| pprust::lifetime_to_string(l)) + .collect::>().connect(" + ")) } &ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ref path, ref ty, ..}) => { format!("{} = {}", pprust::path_to_string(path), pprust::ty_to_string(ty)) @@ -55,7 +59,8 @@ pub fn rewrite_lifetime_def(&self, lifetime: &ast::LifetimeDef) -> String { format!("{}: {}", pprust::lifetime_to_string(&lifetime.lifetime), - lifetime.bounds.iter().map(|l| pprust::lifetime_to_string(l)).collect::>().connect(" + ")) + lifetime.bounds.iter().map(|l| pprust::lifetime_to_string(l)) + .collect::>().connect(" + ")) } pub fn rewrite_ty_bound(&self, bound: &ast::TyParamBound) -> String { @@ -77,7 +82,8 @@ pub fn rewrite_ty_param(&self, ty_param: &ast::TyParam) -> String { result.push_str(&token::get_ident(ty_param.ident)); if ty_param.bounds.len() > 0 { result.push_str(": "); - result.push_str(&ty_param.bounds.iter().map(|b| self.rewrite_ty_bound(b)).collect::>().connect(" + ")); + result.push_str(&ty_param.bounds.iter().map(|b| self.rewrite_ty_bound(b)) + .collect::>().connect(" + ")); } if let Some(ref def) = ty_param.default { result.push_str(" = "); @@ -90,7 +96,8 @@ pub fn rewrite_ty_param(&self, ty_param: &ast::TyParam) -> String { fn rewrite_poly_trait_ref(&self, t: &ast::PolyTraitRef) -> String { if t.bound_lifetimes.len() > 0 { format!("for<{}> {}", - t.bound_lifetimes.iter().map(|l| self.rewrite_lifetime_def(l)).collect::>().connect(", "), + t.bound_lifetimes.iter().map(|l| self.rewrite_lifetime_def(l)) + .collect::>().connect(", "), pprust::path_to_string(&t.trait_ref.path)) } else { diff --git a/src/visitor.rs b/src/visitor.rs index 1b1fd9d17c6..eb3c4be80f7 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -380,7 +380,9 @@ fn format_mod(&mut self, m: &ast::Mod, s: Span, ident: ast::Ident, attrs: &[ast: } Some(open_brace) => { debug!("FmtVisitor::format_mod: internal mod"); - debug!("... open_brace: {}, str: {:?}", open_brace, self.codemap.span_to_snippet(s)); + debug!("... open_brace: {}, str: {:?}", + open_brace, + self.codemap.span_to_snippet(s)); // Format everything until opening brace // TODO Shoud rewrite properly self.format_missing(s.lo + BytePos(open_brace as u32));