From c102d50ece44256c3b889d754b34375fb9496a33 Mon Sep 17 00:00:00 2001 From: sinkuu Date: Fri, 3 Nov 2017 17:56:17 +0900 Subject: [PATCH] &Self --- clippy_lints/src/collapsible_if.rs | 2 +- clippy_lints/src/utils/sugg.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 3ac19980a..fa0d7de66 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -134,7 +134,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext, expr: &ast::Expr, check: &ast: db.span_suggestion(expr.span, "try", format!("if {} {}", - lhs.and(rhs), + lhs.and(&rhs), snippet_block(cx, content.span, ".."))); }); } diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index 388c1ae7e..3fd372052 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -6,7 +6,7 @@ use rustc::hir; use rustc::lint::{EarlyContext, LateContext, LintContext}; use rustc_errors; -use std::borrow::{Borrow, Cow}; +use std::borrow::Cow; use std::fmt::Display; use std; use syntax::codemap::{CharPos, Span}; @@ -136,8 +136,8 @@ impl<'a> Sugg<'a> { } /// Convenience method to create the ` && ` suggestion. - pub fn and>(self, rhs: R) -> Sugg<'static> { - make_binop(ast::BinOpKind::And, &self, rhs.borrow()) + pub fn and(self, rhs: &Self) -> Sugg<'static> { + make_binop(ast::BinOpKind::And, &self, rhs) } /// Convenience method to create the ` as ` suggestion. @@ -162,10 +162,10 @@ impl<'a> Sugg<'a> { /// Convenience method to create the `..` or `...` /// suggestion. - pub fn range>(self, end: E, limit: ast::RangeLimits) -> Sugg<'static> { + pub fn range(self, end: &Self, limit: ast::RangeLimits) -> Sugg<'static> { match limit { - ast::RangeLimits::HalfOpen => make_assoc(AssocOp::DotDot, &self, end.borrow()), - ast::RangeLimits::Closed => make_assoc(AssocOp::DotDotEq, &self, end.borrow()), + ast::RangeLimits::HalfOpen => make_assoc(AssocOp::DotDot, &self, end), + ast::RangeLimits::Closed => make_assoc(AssocOp::DotDotEq, &self, end), } }