Skip to content

Commit f65fe3b

Browse files
committed
Remove pattern_arena from RustcMatchCheckCtxt
1 parent be77cf8 commit f65fe3b

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
291291
err = err.and(check_never_pattern(cx, pat));
292292
});
293293
err?;
294-
Ok(cx.pattern_arena.alloc(cx.lower_pat(pat)))
294+
Ok(self.pattern_arena.alloc(cx.lower_pat(pat)))
295295
}
296296
}
297297

@@ -388,7 +388,6 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
388388
typeck_results: self.typeck_results,
389389
param_env: self.param_env,
390390
module: self.tcx.parent_module(self.lint_level).to_def_id(),
391-
pattern_arena: self.pattern_arena,
392391
dropless_arena: self.dropless_arena,
393392
match_lint_level: self.lint_level,
394393
whole_match_span,

compiler/rustc_pattern_analysis/src/errors.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ impl<'tcx> Uncovered<'tcx> {
2323
span: Span,
2424
cx: &RustcMatchCheckCtxt<'p, 'tcx>,
2525
witnesses: Vec<WitnessPat<'p, 'tcx>>,
26-
) -> Self {
26+
) -> Self
27+
where
28+
'tcx: 'p,
29+
{
2730
let witness_1 = cx.hoist_witness_pat(witnesses.get(0).unwrap());
2831
Self {
2932
span,

compiler/rustc_pattern_analysis/src/rustc.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt;
22
use std::iter::once;
33

4-
use rustc_arena::{DroplessArena, TypedArena};
4+
use rustc_arena::DroplessArena;
55
use rustc_hir::def_id::DefId;
66
use rustc_hir::HirId;
77
use rustc_index::{Idx, IndexVec};
@@ -62,7 +62,7 @@ impl<'tcx> RevealedTy<'tcx> {
6262
}
6363

6464
#[derive(Clone)]
65-
pub struct RustcMatchCheckCtxt<'p, 'tcx> {
65+
pub struct RustcMatchCheckCtxt<'p, 'tcx: 'p> {
6666
pub tcx: TyCtxt<'tcx>,
6767
pub typeck_results: &'tcx ty::TypeckResults<'tcx>,
6868
/// The module in which the match occurs. This is necessary for
@@ -72,8 +72,6 @@ pub struct RustcMatchCheckCtxt<'p, 'tcx> {
7272
/// outside its module and should not be matchable with an empty match statement.
7373
pub module: DefId,
7474
pub param_env: ty::ParamEnv<'tcx>,
75-
/// To allocate lowered patterns
76-
pub pattern_arena: &'p TypedArena<DeconstructedPat<'p, 'tcx>>,
7775
/// To allocate the result of `self.ctor_sub_tys()`
7876
pub dropless_arena: &'p DroplessArena,
7977
/// Lint level at the match.
@@ -89,13 +87,13 @@ pub struct RustcMatchCheckCtxt<'p, 'tcx> {
8987
pub known_valid_scrutinee: bool,
9088
}
9189

92-
impl<'p, 'tcx> fmt::Debug for RustcMatchCheckCtxt<'p, 'tcx> {
90+
impl<'p, 'tcx: 'p> fmt::Debug for RustcMatchCheckCtxt<'p, 'tcx> {
9391
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9492
f.debug_struct("RustcMatchCheckCtxt").finish()
9593
}
9694
}
9795

98-
impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
96+
impl<'p, 'tcx: 'p> RustcMatchCheckCtxt<'p, 'tcx> {
9997
/// Type inference occasionally gives us opaque types in places where corresponding patterns
10098
/// have more specific types. To avoid inconsistencies as well as detect opaque uninhabited
10199
/// types, we use the corresponding concrete type if possible.
@@ -844,7 +842,7 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
844842
}
845843
}
846844

847-
impl<'p, 'tcx> TypeCx for RustcMatchCheckCtxt<'p, 'tcx> {
845+
impl<'p, 'tcx: 'p> TypeCx for RustcMatchCheckCtxt<'p, 'tcx> {
848846
type Ty = RevealedTy<'tcx>;
849847
type Error = ErrorGuaranteed;
850848
type VariantIdx = VariantIdx;

0 commit comments

Comments
 (0)