From 48d089a8002d57f0c7b473905bc1925e99bcc76d Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 26 Dec 2023 03:12:48 +0000 Subject: [PATCH] Merge 'thir and 'p --- .../src/thir/pattern/check_match.rs | 34 +++++++++---------- compiler/rustc_pattern_analysis/src/rustc.rs | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 0e85b3452d3..c8e5b934beb 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -75,11 +75,11 @@ enum LetSource { WhileLet, } -struct MatchVisitor<'thir, 'p, 'tcx> { +struct MatchVisitor<'p, 'tcx> { tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, typeck_results: &'tcx ty::TypeckResults<'tcx>, - thir: &'thir Thir<'tcx>, + thir: &'p Thir<'tcx>, lint_level: HirId, let_source: LetSource, pattern_arena: &'p TypedArena>, @@ -92,13 +92,13 @@ struct MatchVisitor<'thir, 'p, 'tcx> { // Visitor for a thir body. This calls `check_match`, `check_let` and `check_let_chain` as // appropriate. -impl<'thir, 'tcx> Visitor<'thir, 'tcx> for MatchVisitor<'thir, '_, 'tcx> { - fn thir(&self) -> &'thir Thir<'tcx> { +impl<'p, 'tcx> Visitor<'p, 'tcx> for MatchVisitor<'p, 'tcx> { + fn thir(&self) -> &'p Thir<'tcx> { self.thir } #[instrument(level = "trace", skip(self))] - fn visit_arm(&mut self, arm: &'thir Arm<'tcx>) { + fn visit_arm(&mut self, arm: &'p Arm<'tcx>) { self.with_lint_level(arm.lint_level, |this| { match arm.guard { Some(Guard::If(expr)) => { @@ -121,7 +121,7 @@ impl<'thir, 'tcx> Visitor<'thir, 'tcx> for MatchVisitor<'thir, '_, 'tcx> { } #[instrument(level = "trace", skip(self))] - fn visit_expr(&mut self, ex: &'thir Expr<'tcx>) { + fn visit_expr(&mut self, ex: &'p Expr<'tcx>) { match ex.kind { ExprKind::Scope { value, lint_level, .. } => { self.with_lint_level(lint_level, |this| { @@ -174,7 +174,7 @@ impl<'thir, 'tcx> Visitor<'thir, 'tcx> for MatchVisitor<'thir, '_, 'tcx> { self.with_let_source(LetSource::None, |this| visit::walk_expr(this, ex)); } - fn visit_stmt(&mut self, stmt: &'thir Stmt<'tcx>) { + fn visit_stmt(&mut self, stmt: &'p Stmt<'tcx>) { match stmt.kind { StmtKind::Let { box ref pattern, initializer, else_block, lint_level, span, .. @@ -195,7 +195,7 @@ impl<'thir, 'tcx> Visitor<'thir, 'tcx> for MatchVisitor<'thir, '_, 'tcx> { } } -impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> { +impl<'p, 'tcx> MatchVisitor<'p, 'tcx> { #[instrument(level = "trace", skip(self, f))] fn with_let_source(&mut self, let_source: LetSource, f: impl FnOnce(&mut Self)) { let old_let_source = self.let_source; @@ -224,7 +224,7 @@ impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> { /// subexpressions we are not handling ourselves. fn visit_land( &mut self, - ex: &'thir Expr<'tcx>, + ex: &'p Expr<'tcx>, accumulator: &mut Vec>, ) -> Result<(), ErrorGuaranteed> { match ex.kind { @@ -251,7 +251,7 @@ impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> { /// expression. This must call `visit_expr` on the subexpressions we are not handling ourselves. fn visit_land_rhs( &mut self, - ex: &'thir Expr<'tcx>, + ex: &'p Expr<'tcx>, ) -> Result, ErrorGuaranteed> { match ex.kind { ExprKind::Scope { value, lint_level, .. } => { @@ -276,7 +276,7 @@ impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> { fn lower_pattern( &mut self, cx: &MatchCheckCtxt<'p, 'tcx>, - pat: &'thir Pat<'tcx>, + pat: &'p Pat<'tcx>, ) -> Result<&'p DeconstructedPat<'p, 'tcx>, ErrorGuaranteed> { if let Err(err) = pat.pat_error_reported() { self.error = Err(err); @@ -395,7 +395,7 @@ impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> { } #[instrument(level = "trace", skip(self))] - fn check_let(&mut self, pat: &'thir Pat<'tcx>, scrutinee: Option, span: Span) { + fn check_let(&mut self, pat: &'p Pat<'tcx>, scrutinee: Option, span: Span) { assert!(self.let_source != LetSource::None); let scrut = scrutinee.map(|id| &self.thir[id]); if let LetSource::PlainLet = self.let_source { @@ -547,7 +547,7 @@ impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> { fn analyze_binding( &mut self, - pat: &'thir Pat<'tcx>, + pat: &'p Pat<'tcx>, refutability: RefutableFlag, scrut: Option<&Expr<'tcx>>, ) -> Result<(MatchCheckCtxt<'p, 'tcx>, UsefulnessReport<'p, 'tcx>), ErrorGuaranteed> { @@ -560,7 +560,7 @@ impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> { fn is_let_irrefutable( &mut self, - pat: &'thir Pat<'tcx>, + pat: &'p Pat<'tcx>, scrut: Option<&Expr<'tcx>>, ) -> Result { let (cx, report) = self.analyze_binding(pat, Refutable, scrut)?; @@ -575,7 +575,7 @@ impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> { #[instrument(level = "trace", skip(self))] fn check_binding_is_irrefutable( &mut self, - pat: &'thir Pat<'tcx>, + pat: &'p Pat<'tcx>, origin: &str, scrut: Option<&Expr<'tcx>>, sp: Option, @@ -677,7 +677,7 @@ impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> { /// - `x @ Some(ref mut? y)`. /// /// This analysis is *not* subsumed by NLL. -fn check_borrow_conflicts_in_at_patterns<'tcx>(cx: &MatchVisitor<'_, '_, 'tcx>, pat: &Pat<'tcx>) { +fn check_borrow_conflicts_in_at_patterns<'tcx>(cx: &MatchVisitor<'_, 'tcx>, pat: &Pat<'tcx>) { // Extract `sub` in `binding @ sub`. let PatKind::Binding { name, mode, ty, subpattern: Some(box ref sub), .. } = pat.kind else { return; @@ -772,7 +772,7 @@ fn check_borrow_conflicts_in_at_patterns<'tcx>(cx: &MatchVisitor<'_, '_, 'tcx>, } fn check_for_bindings_named_same_as_variants( - cx: &MatchVisitor<'_, '_, '_>, + cx: &MatchVisitor<'_, '_>, pat: &Pat<'_>, rf: RefutableFlag, ) { diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index 84aa6a0bbfd..e9922f621b7 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -399,7 +399,7 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> { /// Note: the input patterns must have been lowered through /// `rustc_mir_build::thir::pattern::check_match::MatchVisitor::lower_pattern`. - pub fn lower_pat(&self, pat: &Pat<'tcx>) -> DeconstructedPat<'p, 'tcx> { + pub fn lower_pat(&self, pat: &'p Pat<'tcx>) -> DeconstructedPat<'p, 'tcx> { let singleton = |pat| std::slice::from_ref(self.pattern_arena.alloc(pat)); let cx = self; let ctor;