Skip to content

Commit b04e0df

Browse files
committed
pattern_analysis doesn't need an arena anymore
1 parent 3356ebd commit b04e0df

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

crates/hir-ty/src/diagnostics/expr.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ impl ExprValidator {
169169
return;
170170
}
171171

172-
let pattern_arena = Arena::new();
173-
let cx = MatchCheckCtx::new(self.owner.module(db.upcast()), self.owner, db, &pattern_arena);
172+
let cx = MatchCheckCtx::new(self.owner.module(db.upcast()), self.owner, db);
174173

174+
let pattern_arena = Arena::new();
175175
let mut m_arms = Vec::with_capacity(arms.len());
176176
let mut has_lowering_errors = false;
177177
for arm in arms {
@@ -196,8 +196,9 @@ impl ExprValidator {
196196
// If we had a NotUsefulMatchArm diagnostic, we could
197197
// check the usefulness of each pattern as we added it
198198
// to the matrix here.
199+
let pat = self.lower_pattern(&cx, arm.pat, db, &body, &mut has_lowering_errors);
199200
let m_arm = pat_analysis::MatchArm {
200-
pat: self.lower_pattern(&cx, arm.pat, db, &body, &mut has_lowering_errors),
201+
pat: pattern_arena.alloc(pat),
201202
has_guard: arm.guard.is_some(),
202203
arm_data: (),
203204
};
@@ -245,10 +246,10 @@ impl ExprValidator {
245246
db: &dyn HirDatabase,
246247
body: &Body,
247248
have_errors: &mut bool,
248-
) -> &'p DeconstructedPat<'p> {
249+
) -> DeconstructedPat<'p> {
249250
let mut patcx = match_check::PatCtxt::new(db, &self.infer, body);
250251
let pattern = patcx.lower_pattern(pat);
251-
let pattern = cx.pattern_arena.alloc(cx.lower_pat(&pattern));
252+
let pattern = cx.lower_pat(&pattern);
252253
if !patcx.errors.is_empty() {
253254
*have_errors = true;
254255
}

crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use rustc_pattern_analysis::{
1111
};
1212
use smallvec::{smallvec, SmallVec};
1313
use stdx::never;
14-
use typed_arena::Arena;
1514

1615
use crate::{
1716
db::HirDatabase,
@@ -40,7 +39,6 @@ pub(crate) struct MatchCheckCtx<'p> {
4039
module: ModuleId,
4140
body: DefWithBodyId,
4241
pub(crate) db: &'p dyn HirDatabase,
43-
pub(crate) pattern_arena: &'p Arena<DeconstructedPat<'p>>,
4442
exhaustive_patterns: bool,
4543
min_exhaustive_patterns: bool,
4644
}
@@ -52,17 +50,12 @@ pub(crate) struct PatData<'p> {
5250
}
5351

5452
impl<'p> MatchCheckCtx<'p> {
55-
pub(crate) fn new(
56-
module: ModuleId,
57-
body: DefWithBodyId,
58-
db: &'p dyn HirDatabase,
59-
pattern_arena: &'p Arena<DeconstructedPat<'p>>,
60-
) -> Self {
53+
pub(crate) fn new(module: ModuleId, body: DefWithBodyId, db: &'p dyn HirDatabase) -> Self {
6154
let def_map = db.crate_def_map(module.krate());
6255
let exhaustive_patterns = def_map.is_unstable_feature_enabled("exhaustive_patterns");
6356
let min_exhaustive_patterns =
6457
def_map.is_unstable_feature_enabled("min_exhaustive_patterns");
65-
Self { module, body, db, pattern_arena, exhaustive_patterns, min_exhaustive_patterns }
58+
Self { module, body, db, exhaustive_patterns, min_exhaustive_patterns }
6659
}
6760

6861
fn is_uninhabited(&self, ty: &Ty) -> bool {

0 commit comments

Comments
 (0)