mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-29 03:27:44 +00:00
refactor: Put together an if statement
This commit is contained in:
parent
9716a9eff0
commit
40224f46c0
@ -143,15 +143,11 @@ fn lint_needless_cloning(cx: &LateContext<'_>, root: Span, receiver: Span) {
|
|||||||
impl MapClone {
|
impl MapClone {
|
||||||
fn lint_explicit_closure(&self, cx: &LateContext<'_>, replace: Span, root: Span, is_copy: bool) {
|
fn lint_explicit_closure(&self, cx: &LateContext<'_>, replace: Span, root: Span, is_copy: bool) {
|
||||||
let mut applicability = Applicability::MachineApplicable;
|
let mut applicability = Applicability::MachineApplicable;
|
||||||
let message = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) {
|
|
||||||
"you are using an explicit closure for copying elements"
|
let (message, sugg_method) = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) {
|
||||||
|
("you are using an explicit closure for copying elements", "copied")
|
||||||
} else {
|
} else {
|
||||||
"you are using an explicit closure for cloning elements"
|
("you are using an explicit closure for cloning elements", "cloned")
|
||||||
};
|
|
||||||
let sugg_method = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) {
|
|
||||||
"copied"
|
|
||||||
} else {
|
|
||||||
"cloned"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
span_lint_and_sugg(
|
span_lint_and_sugg(
|
||||||
|
Loading…
Reference in New Issue
Block a user