1
Fork 0

Avoid double-boxing lists of THIR subpatterns

This commit is contained in:
Zalathar 2025-02-02 21:43:45 +11:00
parent d72cc93e4e
commit 869c7b766e
4 changed files with 16 additions and 16 deletions

View file

@ -629,7 +629,7 @@ pub enum InlineAsmOperand<'tcx> {
#[derive(Clone, Debug, HashStable, TypeVisitable)]
pub struct FieldPat<'tcx> {
pub field: FieldIdx,
pub pattern: Box<Pat<'tcx>>,
pub pattern: Pat<'tcx>,
}
#[derive(Clone, Debug, HashStable, TypeVisitable)]
@ -690,7 +690,7 @@ impl<'tcx> Pat<'tcx> {
Or { pats } => pats.iter().for_each(|p| p.walk_(it)),
Array { box ref prefix, ref slice, box ref suffix }
| Slice { box ref prefix, ref slice, box ref suffix } => {
prefix.iter().chain(slice.iter()).chain(suffix.iter()).for_each(|p| p.walk_(it))
prefix.iter().chain(slice.as_deref()).chain(suffix.iter()).for_each(|p| p.walk_(it))
}
}
}
@ -853,22 +853,22 @@ pub enum PatKind<'tcx> {
/// irrefutable when there is a slice pattern and both `prefix` and `suffix` are empty.
/// e.g., `&[ref xs @ ..]`.
Slice {
prefix: Box<[Box<Pat<'tcx>>]>,
prefix: Box<[Pat<'tcx>]>,
slice: Option<Box<Pat<'tcx>>>,
suffix: Box<[Box<Pat<'tcx>>]>,
suffix: Box<[Pat<'tcx>]>,
},
/// Fixed match against an array; irrefutable.
Array {
prefix: Box<[Box<Pat<'tcx>>]>,
prefix: Box<[Pat<'tcx>]>,
slice: Option<Box<Pat<'tcx>>>,
suffix: Box<[Box<Pat<'tcx>>]>,
suffix: Box<[Pat<'tcx>]>,
},
/// An or-pattern, e.g. `p | q`.
/// Invariant: `pats.len() >= 2`.
Or {
pats: Box<[Box<Pat<'tcx>>]>,
pats: Box<[Pat<'tcx>]>,
},
/// A never pattern `!`.