Skip to content

set the applicability of op_ref to MachineApplicable #14438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions clippy_lints/src/operators/op_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub(crate) fn check<'tcx>(
left.span,
"use the left value directly",
lsnip,
Applicability::MaybeIncorrect, // FIXME #2597
Applicability::MachineApplicable,
);
},
);
Expand All @@ -105,7 +105,7 @@ pub(crate) fn check<'tcx>(
right.span,
"use the right value directly",
rsnip,
Applicability::MaybeIncorrect, // FIXME #2597
Applicability::MachineApplicable,
);
},
);
Expand Down Expand Up @@ -137,7 +137,7 @@ pub(crate) fn check<'tcx>(
left.span,
"use the left value directly",
lsnip,
Applicability::MaybeIncorrect, // FIXME #2597
Applicability::MachineApplicable,
);
},
);
Expand All @@ -164,7 +164,7 @@ pub(crate) fn check<'tcx>(
right.span,
"use the right value directly",
rsnip,
Applicability::MaybeIncorrect, // FIXME #2597
Applicability::MachineApplicable,
);
});
}
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/op_ref.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
12 changes: 12 additions & 0 deletions tests/ui/op_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}