Auto merge of #13630 - samueltardieu:push-qrnxuykslnsl, r=y21

Use match ergonomics compatible with editions 2021 and 2024

This PR contains the minimal changes needed to make Clippy match ergonomics work with both Rust 2021 and Rust 2024.

changelog: none
This commit is contained in:
bors 2024-11-01 20:23:33 +00:00
commit e8b78e2f66
33 changed files with 66 additions and 69 deletions

View file

@ -103,7 +103,7 @@ impl<'hir> IfLet<'hir> {
/// Parses an `if let` expression
pub fn hir(cx: &LateContext<'_>, expr: &Expr<'hir>) -> Option<Self> {
if let ExprKind::If(
Expr {
&Expr {
kind:
ExprKind::Let(&hir::LetExpr {
pat: let_pat,
@ -381,12 +381,12 @@ impl<'hir> WhileLet<'hir> {
/// Parses a desugared `while let` loop
pub const fn hir(expr: &Expr<'hir>) -> Option<Self> {
if let ExprKind::Loop(
Block {
&Block {
expr:
Some(Expr {
Some(&Expr {
kind:
ExprKind::If(
Expr {
&Expr {
kind:
ExprKind::Let(&hir::LetExpr {
pat: let_pat,

View file

@ -1189,11 +1189,11 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
self.hash_ty(ty);
self.hash_pat(pat);
},
TyKind::Ptr(ref mut_ty) => {
TyKind::Ptr(mut_ty) => {
self.hash_ty(mut_ty.ty);
mut_ty.mutbl.hash(&mut self.s);
},
TyKind::Ref(lifetime, ref mut_ty) => {
TyKind::Ref(lifetime, mut_ty) => {
self.hash_lifetime(lifetime);
self.hash_ty(mut_ty.ty);
mut_ty.mutbl.hash(&mut self.s);
@ -1218,7 +1218,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
self.hash_ty(ty);
}
},
TyKind::Path(ref qpath) => self.hash_qpath(qpath),
TyKind::Path(qpath) => self.hash_qpath(qpath),
TyKind::OpaqueDef(_, arg_list) => {
self.hash_generic_args(arg_list);
},

View file

@ -689,11 +689,11 @@ pub fn find_crates(tcx: TyCtxt<'_>, name: Symbol) -> Vec<Res> {
///
/// This function is expensive and should be used sparingly.
pub fn def_path_res(tcx: TyCtxt<'_>, path: &[&str]) -> Vec<Res> {
let (base, path) = match *path {
let (base, path) = match path {
[primitive] => {
return vec![PrimTy::from_name(Symbol::intern(primitive)).map_or(Res::Err, Res::PrimTy)];
},
[base, ref path @ ..] => (base, path),
[base, path @ ..] => (base, path),
_ => return Vec::new(),
};
@ -935,7 +935,7 @@ pub fn is_default_equivalent(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
}
},
ExprKind::Call(repl_func, []) => is_default_equivalent_call(cx, repl_func),
ExprKind::Call(from_func, [ref arg]) => is_default_equivalent_from(cx, from_func, arg),
ExprKind::Call(from_func, [arg]) => is_default_equivalent_from(cx, from_func, arg),
ExprKind::Path(qpath) => is_res_lang_ctor(cx, cx.qpath_res(qpath, e.hir_id), OptionNone),
ExprKind::AddrOf(rustc_hir::BorrowKind::Ref, _, expr) => matches!(expr.kind, ExprKind::Array([])),
_ => false,
@ -948,7 +948,7 @@ fn is_default_equivalent_from(cx: &LateContext<'_>, from_func: &Expr<'_>, arg: &
{
match arg.kind {
ExprKind::Lit(hir::Lit {
node: LitKind::Str(ref sym, _),
node: LitKind::Str(sym, _),
..
}) => return sym.is_empty() && is_path_lang_item(cx, ty, LangItem::String),
ExprKind::Array([]) => return is_path_diagnostic_item(cx, ty, sym::Vec),
@ -3460,7 +3460,7 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
pub fn is_parent_stmt(cx: &LateContext<'_>, id: HirId) -> bool {
matches!(
cx.tcx.parent_hir_node(id),
Node::Stmt(..) | Node::Block(Block { stmts: &[], .. })
Node::Stmt(..) | Node::Block(Block { stmts: [], .. })
)
}