diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 3ac19980a6d..fa0d7de6676 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 388c1ae7e34..3fd372052f6 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 @@ pub fn ast(cx: &EarlyContext, expr: &ast::Expr, default: &'a str) -> Self { } /// 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 @@ pub fn deref(self) -> Sugg<'static> { /// 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), } }