Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: rust-lang/rust
ref: a2545fd6fc66b4323f555223a860c451885d1d2b # hash of Hardcoded Rust version
ref: 0d9592026226f5a667a0da60c13b955e0b486a07 # hash of nightly-2025-07-20 (rustc --version)
path: rust
fetch-depth: 1

Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ path = "src/bin/cargo_stable_mir_json.rs"

[package.metadata.rust-analyzer]
# This package uses rustc crates.
rustc_private=true
rustc_private=true

[lints.clippy]
uninlined_format_args = "allow"
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-11-29"
channel = "nightly-2025-07-20"
components = ["llvm-tools", "rustc-dev", "rust-src"]
6 changes: 3 additions & 3 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
extern crate rustc_driver;
extern crate rustc_interface;
extern crate rustc_middle;
extern crate rustc_public;
extern crate rustc_session;
extern crate rustc_smir;
use rustc_driver::Compilation;
use rustc_interface::interface::Compiler;
use rustc_middle::ty::TyCtxt;
use rustc_smir::rustc_internal;
use rustc_public::rustc_internal;

struct StableMirCallbacks {
callback_fn: fn(TyCtxt) -> (),
Expand All @@ -44,5 +44,5 @@ pub fn stable_mir_driver(args_outer: &[String], callback_fn: fn(TyCtxt) -> ()) {
let early_dcx =
rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default());
rustc_driver::init_rustc_env_logger(&early_dcx);
let _ = rustc_driver::RunCompiler::new(args_outer, &mut callbacks).run();
rustc_driver::run_compiler(args_outer, &mut callbacks);
}
37 changes: 20 additions & 17 deletions src/mk_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ use dot_writer::{Attributes, Color, DotWriter, Scope, Shape, Style};
extern crate rustc_middle;
use rustc_middle::ty::TyCtxt;

extern crate stable_mir;
extern crate rustc_public;
extern crate rustc_public_bridge;
use rustc_session::config::{OutFileName, OutputType};

extern crate rustc_session;
use stable_mir::ty::{IndexedVal, Ty};
use stable_mir::{
use rustc_public::ty::Ty;
use rustc_public::{
mir::{
AggregateKind, BasicBlock, BorrowKind, ConstOperand, Mutability, NonDivergingIntrinsic,
NullOp, Operand, Place, ProjectionElem, Rvalue, Statement, StatementKind, TerminatorKind,
UnwindAction,
NullOp, Operand, Place, ProjectionElem, RawPtrKind, Rvalue, Statement, StatementKind,
TerminatorKind, UnwindAction,
},
ty::RigidTy,
};
use rustc_public_bridge::IndexedVal;

use crate::{
printer::{collect_smir, FnSymType, SmirJson},
Expand Down Expand Up @@ -136,16 +138,16 @@ impl SmirJson<'_> {
.attributes()
.set_label("other");
}
Resume {} => {
Resume => {
label_strs.push("Resume".to_string());
}
Abort {} => {
Abort => {
label_strs.push("Abort".to_string());
}
Return {} => {
Return => {
label_strs.push("Return".to_string());
}
Unreachable {} => {
Unreachable => {
label_strs.push("Unreachable".to_string());
}
TerminatorKind::Drop {
Expand Down Expand Up @@ -380,8 +382,8 @@ fn render_stmt(s: &Statement) -> String {
} => format!("Ascribe {}.{}", place.label(), projections.base),
Coverage(_) => "Coverage".to_string(),
Intrinsic(intr) => format!("Intr: {}", intr.label()),
ConstEvalCounter {} => "ConstEvalCounter".to_string(),
Nop {} => "Nop".to_string(),
ConstEvalCounter => "ConstEvalCounter".to_string(),
Nop => "Nop".to_string(),
}
}

Expand All @@ -396,8 +398,8 @@ impl GraphLabelString for Operand {
Operand::Constant(ConstOperand { const_, .. }) => {
let ty = const_.ty();
match &ty.kind() {
stable_mir::ty::TyKind::RigidTy(RigidTy::Int(_))
| stable_mir::ty::TyKind::RigidTy(RigidTy::Uint(_)) => {
rustc_public::ty::TyKind::RigidTy(RigidTy::Int(_))
| rustc_public::ty::TyKind::RigidTy(RigidTy::Uint(_)) => {
format!("const ?_{}", const_.ty())
}
_ => format!("const {}", const_.ty()),
Expand Down Expand Up @@ -448,11 +450,11 @@ impl GraphLabelString for AggregateKind {
use AggregateKind::*;
match &self {
Array(_ty) => "Array".to_string(),
Tuple {} => "Tuple".to_string(),
Tuple => "Tuple".to_string(),
Adt(_, idx, _, _, _) => format!("Adt{{{}}}", idx.to_index()), // (AdtDef, VariantIdx, GenericArgs, Option<usize>, Option<FieldIdx>),
Closure(_, _) => "Closure".to_string(), // (ClosureDef, GenericArgs),
Coroutine(_, _, _) => "Coroutine".to_string(), // (CoroutineDef, GenericArgs, Movability),
// CoroutineClosure{} => "CoroutineClosure".to_string(), // (CoroutineClosureDef, GenericArgs),
CoroutineClosure(_, _) => "CoroutineClosure".to_string(), // (CoroutineClosureDef, GenericArgs),
RawPtr(ty, Mutability::Mut) => format!("*mut ({})", ty),
RawPtr(ty, Mutability::Not) => format!("*({})", ty),
}
Expand All @@ -464,8 +466,9 @@ impl GraphLabelString for Rvalue {
use Rvalue::*;
match &self {
AddressOf(mutability, p) => match mutability {
Mutability::Not => format!("&raw {}", p.label()),
Mutability::Mut => format!("&raw mut {}", p.label()),
RawPtrKind::Const => format!("&raw {}", p.label()),
RawPtrKind::Mut => format!("&raw mut {}", p.label()),
RawPtrKind::FakeForPtrMetadata => format!("&raw4meta {}", p.label()),
},
Aggregate(kind, operands) => {
let os: Vec<String> = operands.iter().map(|op| op.label()).collect();
Expand Down
Loading