Skip to content

Commit d993432

Browse files
authored
set the applicability of op_ref to MachineApplicable (#14438)
#2597 appears to be already resolved, so the applicability of `op_ref` can be set to `MachineApplicable`. close #2597 changelog: [`op_ref`]: set the applicability to `MachineApplicable`
2 parents e8e0126 + a463154 commit d993432

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

clippy_lints/src/operators/op_ref.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub(crate) fn check<'tcx>(
8686
left.span,
8787
"use the left value directly",
8888
lsnip,
89-
Applicability::MaybeIncorrect, // FIXME #2597
89+
Applicability::MachineApplicable,
9090
);
9191
},
9292
);
@@ -105,7 +105,7 @@ pub(crate) fn check<'tcx>(
105105
right.span,
106106
"use the right value directly",
107107
rsnip,
108-
Applicability::MaybeIncorrect, // FIXME #2597
108+
Applicability::MachineApplicable,
109109
);
110110
},
111111
);
@@ -137,7 +137,7 @@ pub(crate) fn check<'tcx>(
137137
left.span,
138138
"use the left value directly",
139139
lsnip,
140-
Applicability::MaybeIncorrect, // FIXME #2597
140+
Applicability::MachineApplicable,
141141
);
142142
},
143143
);
@@ -164,7 +164,7 @@ pub(crate) fn check<'tcx>(
164164
right.span,
165165
"use the right value directly",
166166
rsnip,
167-
Applicability::MaybeIncorrect, // FIXME #2597
167+
Applicability::MachineApplicable,
168168
);
169169
});
170170
}

tests/ui/op_ref.fixed

+12
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,15 @@ impl Mul<A> for A {
9898
self * &rhs
9999
}
100100
}
101+
102+
mod issue_2597 {
103+
fn ex1() {
104+
let a: &str = "abc";
105+
let b: String = "abc".to_owned();
106+
println!("{}", a > &b);
107+
}
108+
109+
pub fn ex2<T: Ord + PartialOrd>(array: &[T], val: &T, idx: usize) -> bool {
110+
&array[idx] < val
111+
}
112+
}

tests/ui/op_ref.rs

+12
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,15 @@ impl Mul<A> for A {
9898
self * &rhs
9999
}
100100
}
101+
102+
mod issue_2597 {
103+
fn ex1() {
104+
let a: &str = "abc";
105+
let b: String = "abc".to_owned();
106+
println!("{}", a > &b);
107+
}
108+
109+
pub fn ex2<T: Ord + PartialOrd>(array: &[T], val: &T, idx: usize) -> bool {
110+
&array[idx] < val
111+
}
112+
}

0 commit comments

Comments
 (0)