Skip to content

Commit 7ea3350

Browse files
authored
Rollup merge of #140532 - celinval:chores-smir-ra, r=oli-obk
Fix RustAnalyzer discovery of rustc's `stable_mir` crate This fixes issues with RustAnalyzer not finding `stable_mir` crate since RA discovery traverses the dependency graph of `rustc_driver` crate. This change also aligns with 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. See [this doc](https://hackmd.io/jBRkZLqAQL2EVgwIIeNMHg) for more details. I believe a similar function will come handy eventually for `stable_mir` users, but I'm keeping it as part of `rustc_internal` since its current format initializes the StableMir context and requires `TyCtxt`. Finally, I added the `rustc_internal` module re-export under a feature since the APIs from this module shall not be stabilized.
2 parents 7cd7605 + 0f81fca commit 7ea3350

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
@@ -3605,13 +3605,13 @@ dependencies = [
36053605
"rustc_query_system",
36063606
"rustc_resolve",
36073607
"rustc_session",
3608-
"rustc_smir",
36093608
"rustc_span",
36103609
"rustc_target",
36113610
"rustc_trait_selection",
36123611
"rustc_ty_utils",
36133612
"serde_json",
36143613
"shlex",
3614+
"stable_mir",
36153615
"tracing",
36163616
"windows 0.59.0",
36173617
]

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)