Skip to content

Commit 0f81fca

Browse files
committed
Change rustc_driver dependency on stable_mir crate
This fixes issues with RustAnalyzer not finding stable_mir crate. It is also part of the long term architecture plan for these crates, since we are moving towards having stable_mir depend on rustc_smir and not the other way around. I believe this is an utility function that will come handy eventually for stable_mir users, but I'm keeping it as part of rustc_internal since it initializes the StableMir context and requires `TyCtxt`. Finally, I added the rustc_internal crate under a feature since the APIs from this module shall not be stabilized.
1 parent 7188f45 commit 0f81fca

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

Cargo.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -3583,13 +3583,13 @@ dependencies = [
35833583
"rustc_query_system",
35843584
"rustc_resolve",
35853585
"rustc_session",
3586-
"rustc_smir",
35873586
"rustc_span",
35883587
"rustc_target",
35893588
"rustc_trait_selection",
35903589
"rustc_ty_utils",
35913590
"serde_json",
35923591
"shlex",
3592+
"stable_mir",
35933593
"tracing",
35943594
"windows 0.59.0",
35953595
]

compiler/rustc_driver_impl/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ rustc_privacy = { path = "../rustc_privacy" }
4444
rustc_query_system = { path = "../rustc_query_system" }
4545
rustc_resolve = { path = "../rustc_resolve" }
4646
rustc_session = { path = "../rustc_session" }
47-
rustc_smir = { path = "../rustc_smir" }
4847
rustc_span = { path = "../rustc_span" }
4948
rustc_target = { path = "../rustc_target" }
5049
rustc_trait_selection = { path = "../rustc_trait_selection" }
5150
rustc_ty_utils = { path = "../rustc_ty_utils" }
5251
serde_json = "1.0.59"
5352
shlex = "1.0"
53+
stable_mir = { path = "../stable_mir", features = ["rustc_internal"] }
5454
tracing = { version = "0.1.35" }
5555
# tidy-alphabetical-end
5656

compiler/rustc_driver_impl/src/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use rustc_middle::ty::{self, TyCtxt};
1010
use rustc_mir_build::thir::print::{thir_flat, thir_tree};
1111
use rustc_session::Session;
1212
use rustc_session::config::{OutFileName, PpHirMode, PpMode, PpSourceMode};
13-
use rustc_smir::rustc_internal::pretty::write_smir_pretty;
1413
use rustc_span::{FileName, Ident};
14+
use stable_mir::rustc_internal::pretty::write_smir_pretty;
1515
use tracing::debug;
1616
use {rustc_ast as ast, rustc_hir_pretty as pprust_hir};
1717

compiler/stable_mir/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ edition = "2024"
55

66
[dependencies]
77
rustc_smir = { path = "../rustc_smir" }
8+
9+
[features]
10+
# Provides access to APIs that expose internals of the rust compiler.
11+
# APIs enabled by this feature are unstable. They can be removed or modified
12+
# at any point and they are not included in the crate's semantic versioning.
13+
rustc_internal = []

compiler/stable_mir/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44
//! This is a transitional measure as described in [PR #139319](https://github.com/rust-lang/rust/pull/139319).
55
//! Once the refactoring is complete, the `stable_mir` implementation will be moved back here.
66
7+
/// Export the rustc_internal APIs. Note that this module has no stability
8+
/// guarantees and it is not taken into account for semver.
9+
#[cfg(feature = "rustc_internal")]
10+
pub use rustc_smir::rustc_internal;
711
pub use rustc_smir::stable_mir::*;

0 commit comments

Comments
 (0)