about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlapla-cogito <me@lapla.dev>2025-03-19 21:37:42 +0900
committerlapla-cogito <me@lapla.dev>2025-03-19 21:37:42 +0900
commita463154bf0a4028fb6f4027ad58fc45a30379103 (patch)
tree3641286fd1f3c61b614f732429bcfa252eb95f95
parent775a5c27123414c11376778f090f167831259ce8 (diff)
downloadrust-a463154bf0a4028fb6f4027ad58fc45a30379103.tar.gz
rust-a463154bf0a4028fb6f4027ad58fc45a30379103.zip
set the applicability of `op_ref` to `MachineApplicable`
-rw-r--r--clippy_lints/src/operators/op_ref.rs8
-rw-r--r--tests/ui/op_ref.fixed12
-rw-r--r--tests/ui/op_ref.rs12
3 files changed, 28 insertions, 4 deletions
diff --git a/clippy_lints/src/operators/op_ref.rs b/clippy_lints/src/operators/op_ref.rs
index c3c09946c27..b03985d1565 100644
--- a/clippy_lints/src/operators/op_ref.rs
+++ b/clippy_lints/src/operators/op_ref.rs
@@ -86,7 +86,7 @@ pub(crate) fn check<'tcx>(
                                 left.span,
                                 "use the left value directly",
                                 lsnip,
-                                Applicability::MaybeIncorrect, // FIXME #2597
+                                Applicability::MachineApplicable,
                             );
                         },
                     );
@@ -105,7 +105,7 @@ pub(crate) fn check<'tcx>(
                                 right.span,
                                 "use the right value directly",
                                 rsnip,
-                                Applicability::MaybeIncorrect, // FIXME #2597
+                                Applicability::MachineApplicable,
                             );
                         },
                     );
@@ -137,7 +137,7 @@ pub(crate) fn check<'tcx>(
                                 left.span,
                                 "use the left value directly",
                                 lsnip,
-                                Applicability::MaybeIncorrect, // FIXME #2597
+                                Applicability::MachineApplicable,
                             );
                         },
                     );
@@ -164,7 +164,7 @@ pub(crate) fn check<'tcx>(
                             right.span,
                             "use the right value directly",
                             rsnip,
-                            Applicability::MaybeIncorrect, // FIXME #2597
+                            Applicability::MachineApplicable,
                         );
                     });
                 }
diff --git a/tests/ui/op_ref.fixed b/tests/ui/op_ref.fixed
index 46a59e419cc..f412190b9fd 100644
--- a/tests/ui/op_ref.fixed
+++ b/tests/ui/op_ref.fixed
@@ -98,3 +98,15 @@ impl Mul<A> for A {
         self * &rhs
     }
 }
+
+mod issue_2597 {
+    fn ex1() {
+        let a: &str = "abc";
+        let b: String = "abc".to_owned();
+        println!("{}", a > &b);
+    }
+
+    pub fn ex2<T: Ord + PartialOrd>(array: &[T], val: &T, idx: usize) -> bool {
+        &array[idx] < val
+    }
+}
diff --git a/tests/ui/op_ref.rs b/tests/ui/op_ref.rs
index e10840ff4b9..a4bbd86c7e9 100644
--- a/tests/ui/op_ref.rs
+++ b/tests/ui/op_ref.rs
@@ -98,3 +98,15 @@ impl Mul<A> for A {
         self * &rhs
     }
 }
+
+mod issue_2597 {
+    fn ex1() {
+        let a: &str = "abc";
+        let b: String = "abc".to_owned();
+        println!("{}", a > &b);
+    }
+
+    pub fn ex2<T: Ord + PartialOrd>(array: &[T], val: &T, idx: usize) -> bool {
+        &array[idx] < val
+    }
+}