Remove needless borrows

This commit is contained in:
topecongiro 2017-10-26 16:54:41 +09:00
parent 314c97387d
commit 6c5ac5a9b3
5 changed files with 15 additions and 15 deletions

View File

@ -75,7 +75,7 @@ pub fn format_expr(
ast::ExprKind::Call(ref callee, ref args) => {
let inner_span = mk_sp(callee.span.hi(), expr.span.hi());
let callee_str = callee.rewrite(context, shape)?;
rewrite_call(context, &callee_str, &args, inner_span, shape)
rewrite_call(context, &callee_str, args, inner_span, shape)
}
ast::ExprKind::Paren(ref subexpr) => rewrite_paren(context, subexpr, shape),
ast::ExprKind::Binary(ref op, ref lhs, ref rhs) => {
@ -101,7 +101,7 @@ pub fn format_expr(
shape,
),
ast::ExprKind::Tup(ref items) => {
rewrite_tuple(context, &ptr_vec_to_ref_vec(&items), expr.span, shape)
rewrite_tuple(context, &ptr_vec_to_ref_vec(items), expr.span, shape)
}
ast::ExprKind::If(..) |
ast::ExprKind::IfLet(..) |
@ -355,7 +355,7 @@ where
.unwrap_or(false);
if !rhs_result.contains('\n') || allow_same_line {
let one_line_width = last_line_width(&lhs_result) + infix.len()
+ first_line_width(&rhs_result) + suffix.len();
+ first_line_width(rhs_result) + suffix.len();
if one_line_width <= shape.width {
return Some(format!("{}{}{}{}", lhs_result, infix, rhs_result, suffix));
}
@ -2004,7 +2004,7 @@ pub fn rewrite_call(
rewrite_call_inner(
context,
callee,
&ptr_vec_to_ref_vec(&args),
&ptr_vec_to_ref_vec(args),
span,
shape,
context.config.fn_call_width(),

View File

@ -292,7 +292,7 @@ impl<'a> FmtVisitor<'a> {
}
Some(ref s) => {
self.format_missing_with_indent(source!(self, span).lo());
self.buffer.push_str(&s);
self.buffer.push_str(s);
self.last_pos = source!(self, span).hi();
}
None => {

View File

@ -215,7 +215,7 @@ impl<'a> FnSig<'a> {
unsafety: unsafety,
visibility: visibility.clone(),
},
visit::FnKind::Method(_, ref method_sig, vis, _) => {
visit::FnKind::Method(_, method_sig, vis, _) => {
let mut fn_sig = FnSig::from_method_sig(method_sig, generics);
fn_sig.defaultness = defualtness;
if let Some(vis) = vis {
@ -2318,16 +2318,16 @@ fn rewrite_generics_inner(
impl<'a> Rewrite for GenericsArg<'a> {
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
match *self {
GenericsArg::Lifetime(ref lifetime) => lifetime.rewrite(context, shape),
GenericsArg::TyParam(ref ty) => ty.rewrite(context, shape),
GenericsArg::Lifetime(lifetime) => lifetime.rewrite(context, shape),
GenericsArg::TyParam(ty) => ty.rewrite(context, shape),
}
}
}
impl<'a> Spanned for GenericsArg<'a> {
fn span(&self) -> Span {
match *self {
GenericsArg::Lifetime(ref lifetime) => lifetime.span(),
GenericsArg::TyParam(ref ty) => ty.span(),
GenericsArg::Lifetime(lifetime) => lifetime.span(),
GenericsArg::TyParam(ty) => ty.span(),
}
}
}

View File

@ -70,10 +70,10 @@ pub enum MacroArg {
impl Rewrite for MacroArg {
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
match self {
&MacroArg::Expr(ref expr) => expr.rewrite(context, shape),
&MacroArg::Ty(ref ty) => ty.rewrite(context, shape),
&MacroArg::Pat(ref pat) => pat.rewrite(context, shape),
match *self {
MacroArg::Expr(ref expr) => expr.rewrite(context, shape),
MacroArg::Ty(ref ty) => ty.rewrite(context, shape),
MacroArg::Pat(ref pat) => pat.rewrite(context, shape),
}
}
}

View File

@ -695,7 +695,7 @@ impl Rewrite for ast::Ty {
}
ast::TyKind::Tup(ref items) => rewrite_tuple(
context,
&::utils::ptr_vec_to_ref_vec(&items),
&::utils::ptr_vec_to_ref_vec(items),
self.span,
shape,
),