diff options
| author | Philipp Krones <hello@philkrones.com> | 2024-10-03 16:32:51 +0200 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2024-10-03 16:32:51 +0200 |
| commit | 277c4e4baff50ff0df4b63e86404b8eea70e61ec (patch) | |
| tree | 180f9eae4b5683842ff29520e2ed1ff38f393493 /clippy_lints/src/unnested_or_patterns.rs | |
| parent | 4891dd4627be38fa6133fcf3cfb0c1a65867bf87 (diff) | |
| download | rust-277c4e4baff50ff0df4b63e86404b8eea70e61ec.tar.gz rust-277c4e4baff50ff0df4b63e86404b8eea70e61ec.zip | |
Merge commit 'aa0d551351a9c15d8a95fdb3e2946b505893dda8' into clippy-subtree-update
Diffstat (limited to 'clippy_lints/src/unnested_or_patterns.rs')
| -rw-r--r-- | clippy_lints/src/unnested_or_patterns.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/clippy_lints/src/unnested_or_patterns.rs b/clippy_lints/src/unnested_or_patterns.rs index 104be63bb15..c7c837de505 100644 --- a/clippy_lints/src/unnested_or_patterns.rs +++ b/clippy_lints/src/unnested_or_patterns.rs @@ -275,12 +275,15 @@ fn transform_with_focus_on_idx(alternatives: &mut ThinVec<P<Pat>>, focus_idx: us |k, ps1, idx| matches!( k, TupleStruct(qself2, path2, ps2) - if eq_maybe_qself(qself1, qself2) && eq_path(path1, path2) && eq_pre_post(ps1, ps2, idx) + if eq_maybe_qself(qself1.as_ref(), qself2.as_ref()) + && eq_path(path1, path2) && eq_pre_post(ps1, ps2, idx) ), |k| always_pat!(k, TupleStruct(_, _, ps) => ps), ), // Transform a record pattern `S { fp_0, ..., fp_n }`. - Struct(qself1, path1, fps1, rest1) => extend_with_struct_pat(qself1, path1, fps1, *rest1, start, alternatives), + Struct(qself1, path1, fps1, rest1) => { + extend_with_struct_pat(qself1.as_ref(), path1, fps1, *rest1, start, alternatives) + }, }; alternatives[focus_idx].kind = focus_kind; @@ -292,7 +295,7 @@ fn transform_with_focus_on_idx(alternatives: &mut ThinVec<P<Pat>>, focus_idx: us /// So when we fixate on some `ident_k: pat_k`, we try to find `ident_k` in the other pattern /// and check that all `fp_i` where `i ∈ ((0...n) \ k)` between two patterns are equal. fn extend_with_struct_pat( - qself1: &Option<P<ast::QSelf>>, + qself1: Option<&P<ast::QSelf>>, path1: &ast::Path, fps1: &mut [ast::PatField], rest1: ast::PatFieldsRest, @@ -307,7 +310,7 @@ fn extend_with_struct_pat( |k| { matches!(k, Struct(qself2, path2, fps2, rest2) if rest1 == *rest2 // If one struct pattern has `..` so must the other. - && eq_maybe_qself(qself1, qself2) + && eq_maybe_qself(qself1, qself2.as_ref()) && eq_path(path1, path2) && fps1.len() == fps2.len() && fps1.iter().enumerate().all(|(idx_1, fp1)| { |
