Tidy up some overrunning lines

This commit is contained in:
Nick Cameron 2015-07-16 14:23:48 +12:00
parent 9ab1587a98
commit f2bcee9d87
4 changed files with 25 additions and 12 deletions

View File

@ -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);

View File

@ -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),

View File

@ -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::<Vec<_>>().connect(", "),
bound_lifetimes.iter().map(|l| self.rewrite_lifetime_def(l))
.collect::<Vec<_>>().connect(", "),
pprust::ty_to_string(bounded_ty),
bounds.iter().map(|b| self.rewrite_ty_bound(b)).collect::<Vec<_>>().connect(" + "))
bounds.iter().map(|b| self.rewrite_ty_bound(b))
.collect::<Vec<_>>().connect(" + "))
} else {
format!("{}: {}",
pprust::ty_to_string(bounded_ty),
bounds.iter().map(|b| self.rewrite_ty_bound(b)).collect::<Vec<_>>().connect(" + "))
bounds.iter().map(|b| self.rewrite_ty_bound(b))
.collect::<Vec<_>>().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::<Vec<_>>().connect(" + "))
bounds.iter().map(|l| pprust::lifetime_to_string(l))
.collect::<Vec<_>>().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::<Vec<_>>().connect(" + "))
lifetime.bounds.iter().map(|l| pprust::lifetime_to_string(l))
.collect::<Vec<_>>().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::<Vec<_>>().connect(" + "));
result.push_str(&ty_param.bounds.iter().map(|b| self.rewrite_ty_bound(b))
.collect::<Vec<_>>().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::<Vec<_>>().connect(", "),
t.bound_lifetimes.iter().map(|l| self.rewrite_lifetime_def(l))
.collect::<Vec<_>>().connect(", "),
pprust::path_to_string(&t.trait_ref.path))
} else {

View File

@ -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));