1
Fork 0

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

View file

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

View file

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

View file

@ -70,10 +70,10 @@ pub enum MacroArg {
impl Rewrite for MacroArg { impl Rewrite for MacroArg {
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> { fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
match self { match *self {
&MacroArg::Expr(ref expr) => expr.rewrite(context, shape), MacroArg::Expr(ref expr) => expr.rewrite(context, shape),
&MacroArg::Ty(ref ty) => ty.rewrite(context, shape), MacroArg::Ty(ref ty) => ty.rewrite(context, shape),
&MacroArg::Pat(ref pat) => pat.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( ast::TyKind::Tup(ref items) => rewrite_tuple(
context, context,
&::utils::ptr_vec_to_ref_vec(&items), &::utils::ptr_vec_to_ref_vec(items),
self.span, self.span,
shape, shape,
), ),