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`
This commit is contained in:
Jason Newcomb 2025-03-22 14:16:52 +00:00 committed by GitHub
commit d9934328dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 4 deletions

View file

@ -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,
);
});
}

View file

@ -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
}
}

View file

@ -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
}
}