Skip to content

Commit 02aa4ff

Browse files
authored
Rollup merge of #143524 - makai410:smir-move-back, r=oli-obk
Move `stable_mir` back to its own crate We've finished the refactoring, so it's time to move `stable_mir` back to its own crate. This PR leaves an empty `rustc_internal` module with a `#[deprecated]` attribute in `rustc_smir` to let users know we just moved it to `stable_mir`.
2 parents 4ba4b5f + 627cefa commit 02aa4ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1284
-1344
lines changed

Cargo.lock

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4553,9 +4553,6 @@ dependencies = [
45534553
"rustc_session",
45544554
"rustc_span",
45554555
"rustc_target",
4556-
"scoped-tls",
4557-
"serde",
4558-
"tracing",
45594556
]
45604557

45614558
[[package]]
@@ -5108,7 +5105,16 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
51085105
name = "stable_mir"
51095106
version = "0.1.0-preview"
51105107
dependencies = [
5108+
"rustc_abi",
5109+
"rustc_hir",
5110+
"rustc_middle",
5111+
"rustc_session",
51115112
"rustc_smir",
5113+
"rustc_span",
5114+
"rustc_target",
5115+
"scoped-tls",
5116+
"serde",
5117+
"tracing",
51125118
]
51135119

51145120
[[package]]

compiler/rustc_smir/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@ rustc_middle = { path = "../rustc_middle" }
1313
rustc_session = { path = "../rustc_session" }
1414
rustc_span = { path = "../rustc_span" }
1515
rustc_target = { path = "../rustc_target" }
16-
scoped-tls = "1.0"
17-
serde = { version = "1.0.125", features = [ "derive" ] }
18-
tracing = "0.1"
1916
# tidy-alphabetical-end

compiler/rustc_smir/src/rustc_smir/alloc.rs renamed to compiler/rustc_smir/src/alloc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ use rustc_middle::mir::interpret::{
1111
use rustc_middle::ty::{Ty, layout};
1212

1313
use super::{SmirCtxt, Tables};
14-
use crate::rustc_smir::bridge::Allocation as _;
15-
use crate::rustc_smir::{Bridge, SmirError};
14+
use crate::bridge::Allocation as _;
15+
use crate::{Bridge, SmirError};
1616

1717
pub fn create_ty_and_layout<'tcx, B: Bridge>(
1818
cx: &SmirCtxt<'tcx, B>,
1919
ty: Ty<'tcx>,
2020
) -> Result<TyAndLayout<'tcx, Ty<'tcx>>, &'tcx layout::LayoutError<'tcx>> {
21-
use crate::rustc_smir::context::SmirTypingEnv;
21+
use crate::context::SmirTypingEnv;
2222
cx.tcx.layout_of(cx.fully_monomorphized().as_query_input(ty))
2323
}
2424

compiler/rustc_smir/src/rustc_smir/context/impls.rs renamed to compiler/rustc_smir/src/context/impls.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use rustc_span::{FileNameDisplayPreference, Span, Symbol};
2525
use rustc_target::callconv::FnAbi;
2626

2727
use super::{SmirAllocRange, SmirCtxt, SmirTy, SmirTypingEnv};
28-
use crate::rustc_smir::builder::BodyBuilder;
29-
use crate::rustc_smir::{Bridge, SmirError, Tables, filter_def_ids};
28+
use crate::builder::BodyBuilder;
29+
use crate::{Bridge, SmirError, Tables, filter_def_ids};
3030

3131
impl<'tcx, B: Bridge> SmirTy<'tcx> for SmirCtxt<'tcx, B> {
3232
fn new_foreign(&self, def_id: DefId) -> ty::Ty<'tcx> {
@@ -426,7 +426,7 @@ impl<'tcx, B: Bridge> SmirCtxt<'tcx, B> {
426426

427427
/// Evaluate constant as a target usize.
428428
pub fn eval_target_usize(&self, cnst: MirConst<'tcx>) -> Result<u64, B::Error> {
429-
use crate::rustc_smir::context::SmirTypingEnv;
429+
use crate::context::SmirTypingEnv;
430430
cnst.try_eval_target_usize(self.tcx, self.fully_monomorphized())
431431
.ok_or_else(|| B::Error::new(format!("Const `{cnst:?}` cannot be encoded as u64")))
432432
}
@@ -436,10 +436,7 @@ impl<'tcx, B: Bridge> SmirCtxt<'tcx, B> {
436436
.ok_or_else(|| B::Error::new(format!("Const `{cnst:?}` cannot be encoded as u64")))
437437
}
438438

439-
pub(crate) fn try_new_const_zst(
440-
&self,
441-
ty_internal: Ty<'tcx>,
442-
) -> Result<MirConst<'tcx>, B::Error> {
439+
pub fn try_new_const_zst(&self, ty_internal: Ty<'tcx>) -> Result<MirConst<'tcx>, B::Error> {
443440
let size = self
444441
.tcx
445442
.layout_of(self.fully_monomorphized().as_query_input(ty_internal))

compiler/rustc_smir/src/rustc_smir/context/mod.rs renamed to compiler/rustc_smir/src/context/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::ty;
99
use rustc_middle::ty::layout::{FnAbiOfHelpers, HasTyCtxt, HasTypingEnv, LayoutOfHelpers};
1010
use rustc_middle::ty::{Ty, TyCtxt};
1111

12-
use crate::rustc_smir::{Bridge, SmirError};
12+
use crate::{Bridge, SmirError};
1313

1414
mod impls;
1515
mod traits;
@@ -18,7 +18,7 @@ pub use traits::*;
1818

1919
/// Provides direct access to rustc's internal queries.
2020
///
21-
/// The [`crate::stable_mir::compiler_interface::SmirInterface`] must go through
21+
/// `SmirInterface` must go through
2222
/// this context to obtain rustc-level information.
2323
pub struct SmirCtxt<'tcx, B: Bridge> {
2424
pub tcx: TyCtxt<'tcx>,

compiler/rustc_smir/src/rustc_smir/context/traits.rs renamed to compiler/rustc_smir/src/context/traits.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,6 @@ use rustc_middle::ty;
88
use rustc_middle::ty::Ty;
99
use rustc_span::def_id::DefId;
1010

11-
pub trait SmirExistentialProjection<'tcx> {
12-
fn new_from_args(
13-
&self,
14-
def_id: DefId,
15-
args: ty::GenericArgsRef<'tcx>,
16-
term: ty::Term<'tcx>,
17-
) -> ty::ExistentialProjection<'tcx>;
18-
}
19-
20-
pub trait SmirExistentialTraitRef<'tcx> {
21-
fn new_from_args(
22-
&self,
23-
trait_def_id: DefId,
24-
args: ty::GenericArgsRef<'tcx>,
25-
) -> ty::ExistentialTraitRef<'tcx>;
26-
}
27-
28-
pub trait SmirTraitRef<'tcx> {
29-
fn new_from_args(
30-
&self,
31-
trait_def_id: DefId,
32-
args: ty::GenericArgsRef<'tcx>,
33-
) -> ty::TraitRef<'tcx>;
34-
}
35-
3611
pub trait SmirTy<'tcx> {
3712
fn new_foreign(&self, def_id: DefId) -> Ty<'tcx>;
3813
}

0 commit comments

Comments
 (0)