Skip to content

Rename stable_mir and rustc_smir #143848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
66 changes: 33 additions & 33 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3271,8 +3271,8 @@ dependencies = [
"rustc_codegen_ssa",
"rustc_driver",
"rustc_driver_impl",
"rustc_smir",
"stable_mir",
"rustc_public",
"rustc_public_shim",
"tikv-jemalloc-sys",
]

Expand Down Expand Up @@ -3709,6 +3709,7 @@ dependencies = [
"rustc_passes",
"rustc_pattern_analysis",
"rustc_privacy",
"rustc_public",
"rustc_query_system",
"rustc_resolve",
"rustc_session",
Expand All @@ -3718,7 +3719,6 @@ dependencies = [
"rustc_ty_utils",
"serde_json",
"shlex",
"stable_mir",
"tracing",
"windows 0.61.3",
]
Expand Down Expand Up @@ -4414,6 +4414,36 @@ dependencies = [
"rustc-literal-escaper",
]

[[package]]
name = "rustc_public"
version = "0.1.0-preview"
dependencies = [
"rustc_abi",
"rustc_hir",
"rustc_middle",
"rustc_public_shim",
"rustc_session",
"rustc_span",
"rustc_target",
"scoped-tls",
"serde",
"tracing",
]

[[package]]
name = "rustc_public_shim"
version = "0.0.0"
dependencies = [
"rustc_abi",
"rustc_data_structures",
"rustc_hir",
"rustc_hir_pretty",
"rustc_middle",
"rustc_session",
"rustc_span",
"rustc_target",
]

[[package]]
name = "rustc_query_impl"
version = "0.0.0"
Expand Down Expand Up @@ -4541,20 +4571,6 @@ dependencies = [
"windows 0.61.3",
]

[[package]]
name = "rustc_smir"
version = "0.0.0"
dependencies = [
"rustc_abi",
"rustc_data_structures",
"rustc_hir",
"rustc_hir_pretty",
"rustc_middle",
"rustc_session",
"rustc_span",
"rustc_target",
]

[[package]]
name = "rustc_span"
version = "0.0.0"
Expand Down Expand Up @@ -5102,22 +5118,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"

[[package]]
name = "stable_mir"
version = "0.1.0-preview"
dependencies = [
"rustc_abi",
"rustc_hir",
"rustc_middle",
"rustc_session",
"rustc_smir",
"rustc_span",
"rustc_target",
"scoped-tls",
"serde",
"tracing",
]

[[package]]
name = "stacker"
version = "0.1.21"
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
rustc_driver = { path = "../rustc_driver" }
rustc_driver_impl = { path = "../rustc_driver_impl" }

# Make sure rustc_smir ends up in the sysroot, because this
# crate is intended to be used by stable MIR consumers, which are not in-tree.
rustc_smir = { path = "../rustc_smir" }
rustc_public = { path = "../rustc_public" }

stable_mir = { path = "../stable_mir" }
# Make sure rustc_public_shim ends up in the sysroot, because this
# crate is intended to be used by stable MIR consumers, which are not in-tree.
rustc_public_shim = { path = "../rustc_public_shim" }
# tidy-alphabetical-end

[dependencies.tikv-jemalloc-sys]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ rustc_parse = { path = "../rustc_parse" }
rustc_passes = { path = "../rustc_passes" }
rustc_pattern_analysis = { path = "../rustc_pattern_analysis" }
rustc_privacy = { path = "../rustc_privacy" }
rustc_public = { path = "../rustc_public", features = ["rustc_internal"] }
rustc_query_system = { path = "../rustc_query_system" }
rustc_resolve = { path = "../rustc_resolve" }
rustc_session = { path = "../rustc_session" }
Expand All @@ -50,7 +51,6 @@ rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_ty_utils = { path = "../rustc_ty_utils" }
serde_json = "1.0.59"
shlex = "1.0"
stable_mir = { path = "../stable_mir", features = ["rustc_internal"] }
tracing = { version = "0.1.35" }
# tidy-alphabetical-end

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver_impl/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use rustc_middle::bug;
use rustc_middle::mir::{write_mir_graphviz, write_mir_pretty};
use rustc_middle::ty::{self, TyCtxt};
use rustc_mir_build::thir::print::{thir_flat, thir_tree};
use rustc_public::rustc_internal::pretty::write_smir_pretty;
use rustc_session::Session;
use rustc_session::config::{OutFileName, PpHirMode, PpMode, PpSourceMode};
use rustc_span::{FileName, Ident};
use stable_mir::rustc_internal::pretty::write_smir_pretty;
use tracing::debug;
use {rustc_ast as ast, rustc_hir_pretty as pprust_hir};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "stable_mir"
name = "rustc_public"
version = "0.1.0-preview"
edition = "2024"

Expand All @@ -8,8 +8,8 @@ edition = "2024"
rustc_abi = { path = "../rustc_abi" }
rustc_hir = { path = "../rustc_hir" }
rustc_middle = { path = "../rustc_middle" }
rustc_public_shim = { path = "../rustc_public_shim" }
rustc_session = { path = "../rustc_session" }
rustc_smir = { path = "../rustc_smir" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
scoped-tls = "1.0"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
//!
//! This module is responsible for constructing stable components.
//! All operations requiring rustc queries must be delegated
//! to `rustc_smir::alloc` to maintain stability guarantees.
//! to `rustc_public_shim::alloc` to maintain stability guarantees.

use rustc_abi::Align;
use rustc_middle::mir::ConstValue;
use rustc_middle::mir::interpret::AllocRange;
use rustc_smir::bridge::SmirError;
use rustc_smir::context::SmirCtxt;
use rustc_smir::{Tables, alloc};
use rustc_public_shim::bridge::SmirError;
use rustc_public_shim::context::SmirCtxt;
use rustc_public_shim::{Tables, alloc};

use super::Error;
use super::compiler_interface::BridgeTys;
Expand Down Expand Up @@ -59,7 +59,7 @@ pub(crate) fn try_new_allocation<'tcx>(
}
ConstValue::Indirect { alloc_id, offset } => {
let alloc = alloc::try_new_indirect(alloc_id, cx);
use rustc_smir::context::SmirAllocRange;
use rustc_public_shim::context::SmirAllocRange;
Ok(allocation_filter(&alloc.0, cx.alloc_range(offset, layout.size), tables, cx))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use std::cell::Cell;

use rustc_hir::def::DefKind;
use rustc_smir::context::SmirCtxt;
use rustc_smir::{Bridge, SmirContainer};
use rustc_public_shim::context::SmirCtxt;
use rustc_public_shim::{Bridge, SmirContainer};
use tracing::debug;

use crate::abi::{FnAbi, Layout, LayoutShape, ReprOptions};
Expand Down Expand Up @@ -68,7 +68,7 @@ impl Bridge for BridgeTys {

/// Stable public API for querying compiler information.
///
/// All queries are delegated to [`rustc_smir::context::SmirCtxt`] that provides
/// All queries are delegated to [`rustc_public_shim::context::SmirCtxt`] that provides
/// similar APIs but based on internal rustc constructs.
///
/// Do not use this directly. This is currently used in the macro expansion.
Expand Down Expand Up @@ -567,7 +567,7 @@ impl<'tcx> SmirInterface for SmirContainer<'tcx, BridgeTys> {
DefKind::Fn => ForeignItemKind::Fn(tables.fn_def(def_id)),
DefKind::Static { .. } => ForeignItemKind::Static(tables.static_def(def_id)),
DefKind::ForeignTy => {
use rustc_smir::context::SmirTy;
use rustc_public_shim::context::SmirTy;
ForeignItemKind::Type(tables.intern_ty(cx.new_foreign(def_id)))
}
def_kind => unreachable!("Unexpected kind for a foreign item: {:?}", def_kind),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use std::fmt::{Debug, Display, Formatter};
use std::{fmt, io};

use rustc_smir::bridge::SmirError;
use rustc_public_shim::bridge::SmirError;

macro_rules! error {
($fmt: literal $(,)?) => { Error(format!($fmt)) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
use std::fmt::Debug;
use std::{fmt, io};

pub(crate) use rustc_smir::IndexedVal;
use rustc_smir::Tables;
use rustc_smir::context::SmirCtxt;
pub(crate) use rustc_public_shim::IndexedVal;
use rustc_public_shim::Tables;
use rustc_public_shim::context::SmirCtxt;
/// Export the rustc_internal APIs. Note that this module has no stability
/// guarantees and it is not taken into account for semver.
#[cfg(feature = "rustc_internal")]
Expand Down Expand Up @@ -244,7 +244,7 @@ pub fn opaque<T: Debug>(value: &T) -> Opaque {

macro_rules! bridge_impl {
($name: ident, $ty: ty) => {
impl rustc_smir::bridge::$name<compiler_interface::BridgeTys> for $ty {
impl rustc_public_shim::bridge::$name<compiler_interface::BridgeTys> for $ty {
fn new(def: crate::DefId) -> Self {
Self(def)
}
Expand Down Expand Up @@ -273,13 +273,15 @@ bridge_impl!(AssocDef, crate::ty::AssocDef);
bridge_impl!(OpaqueDef, crate::ty::OpaqueDef);
bridge_impl!(StaticDef, crate::mir::mono::StaticDef);

impl rustc_smir::bridge::Prov<compiler_interface::BridgeTys> for crate::ty::Prov {
impl rustc_public_shim::bridge::Prov<compiler_interface::BridgeTys> for crate::ty::Prov {
fn new(aid: crate::mir::alloc::AllocId) -> Self {
Self(aid)
}
}

impl rustc_smir::bridge::Allocation<compiler_interface::BridgeTys> for crate::ty::Allocation {
impl rustc_public_shim::bridge::Allocation<compiler_interface::BridgeTys>
for crate::ty::Allocation
{
fn new<'tcx>(
bytes: Vec<Option<u8>>,
ptrs: Vec<(usize, rustc_middle::mir::interpret::AllocId)>,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ pub enum AggregateKind {
Tuple,
Adt(AdtDef, VariantIdx, GenericArgs, Option<UserTypeAnnotationIndex>, Option<FieldIdx>),
Closure(ClosureDef, GenericArgs),
// FIXME(stable_mir): Movability here is redundant
// FIXME(rustc_public): Movability here is redundant
Coroutine(CoroutineDef, GenericArgs, Movability),
CoroutineClosure(CoroutineClosureDef, GenericArgs),
RawPtr(Ty, Mutability),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::{Debug, Formatter};
use std::io;

use rustc_smir::bridge::SmirError;
use rustc_public_shim::bridge::SmirError;
use serde::Serialize;

use crate::abi::FnAbi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use std::cell::{Cell, RefCell};

use rustc_middle::ty::TyCtxt;
use rustc_smir::context::SmirCtxt;
use rustc_smir::{Bridge, SmirContainer, Tables};
use rustc_public_shim::context::SmirCtxt;
use rustc_public_shim::{Bridge, SmirContainer, Tables};
use rustc_span::def_id::CrateNum;
use scoped_tls::scoped_thread_local;

Expand Down Expand Up @@ -105,11 +105,11 @@ where
/// # extern crate rustc_interface;
/// # extern crate rustc_middle;
/// # #[macro_use]
/// # extern crate stable_mir;
/// # extern crate rustc_public;
/// #
/// # fn main() {
/// # use std::ops::ControlFlow;
/// # use stable_mir::CompilerError;
/// # use rustc_public::CompilerError;
/// fn analyze_code() -> ControlFlow<(), ()> {
/// // Your code goes in here.
/// # ControlFlow::Continue(())
Expand All @@ -125,11 +125,11 @@ where
/// # extern crate rustc_interface;
/// # extern crate rustc_middle;
/// # #[macro_use]
/// # extern crate stable_mir;
/// # extern crate rustc_public;
/// #
/// # fn main() {
/// # use std::ops::ControlFlow;
/// # use stable_mir::CompilerError;
/// # use rustc_public::CompilerError;
/// fn analyze_code(extra_args: Vec<String>) -> ControlFlow<(), ()> {
/// # let _ = extra_args;
/// // Your code goes in here.
Expand Down Expand Up @@ -187,8 +187,8 @@ macro_rules! run_driver {
use rustc_driver::{Callbacks, Compilation, run_compiler};
use rustc_middle::ty::TyCtxt;
use rustc_interface::interface;
use stable_mir::rustc_internal;
use stable_mir::CompilerError;
use rustc_public::rustc_internal;
use rustc_public::CompilerError;
use std::ops::ControlFlow;

pub struct StableMir<B = (), C = (), F = fn($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C>>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ pub enum RigidTy {
FnDef(FnDef, GenericArgs),
FnPtr(PolyFnSig),
Closure(ClosureDef, GenericArgs),
// FIXME(stable_mir): Movability here is redundant
// FIXME(rustc_public): Movability here is redundant
Coroutine(CoroutineDef, GenericArgs, Movability),
CoroutineClosure(CoroutineClosureDef, GenericArgs),
Dynamic(Vec<Binder<ExistentialPredicate>>, Region, DynKind),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
//! This module will only include a few constructs to allow users to invoke internal rustc APIs
//! due to incomplete stable coverage.

// Prefer importing stable_mir over internal rustc constructs to make this file more readable.
// Prefer importing rustc_public over internal rustc constructs to make this file more readable.

use rustc_middle::ty::{self as rustc_ty, Const as InternalConst, Ty as InternalTy};
use rustc_smir::Tables;
use rustc_public_shim::Tables;

use crate::abi::Layout;
use crate::compiler_interface::BridgeTys;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//! This module holds the logic to convert rustc internal ADTs into stable mir ADTs.
//!
//! The conversion from stable to internal is not meant to be complete,
//! and it should be added as when needed to be passed as input to rustc_smir functions.
//! and it should be added as when needed to be passed as input to rustc_public_shim functions.
//!
//! For contributors, please make sure to avoid calling rustc's internal functions and queries.
//! These should be done via `rustc_smir` APIs, but it's possible to access ADT fields directly.
//! These should be done via `rustc_public_shim` APIs, but it's possible to access ADT fields directly.

use std::ops::RangeInclusive;

use rustc_smir::Tables;
use rustc_smir::context::SmirCtxt;
use rustc_public_shim::Tables;
use rustc_public_shim::context::SmirCtxt;

use super::Stable;
use crate::compiler_interface::BridgeTys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use rustc_abi::{ArmCall, CanonAbi, InterruptKind, X86Call};
use rustc_middle::ty;
use rustc_smir::Tables;
use rustc_smir::context::SmirCtxt;
use rustc_public_shim::Tables;
use rustc_public_shim::context::SmirCtxt;
use rustc_target::callconv;

use crate::abi::{
Expand Down
Loading