Skip to content

Commit dc58c53

Browse files
committed
allow the warning
1 parent b227f23 commit dc58c53

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

clippy_lints/src/unnested_or_patterns.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ fn transform_with_focus_on_idx(alternatives: &mut ThinVec<Box<Pat>>, focus_idx:
306306
/// In particular, for a record pattern, the order in which the field patterns is irrelevant.
307307
/// So when we fixate on some `ident_k: pat_k`, we try to find `ident_k` in the other pattern
308308
/// and check that all `fp_i` where `i ∈ ((0...n) \ k)` between two patterns are equal.
309+
#[expect(clippy::borrowed_box, reason = "required by the signature of `eq_maybe_qself`")]
309310
fn extend_with_struct_pat(
310311
qself1: Option<&Box<ast::QSelf>>,
311312
path1: &ast::Path,
@@ -383,14 +384,15 @@ fn take_pat(from: &mut Pat) -> Pat {
383384
/// in `tail_or` if there are any and return if there were.
384385
fn extend_with_tail_or(target: &mut Pat, tail_or: ThinVec<Box<Pat>>) -> bool {
385386
fn extend(target: &mut Pat, mut tail_or: ThinVec<Box<Pat>>) {
386-
// On an existing or-pattern in the target, append to it,
387-
// otherwise convert the target to an or-pattern.
388-
if let Or(ps) = &mut target.kind {
389-
ps.append(&mut tail_or);
390-
} else {
391-
let mut init_or = thin_vec![Box::new(take_pat(target))];
392-
init_or.append(&mut tail_or);
393-
target.kind = Or(init_or);
387+
match target {
388+
// On an existing or-pattern in the target, append to it.
389+
Pat { kind: Or(ps), .. } => ps.append(&mut tail_or),
390+
// Otherwise convert the target to an or-pattern.
391+
target => {
392+
let mut init_or = thin_vec![Box::new(take_pat(target))];
393+
init_or.append(&mut tail_or);
394+
target.kind = Or(init_or);
395+
},
394396
}
395397
}
396398

0 commit comments

Comments
 (0)