Skip to content

Commit 8563fef

Browse files
committed
!! (WIP) mut thir
1 parent da71e30 commit 8563fef

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

compiler/rustc_mir_build/src/thir/cx/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'tcx> ThirBuildCx<'tcx> {
120120

121121
#[instrument(level = "debug", skip(self))]
122122
fn pattern_from_hir(&mut self, p: &'tcx hir::Pat<'tcx>) -> Box<Pat<'tcx>> {
123-
pat_from_hir(self.tcx, self.typing_env, self.typeck_results, p)
123+
pat_from_hir(self.tcx, &mut self.thir, self.typing_env, self.typeck_results, p)
124124
}
125125

126126
fn closure_env_param(&self, owner_def: LocalDefId, expr_id: HirId) -> Option<Param<'tcx>> {

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_index::Idx;
99
use rustc_infer::infer::TyCtxtInferExt;
1010
use rustc_infer::traits::Obligation;
1111
use rustc_middle::mir::interpret::ErrorHandled;
12-
use rustc_middle::thir::{FieldPat, Pat, PatKind};
12+
use rustc_middle::thir::{FieldPat, Pat, PatKind, Thir};
1313
use rustc_middle::ty::{
1414
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitableExt, TypeVisitor, ValTree,
1515
};
@@ -36,7 +36,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
3636
/// so we have to carry one ourselves.
3737
#[instrument(level = "debug", skip(self), ret)]
3838
pub(super) fn const_to_pat(
39-
&self,
39+
&mut self,
4040
c: ty::Const<'tcx>,
4141
ty: Ty<'tcx>,
4242
id: hir::HirId,
@@ -52,8 +52,9 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
5252
}
5353
}
5454

55-
struct ConstToPat<'tcx> {
55+
struct ConstToPat<'a, 'tcx> {
5656
tcx: TyCtxt<'tcx>,
57+
thir: &'a mut Thir<'tcx>,
5758
typing_env: ty::TypingEnv<'tcx>,
5859
span: Span,
5960
id: hir::HirId,
@@ -63,11 +64,17 @@ struct ConstToPat<'tcx> {
6364
c: ty::Const<'tcx>,
6465
}
6566

66-
impl<'tcx> ConstToPat<'tcx> {
67-
fn new(pat_ctxt: &PatCtxt<'_, 'tcx>, id: hir::HirId, span: Span, c: ty::Const<'tcx>) -> Self {
67+
impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
68+
fn new(
69+
pat_ctxt: &'a mut PatCtxt<'_, 'tcx>,
70+
id: hir::HirId,
71+
span: Span,
72+
c: ty::Const<'tcx>,
73+
) -> Self {
6874
trace!(?pat_ctxt.typeck_results.hir_owner);
6975
ConstToPat {
7076
tcx: pat_ctxt.tcx,
77+
thir: pat_ctxt.thir,
7178
typing_env: pat_ctxt.typing_env,
7279
span,
7380
id,

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_hir::{self as hir, RangeEnd};
1515
use rustc_index::Idx;
1616
use rustc_middle::mir::interpret::LitToConstInput;
1717
use rustc_middle::thir::{
18-
Ascription, FieldPat, LocalVarId, Pat, PatKind, PatRange, PatRangeBoundary,
18+
Ascription, FieldPat, LocalVarId, Pat, PatKind, PatRange, PatRangeBoundary, Thir,
1919
};
2020
use rustc_middle::ty::layout::IntegerExt;
2121
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt, TypeVisitableExt};
@@ -30,6 +30,7 @@ use crate::errors::*;
3030

3131
struct PatCtxt<'a, 'tcx> {
3232
tcx: TyCtxt<'tcx>,
33+
thir: &'a mut Thir<'tcx>,
3334
typing_env: ty::TypingEnv<'tcx>,
3435
typeck_results: &'a ty::TypeckResults<'tcx>,
3536

@@ -39,12 +40,14 @@ struct PatCtxt<'a, 'tcx> {
3940

4041
pub(super) fn pat_from_hir<'a, 'tcx>(
4142
tcx: TyCtxt<'tcx>,
43+
thir: &'a mut Thir<'tcx>,
4244
typing_env: ty::TypingEnv<'tcx>,
4345
typeck_results: &'a ty::TypeckResults<'tcx>,
4446
pat: &'tcx hir::Pat<'tcx>,
4547
) -> Box<Pat<'tcx>> {
4648
let mut pcx = PatCtxt {
4749
tcx,
50+
thir,
4851
typing_env,
4952
typeck_results,
5053
rust_2024_migration: typeck_results

0 commit comments

Comments
 (0)