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

@ -37,9 +37,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
&mut self,
match_pairs: &mut Vec<MatchPairTree<'tcx>>,
place: &PlaceBuilder<'tcx>,
prefix: &[Box<Pat<'tcx>>],
prefix: &[Pat<'tcx>],
opt_slice: &Option<Box<Pat<'tcx>>>,
suffix: &[Box<Pat<'tcx>>],
suffix: &[Pat<'tcx>],
) {
let tcx = self.tcx;
let (min_length, exact_size) = if let Some(place_resolved) = place.try_to_place(self) {

View file

@ -208,7 +208,7 @@ impl<'tcx> ConstToPat<'tcx> {
let field = FieldIdx::new(idx);
// Patterns can only use monomorphic types.
let ty = self.tcx.normalize_erasing_regions(self.typing_env, ty);
FieldPat { field, pattern: self.valtree_to_pat(val, ty) }
FieldPat { field, pattern: *self.valtree_to_pat(val, ty) }
})
.collect()
}
@ -277,7 +277,7 @@ impl<'tcx> ConstToPat<'tcx> {
prefix: cv
.unwrap_branch()
.iter()
.map(|val| self.valtree_to_pat(*val, *elem_ty))
.map(|val| *self.valtree_to_pat(*val, *elem_ty))
.collect(),
slice: None,
suffix: Box::new([]),
@ -286,7 +286,7 @@ impl<'tcx> ConstToPat<'tcx> {
prefix: cv
.unwrap_branch()
.iter()
.map(|val| self.valtree_to_pat(*val, *elem_ty))
.map(|val| *self.valtree_to_pat(*val, *elem_ty))
.collect(),
slice: None,
suffix: Box::new([]),

View file

@ -417,7 +417,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
.iter()
.map(|field| FieldPat {
field: self.typeck_results.field_index(field.hir_id),
pattern: self.lower_pattern(field.pat),
pattern: *self.lower_pattern(field.pat),
})
.collect();
@ -445,13 +445,13 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
.enumerate_and_adjust(expected_len, gap_pos)
.map(|(i, subpattern)| FieldPat {
field: FieldIdx::new(i),
pattern: self.lower_pattern(subpattern),
pattern: *self.lower_pattern(subpattern),
})
.collect()
}
fn lower_patterns(&mut self, pats: &'tcx [hir::Pat<'tcx>]) -> Box<[Box<Pat<'tcx>>]> {
pats.iter().map(|p| self.lower_pattern(p)).collect()
fn lower_patterns(&mut self, pats: &'tcx [hir::Pat<'tcx>]) -> Box<[Pat<'tcx>]> {
pats.iter().map(|p| *self.lower_pattern(p)).collect()
}
fn lower_opt_pattern(&mut self, pat: Option<&'tcx hir::Pat<'tcx>>) -> Option<Box<Pat<'tcx>>> {