Format source codes

This commit is contained in:
topecongiro 2017-06-15 16:26:41 +09:00
parent a5138b1676
commit 8a6e9f689b
3 changed files with 23 additions and 20 deletions

View File

@ -684,13 +684,15 @@ fn format_impl_ref_and_type(
item: &ast::Item,
offset: Indent,
) -> Option<String> {
if let ast::ItemKind::Impl(unsafety,
polarity,
_,
ref generics,
ref trait_ref,
ref self_ty,
_) = item.node
if let ast::ItemKind::Impl(
unsafety,
polarity,
_,
ref generics,
ref trait_ref,
ref self_ty,
_,
) = item.node
{
let mut result = String::new();

View File

@ -371,11 +371,11 @@ impl Rewrite for ast::WherePredicate {
// TODO: dead spans?
let result = match *self {
ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate {
ref bound_lifetimes,
ref bounded_ty,
ref bounds,
..
}) => {
ref bound_lifetimes,
ref bounded_ty,
ref bounds,
..
}) => {
let type_str = try_opt!(bounded_ty.rewrite(context, shape));
let colon = type_bound_colon(context);
@ -428,10 +428,10 @@ impl Rewrite for ast::WherePredicate {
}
}
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate {
ref lifetime,
ref bounds,
..
}) => {
ref lifetime,
ref bounds,
..
}) => {
try_opt!(rewrite_bounded_lifetime(
lifetime,
bounds.iter(),
@ -440,10 +440,10 @@ impl Rewrite for ast::WherePredicate {
))
}
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate {
ref lhs_ty,
ref rhs_ty,
..
}) => {
ref lhs_ty,
ref rhs_ty,
..
}) => {
let lhs_ty_str = try_opt!(lhs_ty.rewrite(context, shape));
// 3 = " = ".len()
let used_width = 3 + lhs_ty_str.len();

View File

@ -99,6 +99,7 @@ pub fn last_line_width(s: &str) -> usize {
None => s.len(),
}
}
#[inline]
pub fn trimmed_last_line_width(s: &str) -> usize {
match s.rfind('\n') {