Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5d1551b

Browse files
committedFeb 18, 2025
Remove rustc_middle::mir::tcx module.
This is a really weird module. For example, what does `tcx` in `rustc_middle::mir::tcx::PlaceTy` mean? The answer is "not much". The top-level module comment says: > Methods for the various MIR types. These are intended for use after > building is complete. Awfully broad for a module that has a handful of impl blocks for some MIR types, none of which really relates to `TyCtxt`. `git blame` indicates the comment is ancient, from 2015, and made sense then. This module is now vestigial. This commit removes it and moves all the code within into `rustc_middle::mir::statement`. Some specifics: - `Place`, `PlaceRef`, `Rvalue`, `Operand`, `BorrowKind`: they all have `impl` blocks in both the `tcx` and `statement` modules. The commit merges the former into the latter. - `BinOp`, `UnOp`: they only have `impl` blocks in `tcx`. The commit moves these into `statement`. - `PlaceTy`, `RvalueInitializationState`: they are defined in `tcx`. This commit moves them into `statement` *and* makes them available in `mir::*`, like many other MIR types.
1 parent ce36a96 commit 5d1551b

File tree

13 files changed

+402
-430
lines changed

13 files changed

+402
-430
lines changed
 

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ use rustc_hir::intravisit::{Visitor, walk_block, walk_expr};
1818
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField};
1919
use rustc_middle::bug;
2020
use rustc_middle::hir::nested_filter::OnlyBodies;
21-
use rustc_middle::mir::tcx::PlaceTy;
2221
use rustc_middle::mir::{
2322
self, AggregateKind, BindingForm, BorrowKind, ClearCrossCrate, ConstraintCategory,
2423
FakeBorrowKind, FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, MutBorrowKind,
25-
Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator,
26-
TerminatorKind, VarBindingForm, VarDebugInfoContents,
24+
Operand, Place, PlaceRef, PlaceTy, ProjectionElem, Rvalue, Statement, StatementKind,
25+
Terminator, TerminatorKind, VarBindingForm, VarDebugInfoContents,
2726
};
2827
use rustc_middle::ty::print::PrintTraitRefExt as _;
2928
use rustc_middle::ty::{

‎compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ use rustc_infer::infer::{
1313
};
1414
use rustc_infer::traits::SelectionError;
1515
use rustc_middle::bug;
16-
use rustc_middle::mir::tcx::PlaceTy;
1716
use rustc_middle::mir::{
1817
AggregateKind, CallSource, ConstOperand, ConstraintCategory, FakeReadCause, Local, LocalInfo,
19-
LocalKind, Location, Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement,
18+
LocalKind, Location, Operand, Place, PlaceRef, PlaceTy, ProjectionElem, Rvalue, Statement,
2019
StatementKind, Terminator, TerminatorKind, find_self_call,
2120
};
2221
use rustc_middle::ty::print::Print;

‎compiler/rustc_borrowck/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use rustc_index::{IndexSlice, IndexVec};
3333
use rustc_infer::infer::{
3434
InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin, TyCtxtInferExt,
3535
};
36-
use rustc_middle::mir::tcx::PlaceTy;
3736
use rustc_middle::mir::*;
3837
use rustc_middle::query::Providers;
3938
use rustc_middle::ty::fold::fold_regions;

‎compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use rustc_infer::infer::{
1919
BoundRegion, BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin,
2020
};
2121
use rustc_infer::traits::PredicateObligations;
22-
use rustc_middle::mir::tcx::PlaceTy;
2322
use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
2423
use rustc_middle::mir::*;
2524
use rustc_middle::traits::query::NoSolution;

‎compiler/rustc_codegen_ssa/src/mir/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_abi::Primitive::{Int, Pointer};
22
use rustc_abi::{Align, BackendRepr, FieldsShape, Size, TagEncoding, VariantIdx, Variants};
3+
use rustc_middle::mir::PlaceTy;
34
use rustc_middle::mir::interpret::Scalar;
4-
use rustc_middle::mir::tcx::PlaceTy;
55
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
66
use rustc_middle::ty::{self, Ty};
77
use rustc_middle::{bug, mir};

‎compiler/rustc_middle/src/mir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub mod pretty;
5353
mod query;
5454
mod statement;
5555
mod syntax;
56-
pub mod tcx;
5756
mod terminator;
5857

5958
pub mod traversal;

‎compiler/rustc_middle/src/mir/statement.rs

Lines changed: 396 additions & 0 deletions
Large diffs are not rendered by default.

‎compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ pub type AssertMessage<'tcx> = AssertKind<Operand<'tcx>>;
11251125
///
11261126
/// 1. The address in memory that the place refers to.
11271127
/// 2. The provenance with which the place is being accessed.
1128-
/// 3. The type of the place and an optional variant index. See [`PlaceTy`][super::tcx::PlaceTy].
1128+
/// 3. The type of the place and an optional variant index. See [`PlaceTy`][super::PlaceTy].
11291129
/// 4. Optionally, some metadata. This exists if and only if the type of the place is not `Sized`.
11301130
///
11311131
/// We'll give a description below of how all pieces of the place except for the provenance are

‎compiler/rustc_middle/src/mir/tcx.rs

Lines changed: 0 additions & 416 deletions
This file was deleted.

‎compiler/rustc_mir_build/src/builder/custom/parse/instruction.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustc_abi::{FieldIdx, VariantIdx};
22
use rustc_middle::mir::interpret::Scalar;
3-
use rustc_middle::mir::tcx::PlaceTy;
43
use rustc_middle::mir::*;
54
use rustc_middle::thir::*;
65
use rustc_middle::ty;

‎compiler/rustc_mir_dataflow/src/move_paths/builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::mem;
22

33
use rustc_index::IndexVec;
4-
use rustc_middle::mir::tcx::{PlaceTy, RvalueInitializationState};
54
use rustc_middle::mir::*;
65
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
76
use rustc_middle::{bug, span_bug};

‎compiler/rustc_mir_dataflow/src/value_analysis.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet, StdEntry};
77
use rustc_data_structures::stack::ensure_sufficient_stack;
88
use rustc_index::IndexVec;
99
use rustc_index::bit_set::DenseBitSet;
10-
use rustc_middle::mir::tcx::PlaceTy;
1110
use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor};
1211
use rustc_middle::mir::*;
1312
use rustc_middle::ty::{self, Ty, TyCtxt};

‎compiler/rustc_mir_transform/src/elaborate_drop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ where
185185
place.ty(self.elaborator.body(), self.tcx()).ty
186186
} else {
187187
// We don't have a slice with all the locals, since some are in the patch.
188-
tcx::PlaceTy::from_ty(self.elaborator.patch_ref().local_ty(place.local))
188+
PlaceTy::from_ty(self.elaborator.patch_ref().local_ty(place.local))
189189
.multi_projection_ty(self.elaborator.tcx(), place.projection)
190190
.ty
191191
}

0 commit comments

Comments
 (0)
This repository has been archived.