Skip to content

Commit

Permalink
Remove pattern_arena from RustcMatchCheckCtxt
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Jan 31, 2024
1 parent be77cf8 commit f65fe3b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
err = err.and(check_never_pattern(cx, pat));
});
err?;
Ok(cx.pattern_arena.alloc(cx.lower_pat(pat)))
Ok(self.pattern_arena.alloc(cx.lower_pat(pat)))
}
}

Expand Down Expand Up @@ -388,7 +388,6 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
typeck_results: self.typeck_results,
param_env: self.param_env,
module: self.tcx.parent_module(self.lint_level).to_def_id(),
pattern_arena: self.pattern_arena,
dropless_arena: self.dropless_arena,
match_lint_level: self.lint_level,
whole_match_span,
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_pattern_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ impl<'tcx> Uncovered<'tcx> {
span: Span,
cx: &RustcMatchCheckCtxt<'p, 'tcx>,
witnesses: Vec<WitnessPat<'p, 'tcx>>,
) -> Self {
) -> Self
where
'tcx: 'p,
{
let witness_1 = cx.hoist_witness_pat(witnesses.get(0).unwrap());
Self {
span,
Expand Down
12 changes: 5 additions & 7 deletions compiler/rustc_pattern_analysis/src/rustc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt;
use std::iter::once;

use rustc_arena::{DroplessArena, TypedArena};
use rustc_arena::DroplessArena;
use rustc_hir::def_id::DefId;
use rustc_hir::HirId;
use rustc_index::{Idx, IndexVec};
Expand Down Expand Up @@ -62,7 +62,7 @@ impl<'tcx> RevealedTy<'tcx> {
}

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

impl<'p, 'tcx> fmt::Debug for RustcMatchCheckCtxt<'p, 'tcx> {
impl<'p, 'tcx: 'p> fmt::Debug for RustcMatchCheckCtxt<'p, 'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RustcMatchCheckCtxt").finish()
}
}

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

impl<'p, 'tcx> TypeCx for RustcMatchCheckCtxt<'p, 'tcx> {
impl<'p, 'tcx: 'p> TypeCx for RustcMatchCheckCtxt<'p, 'tcx> {
type Ty = RevealedTy<'tcx>;
type Error = ErrorGuaranteed;
type VariantIdx = VariantIdx;
Expand Down

0 comments on commit f65fe3b

Please sign in to comment.