mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
&Self
This commit is contained in:
parent
be7c4b4862
commit
c102d50ece
2 changed files with 7 additions and 7 deletions
|
@ -134,7 +134,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext, expr: &ast::Expr, check: &ast:
|
||||||
db.span_suggestion(expr.span,
|
db.span_suggestion(expr.span,
|
||||||
"try",
|
"try",
|
||||||
format!("if {} {}",
|
format!("if {} {}",
|
||||||
lhs.and(rhs),
|
lhs.and(&rhs),
|
||||||
snippet_block(cx, content.span, "..")));
|
snippet_block(cx, content.span, "..")));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::lint::{EarlyContext, LateContext, LintContext};
|
use rustc::lint::{EarlyContext, LateContext, LintContext};
|
||||||
use rustc_errors;
|
use rustc_errors;
|
||||||
use std::borrow::{Borrow, Cow};
|
use std::borrow::Cow;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std;
|
use std;
|
||||||
use syntax::codemap::{CharPos, Span};
|
use syntax::codemap::{CharPos, Span};
|
||||||
|
@ -136,8 +136,8 @@ impl<'a> Sugg<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience method to create the `<lhs> && <rhs>` suggestion.
|
/// Convenience method to create the `<lhs> && <rhs>` suggestion.
|
||||||
pub fn and<R: Borrow<Self>>(self, rhs: R) -> Sugg<'static> {
|
pub fn and(self, rhs: &Self) -> Sugg<'static> {
|
||||||
make_binop(ast::BinOpKind::And, &self, rhs.borrow())
|
make_binop(ast::BinOpKind::And, &self, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience method to create the `<lhs> as <rhs>` suggestion.
|
/// Convenience method to create the `<lhs> as <rhs>` suggestion.
|
||||||
|
@ -162,10 +162,10 @@ impl<'a> Sugg<'a> {
|
||||||
|
|
||||||
/// Convenience method to create the `<lhs>..<rhs>` or `<lhs>...<rhs>`
|
/// Convenience method to create the `<lhs>..<rhs>` or `<lhs>...<rhs>`
|
||||||
/// suggestion.
|
/// 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 {
|
match limit {
|
||||||
ast::RangeLimits::HalfOpen => make_assoc(AssocOp::DotDot, &self, end.borrow()),
|
ast::RangeLimits::HalfOpen => make_assoc(AssocOp::DotDot, &self, end),
|
||||||
ast::RangeLimits::Closed => make_assoc(AssocOp::DotDotEq, &self, end.borrow()),
|
ast::RangeLimits::Closed => make_assoc(AssocOp::DotDotEq, &self, end),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue