Skip to content

Commit 2769522

Browse files
authored
Rollup merge of #139319 - makai410:refactor, r=celinval
StableMIR: Prepare for refactoring Temporarily make `stable_mir` "parasitic" on the `rustc_smir` crate. It aims to resolve the circular dependency that would arise if we directly invert the dependency order between `rustc_smir` and `stable_mir`. Once the refactoring is complete (`rustc_smir` does not depend on `stable_mir`), we will migrate it back to the `stable_mir` crate. See more details: [here](https://hackmd.io/jBRkZLqAQL2EVgwIIeNMHg).
2 parents 527725b + 707d356 commit 2769522

File tree

31 files changed

+346
-305
lines changed

31 files changed

+346
-305
lines changed

Cargo.lock

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4432,7 +4432,7 @@ dependencies = [
44324432
"rustc_span",
44334433
"rustc_target",
44344434
"scoped-tls",
4435-
"stable_mir",
4435+
"serde",
44364436
"tracing",
44374437
]
44384438

@@ -4990,8 +4990,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
49904990
name = "stable_mir"
49914991
version = "0.1.0-preview"
49924992
dependencies = [
4993-
"scoped-tls",
4994-
"serde",
4993+
"rustc_smir",
49954994
]
49964995

49974996
[[package]]

compiler/rustc_smir/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ rustc_session = { path = "../rustc_session" }
1414
rustc_span = { path = "../rustc_span" }
1515
rustc_target = { path = "../rustc_target" }
1616
scoped-tls = "1.0"
17-
stable_mir = {path = "../stable_mir" }
17+
serde = { version = "1.0.125", features = [ "derive" ] }
1818
tracing = "0.1"
1919
# tidy-alphabetical-end

compiler/rustc_smir/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ pub mod rustc_internal;
2222

2323
// Make this module private for now since external users should not call these directly.
2424
mod rustc_smir;
25+
26+
pub mod stable_mir;

compiler/rustc_smir/src/rustc_internal/internal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use stable_mir::{CrateItem, CrateNum, DefId};
2121

2222
use super::RustcInternal;
2323
use crate::rustc_smir::Tables;
24+
use crate::stable_mir;
2425

2526
impl RustcInternal for CrateItem {
2627
type T<'tcx> = rustc_span::def_id::DefId;

compiler/rustc_smir/src/rustc_internal/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use stable_mir::ty::IndexedVal;
2222

2323
use crate::rustc_smir::context::TablesWrapper;
2424
use crate::rustc_smir::{Stable, Tables};
25+
use crate::stable_mir;
2526

2627
mod internal;
2728
pub mod pretty;

compiler/rustc_smir/src/rustc_internal/pretty.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::io;
33
use rustc_middle::ty::TyCtxt;
44

55
use super::run;
6+
use crate::stable_mir;
67

78
pub fn write_smir_pretty<'tcx, W: io::Write>(tcx: TyCtxt<'tcx>, w: &mut W) -> io::Result<()> {
89
writeln!(

compiler/rustc_smir/src/rustc_smir/alloc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use stable_mir::mir::Mutability;
66
use stable_mir::ty::{Allocation, ProvenanceMap};
77

88
use crate::rustc_smir::{Stable, Tables};
9+
use crate::stable_mir;
910

1011
/// Creates new empty `Allocation` from given `Align`.
1112
fn new_empty_allocation(align: Align) -> Allocation {

compiler/rustc_smir/src/rustc_smir/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_middle::mir::visit::MutVisitor;
1010
use rustc_middle::ty::{self, TyCtxt};
1111

1212
use crate::rustc_smir::{Stable, Tables};
13+
use crate::stable_mir;
1314

1415
/// Builds a monomorphic body for a given instance.
1516
pub(crate) struct BodyBuilder<'tcx> {

compiler/rustc_smir/src/rustc_smir/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use stable_mir::{Crate, CrateDef, CrateItem, CrateNum, DefId, Error, Filename, I
3535
use crate::rustc_internal::RustcInternal;
3636
use crate::rustc_smir::builder::BodyBuilder;
3737
use crate::rustc_smir::{Stable, Tables, alloc, filter_def_ids, new_item_kind, smir_crate};
38+
use crate::stable_mir;
3839

3940
impl<'tcx> Context for TablesWrapper<'tcx> {
4041
fn target_info(&self) -> MachineInfo {

compiler/rustc_smir/src/rustc_smir/convert/abi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use stable_mir::target::MachineSize as Size;
1414
use stable_mir::ty::{Align, IndexedVal, VariantIdx};
1515

1616
use crate::rustc_smir::{Stable, Tables};
17+
use crate::stable_mir;
1718

1819
impl<'tcx> Stable<'tcx> for rustc_abi::VariantIdx {
1920
type T = VariantIdx;

0 commit comments

Comments
 (0)