Rollup merge of #5756 - ebroto:5754_sort_by, r=flip1995
unnecessary_sort_by: avoid linting if key borrows changelog: Avoid linting if key borrows in [`unnecessary_sort_by`] Fixes #5754 Closes #2313
This commit is contained in:
commit
32ef448bdb
5 changed files with 131 additions and 45 deletions
|
|
@ -1356,6 +1356,21 @@ pub fn fn_has_unsatisfiable_preds(cx: &LateContext<'_>, did: DefId) -> bool {
|
|||
)
|
||||
}
|
||||
|
||||
/// Returns the `DefId` of the callee if the given expression is a function or method call.
|
||||
pub fn fn_def_id(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<DefId> {
|
||||
match &expr.kind {
|
||||
ExprKind::MethodCall(..) => cx.tables().type_dependent_def_id(expr.hir_id),
|
||||
ExprKind::Call(
|
||||
Expr {
|
||||
kind: ExprKind::Path(qpath),
|
||||
..
|
||||
},
|
||||
..,
|
||||
) => cx.tables().qpath_res(qpath, expr.hir_id).opt_def_id(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_lints(cx: &LateContext<'_>, lints: &[&'static Lint], id: HirId) -> bool {
|
||||
lints.iter().any(|lint| {
|
||||
matches!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue