&Self
This commit is contained in:
parent
be7c4b4862
commit
c102d50ece
@ -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, "..")));
|
||||
});
|
||||
}
|
||||
|
@ -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 `<lhs> && <rhs>` suggestion.
|
||||
pub fn and<R: Borrow<Self>>(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 `<lhs> as <rhs>` suggestion.
|
||||
@ -162,10 +162,10 @@ pub fn deref(self) -> Sugg<'static> {
|
||||
|
||||
/// Convenience method to create the `<lhs>..<rhs>` or `<lhs>...<rhs>`
|
||||
/// suggestion.
|
||||
pub fn range<E: Borrow<Self>>(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),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user