diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-08-26 12:06:13 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-09-02 07:26:22 +1000 |
| commit | 43a0268f3a28fa53ad8290720002984cff785224 (patch) | |
| tree | 69e4a04f76b5ac097fc9b938c41006b24c051dd0 /compiler/rustc_middle | |
| parent | a40124e01c4b10629c78b417a1fe524d929bcbe9 (diff) | |
| download | rust-43a0268f3a28fa53ad8290720002984cff785224.tar.gz rust-43a0268f3a28fa53ad8290720002984cff785224.zip | |
Use boxed slices in `PatKind`.
To shrink it a little more.
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/thir.rs | 20 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/thir/visit.rs | 6 |
2 files changed, 13 insertions, 13 deletions
diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 120fa787009..59e14337f4e 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -634,22 +634,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: Vec<Box<Pat<'tcx>>>, + prefix: Box<[Box<Pat<'tcx>>]>, slice: Option<Box<Pat<'tcx>>>, - suffix: Vec<Box<Pat<'tcx>>>, + suffix: Box<[Box<Pat<'tcx>>]>, }, /// Fixed match against an array; irrefutable. Array { - prefix: Vec<Box<Pat<'tcx>>>, + prefix: Box<[Box<Pat<'tcx>>]>, slice: Option<Box<Pat<'tcx>>>, - suffix: Vec<Box<Pat<'tcx>>>, + suffix: Box<[Box<Pat<'tcx>>]>, }, /// An or-pattern, e.g. `p | q`. /// Invariant: `pats.len() >= 2`. Or { - pats: Vec<Box<Pat<'tcx>>>, + pats: Box<[Box<Pat<'tcx>>]>, }, } @@ -775,7 +775,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> { PatKind::Slice { ref prefix, ref slice, ref suffix } | PatKind::Array { ref prefix, ref slice, ref suffix } => { write!(f, "[")?; - for p in prefix { + for p in prefix.iter() { write!(f, "{}{}", start_or_comma(), p)?; } if let Some(ref slice) = *slice { @@ -786,13 +786,13 @@ impl<'tcx> fmt::Display for Pat<'tcx> { } write!(f, "..")?; } - for p in suffix { + for p in suffix.iter() { write!(f, "{}{}", start_or_comma(), p)?; } write!(f, "]") } PatKind::Or { ref pats } => { - for pat in pats { + for pat in pats.iter() { write!(f, "{}{}", start_or_continue(" | "), pat)?; } Ok(()) @@ -809,8 +809,8 @@ mod size_asserts { static_assert_size!(Block, 56); static_assert_size!(Expr<'_>, 64); static_assert_size!(ExprKind<'_>, 40); - static_assert_size!(Pat<'_>, 80); - static_assert_size!(PatKind<'_>, 64); + static_assert_size!(Pat<'_>, 72); + static_assert_size!(PatKind<'_>, 56); static_assert_size!(Stmt<'_>, 56); static_assert_size!(StmtKind<'_>, 48); } diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs index 5168c2120f4..79a0e75aa7c 100644 --- a/compiler/rustc_middle/src/thir/visit.rs +++ b/compiler/rustc_middle/src/thir/visit.rs @@ -232,18 +232,18 @@ pub fn walk_pat<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, pat: &Pat<' Constant { value: _ } => {} Range(_) => {} Slice { prefix, slice, suffix } | Array { prefix, slice, suffix } => { - for subpattern in prefix { + for subpattern in prefix.iter() { visitor.visit_pat(&subpattern); } if let Some(pat) = slice { visitor.visit_pat(&pat); } - for subpattern in suffix { + for subpattern in suffix.iter() { visitor.visit_pat(&subpattern); } } Or { pats } => { - for pat in pats { + for pat in pats.iter() { visitor.visit_pat(&pat); } } |
