From 966fc577894c283a1285c8554c10fc56ba67e58c Mon Sep 17 00:00:00 2001 From: Makai Date: Tue, 15 Jul 2025 13:13:03 +0000 Subject: [PATCH 01/10] `SmirCtxt` to `CompilerCtxt`, `SmirInterface` to `CompilerInterface` aaa --- compiler/rustc_public/src/alloc.rs | 8 +- .../rustc_public/src/compiler_interface.rs | 22 ++-- compiler/rustc_public/src/lib.rs | 4 +- .../rustc_public/src/rustc_internal/mod.rs | 8 +- .../rustc_public/src/unstable/convert/mod.rs | 14 +- .../src/unstable/convert/stable/abi.rs | 50 ++++---- .../src/unstable/convert/stable/mir.rs | 80 ++++++------ .../src/unstable/convert/stable/mod.rs | 14 +- .../src/unstable/convert/stable/ty.rs | 120 +++++++++--------- compiler/rustc_public/src/unstable/mod.rs | 6 +- compiler/rustc_public_bridge/src/alloc.rs | 12 +- compiler/rustc_public_bridge/src/bridge.rs | 4 +- .../rustc_public_bridge/src/context/impls.rs | 10 +- .../rustc_public_bridge/src/context/mod.rs | 16 +-- compiler/rustc_public_bridge/src/lib.rs | 4 +- 15 files changed, 186 insertions(+), 186 deletions(-) diff --git a/compiler/rustc_public/src/alloc.rs b/compiler/rustc_public/src/alloc.rs index d2db6c08bbc0d..f2cb8a900a655 100644 --- a/compiler/rustc_public/src/alloc.rs +++ b/compiler/rustc_public/src/alloc.rs @@ -8,7 +8,7 @@ use rustc_abi::Align; use rustc_middle::mir::ConstValue; use rustc_middle::mir::interpret::AllocRange; use rustc_public_bridge::bridge::SmirError; -use rustc_public_bridge::context::SmirCtxt; +use rustc_public_bridge::context::CompilerCtxt; use rustc_public_bridge::{Tables, alloc}; use super::Error; @@ -35,7 +35,7 @@ pub(crate) fn new_allocation<'tcx>( ty: rustc_middle::ty::Ty<'tcx>, const_value: ConstValue<'tcx>, tables: &mut Tables<'tcx, BridgeTys>, - cx: &SmirCtxt<'tcx, BridgeTys>, + cx: &CompilerCtxt<'tcx, BridgeTys>, ) -> Allocation { try_new_allocation(ty, const_value, tables, cx) .unwrap_or_else(|_| panic!("Failed to convert: {const_value:?} to {ty:?}")) @@ -46,7 +46,7 @@ pub(crate) fn try_new_allocation<'tcx>( ty: rustc_middle::ty::Ty<'tcx>, const_value: ConstValue<'tcx>, tables: &mut Tables<'tcx, BridgeTys>, - cx: &SmirCtxt<'tcx, BridgeTys>, + cx: &CompilerCtxt<'tcx, BridgeTys>, ) -> Result { let layout = alloc::create_ty_and_layout(cx, ty).map_err(|e| Error::from_internal(e))?; match const_value { @@ -70,7 +70,7 @@ pub(super) fn allocation_filter<'tcx>( alloc: &rustc_middle::mir::interpret::Allocation, alloc_range: AllocRange, tables: &mut Tables<'tcx, BridgeTys>, - cx: &SmirCtxt<'tcx, BridgeTys>, + cx: &CompilerCtxt<'tcx, BridgeTys>, ) -> Allocation { alloc::allocation_filter(alloc, alloc_range, tables, cx) } diff --git a/compiler/rustc_public/src/compiler_interface.rs b/compiler/rustc_public/src/compiler_interface.rs index d15438c2b800e..84c0ea973b7d0 100644 --- a/compiler/rustc_public/src/compiler_interface.rs +++ b/compiler/rustc_public/src/compiler_interface.rs @@ -6,7 +6,7 @@ use std::cell::Cell; use rustc_hir::def::DefKind; -use rustc_public_bridge::context::SmirCtxt; +use rustc_public_bridge::context::CompilerCtxt; use rustc_public_bridge::{Bridge, SmirContainer}; use tracing::debug; @@ -66,13 +66,13 @@ impl Bridge for BridgeTys { type Allocation = crate::ty::Allocation; } -/// Stable public API for querying compiler information. +/// Public API for querying compiler information. /// -/// All queries are delegated to [`rustc_public_bridge::context::SmirCtxt`] that provides +/// All queries are delegated to [`rustc_public_bridge::context::CompilerCtxt`] that provides /// similar APIs but based on internal rustc constructs. /// /// Do not use this directly. This is currently used in the macro expansion. -pub(crate) trait SmirInterface { +pub(crate) trait CompilerInterface { fn entry_fn(&self) -> Option; /// Retrieve all items of the local crate that have a MIR associated with them. fn all_local_items(&self) -> CrateItems; @@ -316,7 +316,7 @@ pub(crate) trait SmirInterface { fn associated_items(&self, def_id: DefId) -> AssocItems; } -impl<'tcx> SmirInterface for SmirContainer<'tcx, BridgeTys> { +impl<'tcx> CompilerInterface for SmirContainer<'tcx, BridgeTys> { fn entry_fn(&self) -> Option { let mut tables = self.tables.borrow_mut(); let cx = &*self.cx.borrow(); @@ -1059,10 +1059,10 @@ impl<'tcx> SmirInterface for SmirContainer<'tcx, BridgeTys> { } } -// A thread local variable that stores a pointer to [`SmirInterface`]. +// A thread local variable that stores a pointer to [`CompilerInterface`]. scoped_tls::scoped_thread_local!(static TLV: Cell<*const ()>); -pub(crate) fn run(interface: &dyn SmirInterface, f: F) -> Result +pub(crate) fn run(interface: &dyn CompilerInterface, f: F) -> Result where F: FnOnce() -> T, { @@ -1074,21 +1074,21 @@ where } } -/// Execute the given function with access the [`SmirInterface`]. +/// Execute the given function with access the [`CompilerInterface`]. /// /// I.e., This function will load the current interface and calls a function with it. /// Do not nest these, as that will ICE. -pub(crate) fn with(f: impl FnOnce(&dyn SmirInterface) -> R) -> R { +pub(crate) fn with(f: impl FnOnce(&dyn CompilerInterface) -> R) -> R { assert!(TLV.is_set()); TLV.with(|tlv| { let ptr = tlv.get(); assert!(!ptr.is_null()); - f(unsafe { *(ptr as *const &dyn SmirInterface) }) + f(unsafe { *(ptr as *const &dyn CompilerInterface) }) }) } fn smir_crate<'tcx>( - cx: &SmirCtxt<'tcx, BridgeTys>, + cx: &CompilerCtxt<'tcx, BridgeTys>, crate_num: rustc_span::def_id::CrateNum, ) -> Crate { let name = cx.crate_name(crate_num); diff --git a/compiler/rustc_public/src/lib.rs b/compiler/rustc_public/src/lib.rs index e320c4eca71cb..958b3b2647889 100644 --- a/compiler/rustc_public/src/lib.rs +++ b/compiler/rustc_public/src/lib.rs @@ -24,7 +24,7 @@ use std::{fmt, io}; pub(crate) use rustc_public_bridge::IndexedVal; use rustc_public_bridge::Tables; -use rustc_public_bridge::context::SmirCtxt; +use rustc_public_bridge::context::CompilerCtxt; /// 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")] @@ -288,7 +288,7 @@ impl rustc_public_bridge::bridge::Allocation align: u64, mutability: rustc_middle::mir::Mutability, tables: &mut Tables<'tcx, compiler_interface::BridgeTys>, - cx: &SmirCtxt<'tcx, compiler_interface::BridgeTys>, + cx: &CompilerCtxt<'tcx, compiler_interface::BridgeTys>, ) -> Self { Self { bytes, diff --git a/compiler/rustc_public/src/rustc_internal/mod.rs b/compiler/rustc_public/src/rustc_internal/mod.rs index 01354fc7bd422..0e1c857e8b13d 100644 --- a/compiler/rustc_public/src/rustc_internal/mod.rs +++ b/compiler/rustc_public/src/rustc_internal/mod.rs @@ -6,7 +6,7 @@ use std::cell::{Cell, RefCell}; use rustc_middle::ty::TyCtxt; -use rustc_public_bridge::context::SmirCtxt; +use rustc_public_bridge::context::CompilerCtxt; use rustc_public_bridge::{Bridge, SmirContainer, Tables}; use rustc_span::def_id::CrateNum; use scoped_tls::scoped_thread_local; @@ -72,7 +72,7 @@ where /// Loads the current context and calls a function with it. /// Do not nest these, as that will ICE. pub(crate) fn with_container( - f: impl for<'tcx> FnOnce(&mut Tables<'tcx, B>, &SmirCtxt<'tcx, B>) -> R, + f: impl for<'tcx> FnOnce(&mut Tables<'tcx, B>, &CompilerCtxt<'tcx, B>) -> R, ) -> R { assert!(TLV.is_set()); TLV.with(|tlv| { @@ -89,8 +89,8 @@ pub fn run(tcx: TyCtxt<'_>, f: F) -> Result where F: FnOnce() -> T, { - let smir_cx = RefCell::new(SmirCtxt::new(tcx)); - let container = SmirContainer { tables: RefCell::new(Tables::default()), cx: smir_cx }; + let compiler_cx = RefCell::new(CompilerCtxt::new(tcx)); + let container = SmirContainer { tables: RefCell::new(Tables::default()), cx: compiler_cx }; crate::compiler_interface::run(&container, || init(&container, f)) } diff --git a/compiler/rustc_public/src/unstable/convert/mod.rs b/compiler/rustc_public/src/unstable/convert/mod.rs index 85a71e09c3e72..a2e83c6e23944 100644 --- a/compiler/rustc_public/src/unstable/convert/mod.rs +++ b/compiler/rustc_public/src/unstable/convert/mod.rs @@ -9,7 +9,7 @@ use std::ops::RangeInclusive; use rustc_public_bridge::Tables; -use rustc_public_bridge::context::SmirCtxt; +use rustc_public_bridge::context::CompilerCtxt; use super::Stable; use crate::compiler_interface::BridgeTys; @@ -26,7 +26,7 @@ where fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { (*self).stable(tables, cx) } @@ -41,7 +41,7 @@ where fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { self.as_ref().map(|value| value.stable(tables, cx)) } @@ -57,7 +57,7 @@ where fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { Ok(val) => Ok(val.stable(tables, cx)), @@ -74,7 +74,7 @@ where fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { self.iter().map(|e| e.stable(tables, cx)).collect() } @@ -89,7 +89,7 @@ where fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { (self.0.stable(tables, cx), self.1.stable(tables, cx)) } @@ -103,7 +103,7 @@ where fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { RangeInclusive::new(self.start().stable(tables, cx), self.end().stable(tables, cx)) } diff --git a/compiler/rustc_public/src/unstable/convert/stable/abi.rs b/compiler/rustc_public/src/unstable/convert/stable/abi.rs index 40a8bf614e1ff..782e75a930e07 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/abi.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/abi.rs @@ -5,7 +5,7 @@ use rustc_abi::{ArmCall, CanonAbi, InterruptKind, X86Call}; use rustc_middle::ty; use rustc_public_bridge::Tables; -use rustc_public_bridge::context::SmirCtxt; +use rustc_public_bridge::context::CompilerCtxt; use rustc_target::callconv; use crate::abi::{ @@ -21,7 +21,7 @@ use crate::{IndexedVal, opaque}; impl<'tcx> Stable<'tcx> for rustc_abi::VariantIdx { type T = VariantIdx; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { VariantIdx::to_val(self.as_usize()) } } @@ -29,7 +29,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::VariantIdx { impl<'tcx> Stable<'tcx> for rustc_abi::Endian { type T = crate::target::Endian; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { rustc_abi::Endian::Little => crate::target::Endian::Little, rustc_abi::Endian::Big => crate::target::Endian::Big, @@ -43,7 +43,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::TyAndLayout<'tcx, ty::Ty<'tcx>> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { TyAndLayout { ty: self.ty.stable(tables, cx), layout: self.layout.stable(tables, cx) } } @@ -55,7 +55,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Layout<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { tables.layout_id(cx.lift(*self).unwrap()) } @@ -67,7 +67,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::LayoutData( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { LayoutShape { fields: self.fields.stable(tables, cx), @@ -85,7 +85,7 @@ impl<'tcx> Stable<'tcx> for callconv::FnAbi<'tcx, ty::Ty<'tcx>> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { assert!(self.args.len() >= self.fixed_count as usize); assert!(!self.c_variadic || matches!(self.conv, CanonAbi::C)); @@ -105,7 +105,7 @@ impl<'tcx> Stable<'tcx> for callconv::ArgAbi<'tcx, ty::Ty<'tcx>> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { ArgAbi { ty: self.layout.ty.stable(tables, cx), @@ -118,7 +118,7 @@ impl<'tcx> Stable<'tcx> for callconv::ArgAbi<'tcx, ty::Ty<'tcx>> { impl<'tcx> Stable<'tcx> for CanonAbi { type T = CallConvention; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { CanonAbi::C => CallConvention::C, CanonAbi::Rust => CallConvention::Rust, @@ -154,7 +154,7 @@ impl<'tcx> Stable<'tcx> for CanonAbi { impl<'tcx> Stable<'tcx> for callconv::PassMode { type T = PassMode; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { callconv::PassMode::Ignore => PassMode::Ignore, callconv::PassMode::Direct(attr) => PassMode::Direct(opaque(attr)), @@ -179,7 +179,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::FieldsShape { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { rustc_abi::FieldsShape::Primitive => FieldsShape::Primitive, @@ -200,7 +200,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Variants( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { rustc_abi::Variants::Single { index } => { @@ -225,7 +225,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::TagEncoding { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { rustc_abi::TagEncoding::Direct => TagEncoding::Direct, @@ -246,7 +246,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::BackendRepr { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match *self { rustc_abi::BackendRepr::Scalar(scalar) => ValueAbi::Scalar(scalar.stable(tables, cx)), @@ -264,7 +264,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::BackendRepr { impl<'tcx> Stable<'tcx> for rustc_abi::Size { type T = Size; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { Size::from_bits(self.bits_usize()) } } @@ -272,7 +272,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Size { impl<'tcx> Stable<'tcx> for rustc_abi::Align { type T = Align; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { self.bytes() } } @@ -283,7 +283,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Scalar { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { rustc_abi::Scalar::Initialized { value, valid_range } => Scalar::Initialized { @@ -301,7 +301,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Primitive { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { rustc_abi::Primitive::Int(length, signed) => { @@ -318,7 +318,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Primitive { impl<'tcx> Stable<'tcx> for rustc_abi::AddressSpace { type T = AddressSpace; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { AddressSpace(self.0) } } @@ -326,7 +326,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::AddressSpace { impl<'tcx> Stable<'tcx> for rustc_abi::Integer { type T = IntegerLength; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { rustc_abi::Integer::I8 => IntegerLength::I8, rustc_abi::Integer::I16 => IntegerLength::I16, @@ -340,7 +340,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Integer { impl<'tcx> Stable<'tcx> for rustc_abi::Float { type T = FloatLength; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { rustc_abi::Float::F16 => FloatLength::F16, rustc_abi::Float::F32 => FloatLength::F32, @@ -353,7 +353,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Float { impl<'tcx> Stable<'tcx> for rustc_abi::WrappingRange { type T = WrappingRange; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { WrappingRange { start: self.start, end: self.end } } } @@ -364,7 +364,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::ReprFlags { fn stable<'cx>( &self, _tables: &mut Tables<'cx, BridgeTys>, - _cx: &SmirCtxt<'cx, BridgeTys>, + _cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { ReprFlags { is_simd: self.intersects(Self::IS_SIMD), @@ -381,7 +381,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::IntegerType { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { rustc_abi::IntegerType::Pointer(signed) => IntegerType::Pointer { is_signed: *signed }, @@ -398,7 +398,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::ReprOptions { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { ReprOptions { int: self.int.map(|int| int.stable(tables, cx)), diff --git a/compiler/rustc_public/src/unstable/convert/stable/mir.rs b/compiler/rustc_public/src/unstable/convert/stable/mir.rs index bd7d48071526b..433e7a20f017d 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/mir.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/mir.rs @@ -4,7 +4,7 @@ use rustc_middle::mir::mono::MonoItem; use rustc_middle::{bug, mir}; use rustc_public_bridge::Tables; use rustc_public_bridge::bridge::SmirError; -use rustc_public_bridge::context::SmirCtxt; +use rustc_public_bridge::context::CompilerCtxt; use crate::compiler_interface::BridgeTys; use crate::mir::alloc::GlobalAlloc; @@ -19,7 +19,7 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { crate::mir::Body::new( self.basic_blocks @@ -54,7 +54,7 @@ impl<'tcx> Stable<'tcx> for mir::VarDebugInfo<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { crate::mir::VarDebugInfo { name: self.name.to_string(), @@ -71,7 +71,7 @@ impl<'tcx> Stable<'tcx> for mir::Statement<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { Statement { kind: self.kind.stable(tables, cx), @@ -85,7 +85,7 @@ impl<'tcx> Stable<'tcx> for mir::SourceInfo { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { crate::mir::SourceInfo { span: self.span.stable(tables, cx), scope: self.scope.into() } } @@ -96,7 +96,7 @@ impl<'tcx> Stable<'tcx> for mir::VarDebugInfoFragment<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { VarDebugInfoFragment { ty: self.ty.stable(tables, cx), @@ -110,7 +110,7 @@ impl<'tcx> Stable<'tcx> for mir::VarDebugInfoContents<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { mir::VarDebugInfoContents::Place(place) => { @@ -133,7 +133,7 @@ impl<'tcx> Stable<'tcx> for mir::StatementKind<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { mir::StatementKind::Assign(assign) => crate::mir::StatementKind::Assign( @@ -195,7 +195,7 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::mir::Rvalue::*; match self { @@ -259,7 +259,7 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> { impl<'tcx> Stable<'tcx> for mir::Mutability { type T = crate::mir::Mutability; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_hir::Mutability::*; match *self { Not => crate::mir::Mutability::Not, @@ -270,7 +270,7 @@ impl<'tcx> Stable<'tcx> for mir::Mutability { impl<'tcx> Stable<'tcx> for mir::RawPtrKind { type T = crate::mir::RawPtrKind; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use mir::RawPtrKind::*; match *self { Const => crate::mir::RawPtrKind::Const, @@ -285,7 +285,7 @@ impl<'tcx> Stable<'tcx> for mir::BorrowKind { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::mir::BorrowKind::*; match *self { @@ -298,7 +298,7 @@ impl<'tcx> Stable<'tcx> for mir::BorrowKind { impl<'tcx> Stable<'tcx> for mir::MutBorrowKind { type T = crate::mir::MutBorrowKind; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_middle::mir::MutBorrowKind::*; match *self { Default => crate::mir::MutBorrowKind::Default, @@ -310,7 +310,7 @@ impl<'tcx> Stable<'tcx> for mir::MutBorrowKind { impl<'tcx> Stable<'tcx> for mir::FakeBorrowKind { type T = crate::mir::FakeBorrowKind; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_middle::mir::FakeBorrowKind::*; match *self { Deep => crate::mir::FakeBorrowKind::Deep, @@ -324,7 +324,7 @@ impl<'tcx> Stable<'tcx> for mir::NullOp<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::mir::NullOp::*; match self { @@ -344,7 +344,7 @@ impl<'tcx> Stable<'tcx> for mir::CastKind { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::mir::CastKind::*; match self { @@ -364,7 +364,7 @@ impl<'tcx> Stable<'tcx> for mir::CastKind { impl<'tcx> Stable<'tcx> for mir::FakeReadCause { type T = crate::mir::FakeReadCause; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_middle::mir::FakeReadCause::*; match self { ForMatchGuard => crate::mir::FakeReadCause::ForMatchGuard, @@ -383,7 +383,7 @@ impl<'tcx> Stable<'tcx> for mir::Operand<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::mir::Operand::*; match self { @@ -400,7 +400,7 @@ impl<'tcx> Stable<'tcx> for mir::ConstOperand<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { crate::mir::ConstOperand { span: self.span.stable(tables, cx), @@ -415,7 +415,7 @@ impl<'tcx> Stable<'tcx> for mir::Place<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { crate::mir::Place { local: self.local.as_usize(), @@ -429,7 +429,7 @@ impl<'tcx> Stable<'tcx> for mir::PlaceElem<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::mir::ProjectionElem::*; match self { @@ -464,21 +464,21 @@ impl<'tcx> Stable<'tcx> for mir::PlaceElem<'tcx> { impl<'tcx> Stable<'tcx> for mir::UserTypeProjection { type T = crate::mir::UserTypeProjection; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { UserTypeProjection { base: self.base.as_usize(), projection: opaque(&self.projs) } } } impl<'tcx> Stable<'tcx> for mir::Local { type T = crate::mir::Local; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { self.as_usize() } } impl<'tcx> Stable<'tcx> for mir::RetagKind { type T = crate::mir::RetagKind; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_middle::mir::RetagKind; match self { RetagKind::FnEntry => crate::mir::RetagKind::FnEntry, @@ -491,7 +491,7 @@ impl<'tcx> Stable<'tcx> for mir::RetagKind { impl<'tcx> Stable<'tcx> for mir::UnwindAction { type T = crate::mir::UnwindAction; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_middle::mir::UnwindAction; match self { UnwindAction::Continue => crate::mir::UnwindAction::Continue, @@ -508,7 +508,7 @@ impl<'tcx> Stable<'tcx> for mir::NonDivergingIntrinsic<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::mir::NonDivergingIntrinsic; @@ -533,7 +533,7 @@ impl<'tcx> Stable<'tcx> for mir::AssertMessage<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::mir::AssertKind; match self { @@ -580,7 +580,7 @@ impl<'tcx> Stable<'tcx> for mir::AssertMessage<'tcx> { impl<'tcx> Stable<'tcx> for mir::BinOp { type T = crate::mir::BinOp; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_middle::mir::BinOp; match self { BinOp::Add => crate::mir::BinOp::Add, @@ -615,7 +615,7 @@ impl<'tcx> Stable<'tcx> for mir::BinOp { impl<'tcx> Stable<'tcx> for mir::UnOp { type T = crate::mir::UnOp; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_middle::mir::UnOp; match self { UnOp::Not => crate::mir::UnOp::Not, @@ -630,7 +630,7 @@ impl<'tcx> Stable<'tcx> for mir::AggregateKind<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { mir::AggregateKind::Array(ty) => { @@ -676,7 +676,7 @@ impl<'tcx> Stable<'tcx> for mir::InlineAsmOperand<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::mir::InlineAsmOperand; @@ -703,7 +703,7 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::mir::Terminator; Terminator { @@ -718,7 +718,7 @@ impl<'tcx> Stable<'tcx> for mir::TerminatorKind<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::mir::TerminatorKind; match self { @@ -807,7 +807,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::ConstAllocation<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { self.inner().stable(tables, cx) } @@ -819,7 +819,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::Allocation { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_public_bridge::context::SmirAllocRange; alloc::allocation_filter( @@ -836,7 +836,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::AllocId { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - _: &SmirCtxt<'cx, BridgeTys>, + _: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { tables.create_alloc_id(*self) } @@ -848,7 +848,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::GlobalAlloc<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { mir::interpret::GlobalAlloc::Function { instance, .. } => { @@ -877,7 +877,7 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::Const<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let id = tables.intern_mir_const(cx.lift(*self).unwrap()); match *self { @@ -913,7 +913,7 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::Const<'tcx> { impl<'tcx> Stable<'tcx> for mir::interpret::ErrorHandled { type T = Error; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { Error::new(format!("{self:?}")) } } @@ -924,7 +924,7 @@ impl<'tcx> Stable<'tcx> for MonoItem<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::mir::mono::MonoItem as StableMonoItem; match self { diff --git a/compiler/rustc_public/src/unstable/convert/stable/mod.rs b/compiler/rustc_public/src/unstable/convert/stable/mod.rs index ea78ca50eb3e3..add52fc18caaa 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/mod.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/mod.rs @@ -2,7 +2,7 @@ use rustc_abi::FieldIdx; use rustc_public_bridge::Tables; -use rustc_public_bridge::context::SmirCtxt; +use rustc_public_bridge::context::CompilerCtxt; use super::Stable; use crate::compiler_interface::BridgeTys; @@ -13,7 +13,7 @@ mod ty; impl<'tcx> Stable<'tcx> for rustc_hir::Safety { type T = crate::mir::Safety; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { rustc_hir::Safety::Unsafe => crate::mir::Safety::Unsafe, rustc_hir::Safety::Safe => crate::mir::Safety::Safe, @@ -23,14 +23,14 @@ impl<'tcx> Stable<'tcx> for rustc_hir::Safety { impl<'tcx> Stable<'tcx> for FieldIdx { type T = usize; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { self.as_usize() } } impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineSource { type T = crate::mir::CoroutineSource; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_hir::CoroutineSource; match self { CoroutineSource::Block => crate::mir::CoroutineSource::Block, @@ -45,7 +45,7 @@ impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineKind { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_hir::{CoroutineDesugaring, CoroutineKind}; match *self { @@ -77,7 +77,7 @@ impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineKind { impl<'tcx> Stable<'tcx> for rustc_span::Symbol { type T = crate::Symbol; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { self.to_string() } } @@ -88,7 +88,7 @@ impl<'tcx> Stable<'tcx> for rustc_span::Span { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - _: &SmirCtxt<'cx, BridgeTys>, + _: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { tables.create_span(*self) } diff --git a/compiler/rustc_public/src/unstable/convert/stable/ty.rs b/compiler/rustc_public/src/unstable/convert/stable/ty.rs index 6b226b8a24d12..d679615b3bdc9 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/ty.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/ty.rs @@ -3,7 +3,7 @@ use rustc_middle::ty::Ty; use rustc_middle::{bug, mir, ty}; use rustc_public_bridge::Tables; -use rustc_public_bridge::context::SmirCtxt; +use rustc_public_bridge::context::CompilerCtxt; use crate::alloc; use crate::compiler_interface::BridgeTys; @@ -14,7 +14,7 @@ use crate::unstable::Stable; impl<'tcx> Stable<'tcx> for ty::AliasTyKind { type T = crate::ty::AliasKind; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { ty::Projection => crate::ty::AliasKind::Projection, ty::Inherent => crate::ty::AliasKind::Inherent, @@ -29,7 +29,7 @@ impl<'tcx> Stable<'tcx> for ty::AliasTy<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let ty::AliasTy { args, def_id, .. } = self; crate::ty::AliasTy { def_id: tables.alias_def(*def_id), args: args.stable(tables, cx) } @@ -41,7 +41,7 @@ impl<'tcx> Stable<'tcx> for ty::AliasTerm<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let ty::AliasTerm { args, def_id, .. } = self; crate::ty::AliasTerm { def_id: tables.alias_def(*def_id), args: args.stable(tables, cx) } @@ -51,7 +51,7 @@ impl<'tcx> Stable<'tcx> for ty::AliasTerm<'tcx> { impl<'tcx> Stable<'tcx> for ty::DynKind { type T = crate::ty::DynKind; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { ty::Dyn => crate::ty::DynKind::Dyn, } @@ -64,7 +64,7 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialPredicate<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::ExistentialPredicate::*; match self { @@ -85,7 +85,7 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialTraitRef<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let ty::ExistentialTraitRef { def_id, args, .. } = self; crate::ty::ExistentialTraitRef { @@ -101,7 +101,7 @@ impl<'tcx> Stable<'tcx> for ty::TermKind<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::TermKind; match self { @@ -120,7 +120,7 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialProjection<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let ty::ExistentialProjection { def_id, args, term, .. } = self; crate::ty::ExistentialProjection { @@ -136,7 +136,7 @@ impl<'tcx> Stable<'tcx> for ty::adjustment::PointerCoercion { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::ty::adjustment::PointerCoercion; match self { @@ -154,7 +154,7 @@ impl<'tcx> Stable<'tcx> for ty::adjustment::PointerCoercion { impl<'tcx> Stable<'tcx> for ty::UserTypeAnnotationIndex { type T = usize; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { self.as_usize() } } @@ -162,7 +162,7 @@ impl<'tcx> Stable<'tcx> for ty::UserTypeAnnotationIndex { impl<'tcx> Stable<'tcx> for ty::AdtKind { type T = AdtKind; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { ty::AdtKind::Struct => AdtKind::Struct, ty::AdtKind::Union => AdtKind::Union, @@ -177,7 +177,7 @@ impl<'tcx> Stable<'tcx> for ty::FieldDef { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { crate::ty::FieldDef { def: tables.create_def_id(self.did), @@ -191,7 +191,7 @@ impl<'tcx> Stable<'tcx> for ty::GenericArgs<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { GenericArgs(self.iter().map(|arg| arg.kind().stable(tables, cx)).collect()) } @@ -203,7 +203,7 @@ impl<'tcx> Stable<'tcx> for ty::GenericArgKind<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::GenericArgKind; match self { @@ -225,7 +225,7 @@ where fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::Binder; @@ -249,7 +249,7 @@ where fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::EarlyBinder; @@ -262,7 +262,7 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::FnSig; @@ -285,7 +285,7 @@ impl<'tcx> Stable<'tcx> for ty::BoundTyKind { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::BoundTyKind; @@ -304,7 +304,7 @@ impl<'tcx> Stable<'tcx> for ty::BoundRegionKind { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::BoundRegionKind; @@ -326,7 +326,7 @@ impl<'tcx> Stable<'tcx> for ty::BoundVariableKind { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::BoundVariableKind; @@ -345,7 +345,7 @@ impl<'tcx> Stable<'tcx> for ty::BoundVariableKind { impl<'tcx> Stable<'tcx> for ty::IntTy { type T = IntTy; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { ty::IntTy::Isize => IntTy::Isize, ty::IntTy::I8 => IntTy::I8, @@ -360,7 +360,7 @@ impl<'tcx> Stable<'tcx> for ty::IntTy { impl<'tcx> Stable<'tcx> for ty::UintTy { type T = UintTy; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { ty::UintTy::Usize => UintTy::Usize, ty::UintTy::U8 => UintTy::U8, @@ -375,7 +375,7 @@ impl<'tcx> Stable<'tcx> for ty::UintTy { impl<'tcx> Stable<'tcx> for ty::FloatTy { type T = FloatTy; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { ty::FloatTy::F16 => FloatTy::F16, ty::FloatTy::F32 => FloatTy::F32, @@ -390,7 +390,7 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { tables.intern_ty(cx.lift(*self).unwrap()) } @@ -401,7 +401,7 @@ impl<'tcx> Stable<'tcx> for ty::TyKind<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match self { ty::Bool => TyKind::RigidTy(RigidTy::Bool), @@ -487,7 +487,7 @@ impl<'tcx> Stable<'tcx> for ty::Pattern<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { match **self { ty::PatternKind::Range { start, end } => crate::ty::Pattern::Range { @@ -507,7 +507,7 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let ct = cx.lift(*self).unwrap(); let kind = match ct.kind() { @@ -540,7 +540,7 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> { impl<'tcx> Stable<'tcx> for ty::ParamConst { type T = crate::ty::ParamConst; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use crate::ty::ParamConst; ParamConst { index: self.index, name: self.name.to_string() } } @@ -548,7 +548,7 @@ impl<'tcx> Stable<'tcx> for ty::ParamConst { impl<'tcx> Stable<'tcx> for ty::ParamTy { type T = crate::ty::ParamTy; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use crate::ty::ParamTy; ParamTy { index: self.index, name: self.name.to_string() } } @@ -559,7 +559,7 @@ impl<'tcx> Stable<'tcx> for ty::BoundTy { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::BoundTy; BoundTy { var: self.var.as_usize(), kind: self.kind.stable(tables, cx) } @@ -568,7 +568,7 @@ impl<'tcx> Stable<'tcx> for ty::BoundTy { impl<'tcx> Stable<'tcx> for ty::trait_def::TraitSpecializationKind { type T = crate::ty::TraitSpecializationKind; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use crate::ty::TraitSpecializationKind; match self { @@ -586,7 +586,7 @@ impl<'tcx> Stable<'tcx> for ty::TraitDef { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::opaque; use crate::ty::TraitDecl; @@ -616,7 +616,7 @@ impl<'tcx> Stable<'tcx> for ty::TraitRef<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::TraitRef; @@ -630,7 +630,7 @@ impl<'tcx> Stable<'tcx> for ty::Generics { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::Generics; @@ -655,7 +655,7 @@ impl<'tcx> Stable<'tcx> for ty::Generics { impl<'tcx> Stable<'tcx> for rustc_middle::ty::GenericParamDefKind { type T = crate::ty::GenericParamDefKind; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use crate::ty::GenericParamDefKind; match self { ty::GenericParamDefKind::Lifetime => GenericParamDefKind::Lifetime, @@ -675,7 +675,7 @@ impl<'tcx> Stable<'tcx> for rustc_middle::ty::GenericParamDef { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { GenericParamDef { name: self.name.to_string(), @@ -693,7 +693,7 @@ impl<'tcx> Stable<'tcx> for ty::PredicateKind<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::ty::PredicateKind; match self { @@ -731,7 +731,7 @@ impl<'tcx> Stable<'tcx> for ty::ClauseKind<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use rustc_middle::ty::ClauseKind; match *self { @@ -774,7 +774,7 @@ impl<'tcx> Stable<'tcx> for ty::ClauseKind<'tcx> { impl<'tcx> Stable<'tcx> for ty::ClosureKind { type T = crate::ty::ClosureKind; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_middle::ty::ClosureKind::*; match self { Fn => crate::ty::ClosureKind::Fn, @@ -790,7 +790,7 @@ impl<'tcx> Stable<'tcx> for ty::SubtypePredicate<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let ty::SubtypePredicate { a, b, a_is_expected: _ } = self; crate::ty::SubtypePredicate { a: a.stable(tables, cx), b: b.stable(tables, cx) } @@ -803,7 +803,7 @@ impl<'tcx> Stable<'tcx> for ty::CoercePredicate<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let ty::CoercePredicate { a, b } = self; crate::ty::CoercePredicate { a: a.stable(tables, cx), b: b.stable(tables, cx) } @@ -813,7 +813,7 @@ impl<'tcx> Stable<'tcx> for ty::CoercePredicate<'tcx> { impl<'tcx> Stable<'tcx> for ty::AliasRelationDirection { type T = crate::ty::AliasRelationDirection; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_middle::ty::AliasRelationDirection::*; match self { Equate => crate::ty::AliasRelationDirection::Equate, @@ -828,7 +828,7 @@ impl<'tcx> Stable<'tcx> for ty::TraitPredicate<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let ty::TraitPredicate { trait_ref, polarity } = self; crate::ty::TraitPredicate { @@ -847,7 +847,7 @@ where fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let ty::OutlivesPredicate(a, b) = self; crate::ty::OutlivesPredicate(a.stable(tables, cx), b.stable(tables, cx)) @@ -860,7 +860,7 @@ impl<'tcx> Stable<'tcx> for ty::ProjectionPredicate<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let ty::ProjectionPredicate { projection_term, term } = self; crate::ty::ProjectionPredicate { @@ -873,7 +873,7 @@ impl<'tcx> Stable<'tcx> for ty::ProjectionPredicate<'tcx> { impl<'tcx> Stable<'tcx> for ty::ImplPolarity { type T = crate::ty::ImplPolarity; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_middle::ty::ImplPolarity::*; match self { Positive => crate::ty::ImplPolarity::Positive, @@ -886,7 +886,7 @@ impl<'tcx> Stable<'tcx> for ty::ImplPolarity { impl<'tcx> Stable<'tcx> for ty::PredicatePolarity { type T = crate::ty::PredicatePolarity; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_middle::ty::PredicatePolarity::*; match self { Positive => crate::ty::PredicatePolarity::Positive, @@ -901,7 +901,7 @@ impl<'tcx> Stable<'tcx> for ty::Region<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { Region { kind: self.kind().stable(tables, cx) } } @@ -913,7 +913,7 @@ impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::{BoundRegion, EarlyParamRegion, RegionKind}; match self { @@ -948,7 +948,7 @@ impl<'tcx> Stable<'tcx> for ty::Instance<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { let def = tables.instance_def(cx.lift(*self).unwrap()); let kind = match self.def { @@ -976,7 +976,7 @@ impl<'tcx> Stable<'tcx> for ty::Instance<'tcx> { impl<'tcx> Stable<'tcx> for ty::Variance { type T = crate::mir::Variance; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { ty::Bivariant => crate::mir::Variance::Bivariant, ty::Contravariant => crate::mir::Variance::Contravariant, @@ -989,7 +989,7 @@ impl<'tcx> Stable<'tcx> for ty::Variance { impl<'tcx> Stable<'tcx> for ty::Movability { type T = crate::ty::Movability; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { ty::Movability::Static => crate::ty::Movability::Static, ty::Movability::Movable => crate::ty::Movability::Movable, @@ -1000,7 +1000,7 @@ impl<'tcx> Stable<'tcx> for ty::Movability { impl<'tcx> Stable<'tcx> for rustc_abi::ExternAbi { type T = crate::ty::Abi; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use rustc_abi::ExternAbi; use crate::ty::Abi; @@ -1042,7 +1042,7 @@ impl<'tcx> Stable<'tcx> for rustc_session::cstore::ForeignModule { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { crate::ty::ForeignModule { def_id: tables.foreign_module_def(self.def_id), @@ -1057,7 +1057,7 @@ impl<'tcx> Stable<'tcx> for ty::AssocKind { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::{AssocKind, AssocTypeData}; match *self { @@ -1080,7 +1080,7 @@ impl<'tcx> Stable<'tcx> for ty::AssocKind { impl<'tcx> Stable<'tcx> for ty::AssocItemContainer { type T = crate::ty::AssocItemContainer; - fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T { + fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { use crate::ty::AssocItemContainer; match self { ty::AssocItemContainer::Trait => AssocItemContainer::Trait, @@ -1095,7 +1095,7 @@ impl<'tcx> Stable<'tcx> for ty::AssocItem { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { crate::ty::AssocItem { def_id: tables.assoc_def(self.def_id), @@ -1112,7 +1112,7 @@ impl<'tcx> Stable<'tcx> for ty::ImplTraitInTraitData { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - _: &SmirCtxt<'cx, BridgeTys>, + _: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { use crate::ty::ImplTraitInTraitData; match self { @@ -1135,7 +1135,7 @@ impl<'tcx> Stable<'tcx> for rustc_middle::ty::util::Discr<'tcx> { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { crate::ty::Discr { val: self.val, ty: self.ty.stable(tables, cx) } } diff --git a/compiler/rustc_public/src/unstable/mod.rs b/compiler/rustc_public/src/unstable/mod.rs index ce7c41a64fa03..ca154a3378a7f 100644 --- a/compiler/rustc_public/src/unstable/mod.rs +++ b/compiler/rustc_public/src/unstable/mod.rs @@ -10,7 +10,7 @@ use rustc_hir::def::DefKind; use rustc_middle::ty::{List, Ty, TyCtxt}; use rustc_middle::{mir, ty}; use rustc_public_bridge::Tables; -use rustc_public_bridge::context::SmirCtxt; +use rustc_public_bridge::context::CompilerCtxt; use super::compiler_interface::BridgeTys; use crate::{CtorKind, ItemKind}; @@ -21,7 +21,7 @@ mod internal_cx; /// Trait that defines the methods that are fine to call from [`RustcInternal`]. /// /// This trait is only for [`RustcInternal`]. Any other other access to rustc's internals -/// should go through [`rustc_public_bridge::context::SmirCtxt`]. +/// should go through [`rustc_public_bridge::context::CompilerCtxt`]. pub trait InternalCx<'tcx>: Copy + Clone { fn tcx(self) -> TyCtxt<'tcx>; @@ -66,7 +66,7 @@ pub trait Stable<'tcx>: PointeeSized { fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, - cx: &SmirCtxt<'cx, BridgeTys>, + cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T; } diff --git a/compiler/rustc_public_bridge/src/alloc.rs b/compiler/rustc_public_bridge/src/alloc.rs index 23bbaddce06d5..906e4aae9f261 100644 --- a/compiler/rustc_public_bridge/src/alloc.rs +++ b/compiler/rustc_public_bridge/src/alloc.rs @@ -10,12 +10,12 @@ use rustc_middle::mir::interpret::{ }; use rustc_middle::ty::{Ty, layout}; -use super::{SmirCtxt, Tables}; +use super::{CompilerCtxt, Tables}; use crate::bridge::Allocation as _; use crate::{Bridge, SmirError}; pub fn create_ty_and_layout<'tcx, B: Bridge>( - cx: &SmirCtxt<'tcx, B>, + cx: &CompilerCtxt<'tcx, B>, ty: Ty<'tcx>, ) -> Result>, &'tcx layout::LayoutError<'tcx>> { use crate::context::SmirTypingEnv; @@ -25,7 +25,7 @@ pub fn create_ty_and_layout<'tcx, B: Bridge>( pub fn try_new_scalar<'tcx, B: Bridge>( layout: TyAndLayout<'tcx, Ty<'tcx>>, scalar: Scalar, - cx: &SmirCtxt<'tcx, B>, + cx: &CompilerCtxt<'tcx, B>, ) -> Result { let size = scalar.size(); let mut allocation = Allocation::new(size, layout.align.abi, AllocInit::Uninit, ()); @@ -40,7 +40,7 @@ pub fn try_new_slice<'tcx, B: Bridge>( layout: TyAndLayout<'tcx, Ty<'tcx>>, data: ConstAllocation<'tcx>, meta: u64, - cx: &SmirCtxt<'tcx, B>, + cx: &CompilerCtxt<'tcx, B>, ) -> Result { let alloc_id = cx.tcx.reserve_and_set_memory_alloc(data); let ptr = Pointer::new(alloc_id.into(), Size::ZERO); @@ -60,7 +60,7 @@ pub fn try_new_slice<'tcx, B: Bridge>( pub fn try_new_indirect<'tcx, B: Bridge>( alloc_id: AllocId, - cx: &SmirCtxt<'tcx, B>, + cx: &CompilerCtxt<'tcx, B>, ) -> ConstAllocation<'tcx> { let alloc = cx.tcx.global_alloc(alloc_id).unwrap_memory(); @@ -72,7 +72,7 @@ pub fn allocation_filter<'tcx, B: Bridge>( alloc: &rustc_middle::mir::interpret::Allocation, alloc_range: AllocRange, tables: &mut Tables<'tcx, B>, - cx: &SmirCtxt<'tcx, B>, + cx: &CompilerCtxt<'tcx, B>, ) -> B::Allocation { let mut bytes: Vec> = alloc .inspect_with_uninit_and_ptr_outside_interpreter( diff --git a/compiler/rustc_public_bridge/src/bridge.rs b/compiler/rustc_public_bridge/src/bridge.rs index 379a8da5df9d2..675bb2d8bc33a 100644 --- a/compiler/rustc_public_bridge/src/bridge.rs +++ b/compiler/rustc_public_bridge/src/bridge.rs @@ -6,7 +6,7 @@ use std::fmt::Debug; -use super::context::SmirCtxt; +use super::context::CompilerCtxt; use super::{Bridge, Tables}; pub trait SmirError { @@ -25,7 +25,7 @@ pub trait Allocation { align: u64, mutability: rustc_middle::mir::Mutability, tables: &mut Tables<'tcx, B>, - cx: &SmirCtxt<'tcx, B>, + cx: &CompilerCtxt<'tcx, B>, ) -> Self; } diff --git a/compiler/rustc_public_bridge/src/context/impls.rs b/compiler/rustc_public_bridge/src/context/impls.rs index fdefad2821bb2..268aa6927d286 100644 --- a/compiler/rustc_public_bridge/src/context/impls.rs +++ b/compiler/rustc_public_bridge/src/context/impls.rs @@ -24,23 +24,23 @@ use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc_span::{FileNameDisplayPreference, Span, Symbol}; use rustc_target::callconv::FnAbi; -use super::{SmirAllocRange, SmirCtxt, SmirTy, SmirTypingEnv}; +use super::{SmirAllocRange, CompilerCtxt, SmirTy, SmirTypingEnv}; use crate::builder::BodyBuilder; use crate::{Bridge, SmirError, Tables, filter_def_ids}; -impl<'tcx, B: Bridge> SmirTy<'tcx> for SmirCtxt<'tcx, B> { +impl<'tcx, B: Bridge> SmirTy<'tcx> for CompilerCtxt<'tcx, B> { fn new_foreign(&self, def_id: DefId) -> ty::Ty<'tcx> { ty::Ty::new_foreign(self.tcx, def_id) } } -impl<'tcx, B: Bridge> SmirTypingEnv<'tcx> for SmirCtxt<'tcx, B> { +impl<'tcx, B: Bridge> SmirTypingEnv<'tcx> for CompilerCtxt<'tcx, B> { fn fully_monomorphized(&self) -> ty::TypingEnv<'tcx> { ty::TypingEnv::fully_monomorphized() } } -impl<'tcx, B: Bridge> SmirAllocRange<'tcx> for SmirCtxt<'tcx, B> { +impl<'tcx, B: Bridge> SmirAllocRange<'tcx> for CompilerCtxt<'tcx, B> { fn alloc_range( &self, offset: rustc_abi::Size, @@ -50,7 +50,7 @@ impl<'tcx, B: Bridge> SmirAllocRange<'tcx> for SmirCtxt<'tcx, B> { } } -impl<'tcx, B: Bridge> SmirCtxt<'tcx, B> { +impl<'tcx, B: Bridge> CompilerCtxt<'tcx, B> { pub fn lift>>(&self, value: T) -> Option { self.tcx.lift(value) } diff --git a/compiler/rustc_public_bridge/src/context/mod.rs b/compiler/rustc_public_bridge/src/context/mod.rs index da20be2a4b3a6..d2fbf976a24fa 100644 --- a/compiler/rustc_public_bridge/src/context/mod.rs +++ b/compiler/rustc_public_bridge/src/context/mod.rs @@ -18,21 +18,21 @@ pub use traits::*; /// Provides direct access to rustc's internal queries. /// -/// `SmirInterface` must go through +/// `CompilerInterface` must go through /// this context to obtain rustc-level information. -pub struct SmirCtxt<'tcx, B: Bridge> { +pub struct CompilerCtxt<'tcx, B: Bridge> { pub tcx: TyCtxt<'tcx>, _marker: PhantomData, } -impl<'tcx, B: Bridge> SmirCtxt<'tcx, B> { +impl<'tcx, B: Bridge> CompilerCtxt<'tcx, B> { pub fn new(tcx: TyCtxt<'tcx>) -> Self { Self { tcx, _marker: Default::default() } } } /// Implement error handling for extracting function ABI information. -impl<'tcx, B: Bridge> FnAbiOfHelpers<'tcx> for SmirCtxt<'tcx, B> { +impl<'tcx, B: Bridge> FnAbiOfHelpers<'tcx> for CompilerCtxt<'tcx, B> { type FnAbiOfResult = Result<&'tcx rustc_target::callconv::FnAbi<'tcx, Ty<'tcx>>, B::Error>; #[inline] @@ -46,7 +46,7 @@ impl<'tcx, B: Bridge> FnAbiOfHelpers<'tcx> for SmirCtxt<'tcx, B> { } } -impl<'tcx, B: Bridge> LayoutOfHelpers<'tcx> for SmirCtxt<'tcx, B> { +impl<'tcx, B: Bridge> LayoutOfHelpers<'tcx> for CompilerCtxt<'tcx, B> { type LayoutOfResult = Result, B::Error>; #[inline] @@ -60,19 +60,19 @@ impl<'tcx, B: Bridge> LayoutOfHelpers<'tcx> for SmirCtxt<'tcx, B> { } } -impl<'tcx, B: Bridge> HasTypingEnv<'tcx> for SmirCtxt<'tcx, B> { +impl<'tcx, B: Bridge> HasTypingEnv<'tcx> for CompilerCtxt<'tcx, B> { fn typing_env(&self) -> ty::TypingEnv<'tcx> { ty::TypingEnv::fully_monomorphized() } } -impl<'tcx, B: Bridge> HasTyCtxt<'tcx> for SmirCtxt<'tcx, B> { +impl<'tcx, B: Bridge> HasTyCtxt<'tcx> for CompilerCtxt<'tcx, B> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } } -impl<'tcx, B: Bridge> HasDataLayout for SmirCtxt<'tcx, B> { +impl<'tcx, B: Bridge> HasDataLayout for CompilerCtxt<'tcx, B> { fn data_layout(&self) -> &rustc_abi::TargetDataLayout { self.tcx.data_layout() } diff --git a/compiler/rustc_public_bridge/src/lib.rs b/compiler/rustc_public_bridge/src/lib.rs index 652a8093a8791..7f58430ea4977 100644 --- a/compiler/rustc_public_bridge/src/lib.rs +++ b/compiler/rustc_public_bridge/src/lib.rs @@ -29,7 +29,7 @@ use std::hash::Hash; use std::ops::Index; use bridge::*; -use context::SmirCtxt; +use context::CompilerCtxt; use rustc_data_structures::fx::{self, FxIndexMap}; use rustc_middle::mir; use rustc_middle::mir::interpret::AllocId; @@ -48,7 +48,7 @@ pub mod rustc_internal {} /// A container which is used for TLS. pub struct SmirContainer<'tcx, B: Bridge> { pub tables: RefCell>, - pub cx: RefCell>, + pub cx: RefCell>, } pub struct Tables<'tcx, B: Bridge> { From 7f22e88fab428181401b0c9d3aaf972784a65383 Mon Sep 17 00:00:00 2001 From: Makai Date: Tue, 15 Jul 2025 13:21:41 +0000 Subject: [PATCH 02/10] `SmirContainer` to `Container` --- compiler/rustc_public/src/compiler_interface.rs | 4 ++-- compiler/rustc_public/src/rustc_internal/mod.rs | 8 ++++---- compiler/rustc_public_bridge/src/lib.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_public/src/compiler_interface.rs b/compiler/rustc_public/src/compiler_interface.rs index 84c0ea973b7d0..1e7a4223f3f55 100644 --- a/compiler/rustc_public/src/compiler_interface.rs +++ b/compiler/rustc_public/src/compiler_interface.rs @@ -7,7 +7,7 @@ use std::cell::Cell; use rustc_hir::def::DefKind; use rustc_public_bridge::context::CompilerCtxt; -use rustc_public_bridge::{Bridge, SmirContainer}; +use rustc_public_bridge::{Bridge, Container}; use tracing::debug; use crate::abi::{FnAbi, Layout, LayoutShape, ReprOptions}; @@ -316,7 +316,7 @@ pub(crate) trait CompilerInterface { fn associated_items(&self, def_id: DefId) -> AssocItems; } -impl<'tcx> CompilerInterface for SmirContainer<'tcx, BridgeTys> { +impl<'tcx> CompilerInterface for Container<'tcx, BridgeTys> { fn entry_fn(&self) -> Option { let mut tables = self.tables.borrow_mut(); let cx = &*self.cx.borrow(); diff --git a/compiler/rustc_public/src/rustc_internal/mod.rs b/compiler/rustc_public/src/rustc_internal/mod.rs index 0e1c857e8b13d..ca999b62f8074 100644 --- a/compiler/rustc_public/src/rustc_internal/mod.rs +++ b/compiler/rustc_public/src/rustc_internal/mod.rs @@ -7,7 +7,7 @@ use std::cell::{Cell, RefCell}; use rustc_middle::ty::TyCtxt; use rustc_public_bridge::context::CompilerCtxt; -use rustc_public_bridge::{Bridge, SmirContainer, Tables}; +use rustc_public_bridge::{Bridge, Container, Tables}; use rustc_span::def_id::CrateNum; use scoped_tls::scoped_thread_local; @@ -60,7 +60,7 @@ pub fn crate_num(item: &crate::Crate) -> CrateNum { // datastructures and stable MIR datastructures scoped_thread_local! (static TLV: Cell<*const ()>); -pub(crate) fn init<'tcx, F, T, B: Bridge>(container: &SmirContainer<'tcx, B>, f: F) -> T +pub(crate) fn init<'tcx, F, T, B: Bridge>(container: &Container<'tcx, B>, f: F) -> T where F: FnOnce() -> T, { @@ -78,7 +78,7 @@ pub(crate) fn with_container( TLV.with(|tlv| { let ptr = tlv.get(); assert!(!ptr.is_null()); - let container = ptr as *const SmirContainer<'_, B>; + let container = ptr as *const Container<'_, B>; let mut tables = unsafe { (*container).tables.borrow_mut() }; let cx = unsafe { (*container).cx.borrow() }; f(&mut *tables, &*cx) @@ -90,7 +90,7 @@ where F: FnOnce() -> T, { let compiler_cx = RefCell::new(CompilerCtxt::new(tcx)); - let container = SmirContainer { tables: RefCell::new(Tables::default()), cx: compiler_cx }; + let container = Container { tables: RefCell::new(Tables::default()), cx: compiler_cx }; crate::compiler_interface::run(&container, || init(&container, f)) } diff --git a/compiler/rustc_public_bridge/src/lib.rs b/compiler/rustc_public_bridge/src/lib.rs index 7f58430ea4977..2bb259a857c0c 100644 --- a/compiler/rustc_public_bridge/src/lib.rs +++ b/compiler/rustc_public_bridge/src/lib.rs @@ -46,7 +46,7 @@ pub mod context; pub mod rustc_internal {} /// A container which is used for TLS. -pub struct SmirContainer<'tcx, B: Bridge> { +pub struct Container<'tcx, B: Bridge> { pub tables: RefCell>, pub cx: RefCell>, } From ad0de062b50e521bd1ea100921d25021ab90b1e5 Mon Sep 17 00:00:00 2001 From: Makai Date: Tue, 15 Jul 2025 13:51:55 +0000 Subject: [PATCH 03/10] use "helper" as a more descriptive name --- compiler/rustc_public/src/alloc.rs | 2 +- compiler/rustc_public/src/compiler_interface.rs | 2 +- compiler/rustc_public/src/unstable/convert/internal.rs | 6 +++--- .../rustc_public/src/unstable/convert/stable/mir.rs | 2 +- .../src/unstable/internal_cx/{traits.rs => helpers.rs} | 6 +++--- compiler/rustc_public/src/unstable/internal_cx/mod.rs | 10 +++++----- compiler/rustc_public_bridge/src/alloc.rs | 2 +- .../src/context/{traits.rs => helpers.rs} | 8 ++++---- compiler/rustc_public_bridge/src/context/impls.rs | 10 +++++----- compiler/rustc_public_bridge/src/context/mod.rs | 4 ++-- 10 files changed, 26 insertions(+), 26 deletions(-) rename compiler/rustc_public/src/unstable/internal_cx/{traits.rs => helpers.rs} (83%) rename compiler/rustc_public_bridge/src/context/{traits.rs => helpers.rs} (71%) diff --git a/compiler/rustc_public/src/alloc.rs b/compiler/rustc_public/src/alloc.rs index f2cb8a900a655..cb6cc37e82981 100644 --- a/compiler/rustc_public/src/alloc.rs +++ b/compiler/rustc_public/src/alloc.rs @@ -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_public_bridge::context::SmirAllocRange; + use rustc_public_bridge::context::AllocRangeHelpers; Ok(allocation_filter(&alloc.0, cx.alloc_range(offset, layout.size), tables, cx)) } } diff --git a/compiler/rustc_public/src/compiler_interface.rs b/compiler/rustc_public/src/compiler_interface.rs index 1e7a4223f3f55..043064951d5d4 100644 --- a/compiler/rustc_public/src/compiler_interface.rs +++ b/compiler/rustc_public/src/compiler_interface.rs @@ -567,7 +567,7 @@ impl<'tcx> CompilerInterface for Container<'tcx, BridgeTys> { DefKind::Fn => ForeignItemKind::Fn(tables.fn_def(def_id)), DefKind::Static { .. } => ForeignItemKind::Static(tables.static_def(def_id)), DefKind::ForeignTy => { - use rustc_public_bridge::context::SmirTy; + use rustc_public_bridge::context::TyHelpers; ForeignItemKind::Type(tables.intern_ty(cx.new_foreign(def_id))) } def_kind => unreachable!("Unexpected kind for a foreign item: {:?}", def_kind), diff --git a/compiler/rustc_public/src/unstable/convert/internal.rs b/compiler/rustc_public/src/unstable/convert/internal.rs index 8a6238413b08c..0571a03b62bb8 100644 --- a/compiler/rustc_public/src/unstable/convert/internal.rs +++ b/compiler/rustc_public/src/unstable/convert/internal.rs @@ -504,7 +504,7 @@ impl RustcInternal for ExistentialProjection { tables: &mut Tables<'_, BridgeTys>, tcx: impl InternalCx<'tcx>, ) -> Self::T<'tcx> { - use crate::unstable::internal_cx::SmirExistentialProjection; + use crate::unstable::internal_cx::ExistentialProjectionHelpers; tcx.new_from_args( self.def_id.0.internal(tables, tcx), self.generic_args.internal(tables, tcx), @@ -536,7 +536,7 @@ impl RustcInternal for ExistentialTraitRef { tables: &mut Tables<'_, BridgeTys>, tcx: impl InternalCx<'tcx>, ) -> Self::T<'tcx> { - use crate::unstable::internal_cx::SmirExistentialTraitRef; + use crate::unstable::internal_cx::ExistentialTraitRefHelpers; tcx.new_from_args( self.def_id.0.internal(tables, tcx), self.generic_args.internal(tables, tcx), @@ -552,7 +552,7 @@ impl RustcInternal for TraitRef { tables: &mut Tables<'_, BridgeTys>, tcx: impl InternalCx<'tcx>, ) -> Self::T<'tcx> { - use crate::unstable::internal_cx::SmirTraitRef; + use crate::unstable::internal_cx::TraitRefHelpers; tcx.new_from_args(self.def_id.0.internal(tables, tcx), self.args().internal(tables, tcx)) } } diff --git a/compiler/rustc_public/src/unstable/convert/stable/mir.rs b/compiler/rustc_public/src/unstable/convert/stable/mir.rs index 433e7a20f017d..cb68129c6606a 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/mir.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/mir.rs @@ -821,7 +821,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::Allocation { tables: &mut Tables<'cx, BridgeTys>, cx: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { - use rustc_public_bridge::context::SmirAllocRange; + use rustc_public_bridge::context::AllocRangeHelpers; alloc::allocation_filter( self, cx.alloc_range(rustc_abi::Size::ZERO, self.size()), diff --git a/compiler/rustc_public/src/unstable/internal_cx/traits.rs b/compiler/rustc_public/src/unstable/internal_cx/helpers.rs similarity index 83% rename from compiler/rustc_public/src/unstable/internal_cx/traits.rs rename to compiler/rustc_public/src/unstable/internal_cx/helpers.rs index da443cd78f18f..da635c04d7442 100644 --- a/compiler/rustc_public/src/unstable/internal_cx/traits.rs +++ b/compiler/rustc_public/src/unstable/internal_cx/helpers.rs @@ -5,7 +5,7 @@ use rustc_middle::ty; -pub(crate) trait SmirExistentialProjection<'tcx> { +pub(crate) trait ExistentialProjectionHelpers<'tcx> { fn new_from_args( &self, def_id: rustc_span::def_id::DefId, @@ -14,7 +14,7 @@ pub(crate) trait SmirExistentialProjection<'tcx> { ) -> ty::ExistentialProjection<'tcx>; } -pub(crate) trait SmirExistentialTraitRef<'tcx> { +pub(crate) trait ExistentialTraitRefHelpers<'tcx> { fn new_from_args( &self, trait_def_id: rustc_span::def_id::DefId, @@ -22,7 +22,7 @@ pub(crate) trait SmirExistentialTraitRef<'tcx> { ) -> ty::ExistentialTraitRef<'tcx>; } -pub(crate) trait SmirTraitRef<'tcx> { +pub(crate) trait TraitRefHelpers<'tcx> { fn new_from_args( &self, trait_def_id: rustc_span::def_id::DefId, diff --git a/compiler/rustc_public/src/unstable/internal_cx/mod.rs b/compiler/rustc_public/src/unstable/internal_cx/mod.rs index 6b0a06e304cf1..44fbfde877550 100644 --- a/compiler/rustc_public/src/unstable/internal_cx/mod.rs +++ b/compiler/rustc_public/src/unstable/internal_cx/mod.rs @@ -2,13 +2,13 @@ use rustc_middle::ty::{List, Ty, TyCtxt}; use rustc_middle::{mir, ty}; -pub(crate) use traits::*; +pub(crate) use helpers::*; use super::InternalCx; -pub(crate) mod traits; +pub(crate) mod helpers; -impl<'tcx, T: InternalCx<'tcx>> SmirExistentialProjection<'tcx> for T { +impl<'tcx, T: InternalCx<'tcx>> ExistentialProjectionHelpers<'tcx> for T { fn new_from_args( &self, def_id: rustc_span::def_id::DefId, @@ -19,7 +19,7 @@ impl<'tcx, T: InternalCx<'tcx>> SmirExistentialProjection<'tcx> for T { } } -impl<'tcx, T: InternalCx<'tcx>> SmirExistentialTraitRef<'tcx> for T { +impl<'tcx, T: InternalCx<'tcx>> ExistentialTraitRefHelpers<'tcx> for T { fn new_from_args( &self, trait_def_id: rustc_span::def_id::DefId, @@ -29,7 +29,7 @@ impl<'tcx, T: InternalCx<'tcx>> SmirExistentialTraitRef<'tcx> for T { } } -impl<'tcx, T: InternalCx<'tcx>> SmirTraitRef<'tcx> for T { +impl<'tcx, T: InternalCx<'tcx>> TraitRefHelpers<'tcx> for T { fn new_from_args( &self, trait_def_id: rustc_span::def_id::DefId, diff --git a/compiler/rustc_public_bridge/src/alloc.rs b/compiler/rustc_public_bridge/src/alloc.rs index 906e4aae9f261..c866b05e6cf22 100644 --- a/compiler/rustc_public_bridge/src/alloc.rs +++ b/compiler/rustc_public_bridge/src/alloc.rs @@ -18,7 +18,7 @@ pub fn create_ty_and_layout<'tcx, B: Bridge>( cx: &CompilerCtxt<'tcx, B>, ty: Ty<'tcx>, ) -> Result>, &'tcx layout::LayoutError<'tcx>> { - use crate::context::SmirTypingEnv; + use crate::context::TypingEnvHelpers; cx.tcx.layout_of(cx.fully_monomorphized().as_query_input(ty)) } diff --git a/compiler/rustc_public_bridge/src/context/traits.rs b/compiler/rustc_public_bridge/src/context/helpers.rs similarity index 71% rename from compiler/rustc_public_bridge/src/context/traits.rs rename to compiler/rustc_public_bridge/src/context/helpers.rs index 8483bee4aadce..21eef29e5f1cc 100644 --- a/compiler/rustc_public_bridge/src/context/traits.rs +++ b/compiler/rustc_public_bridge/src/context/helpers.rs @@ -1,6 +1,6 @@ //! A set of traits that define a stable interface to rustc's internals. //! -//! These traits abstract rustc's internal APIs, allowing StableMIR to maintain a stable +//! These traits abstract rustc's internal APIs, allowing rustc_public to maintain a stable //! interface regardless of internal compiler changes. use rustc_middle::mir::interpret::AllocRange; @@ -8,14 +8,14 @@ use rustc_middle::ty; use rustc_middle::ty::Ty; use rustc_span::def_id::DefId; -pub trait SmirTy<'tcx> { +pub trait TyHelpers<'tcx> { fn new_foreign(&self, def_id: DefId) -> Ty<'tcx>; } -pub trait SmirTypingEnv<'tcx> { +pub trait TypingEnvHelpers<'tcx> { fn fully_monomorphized(&self) -> ty::TypingEnv<'tcx>; } -pub trait SmirAllocRange<'tcx> { +pub trait AllocRangeHelpers<'tcx> { fn alloc_range(&self, offset: rustc_abi::Size, size: rustc_abi::Size) -> AllocRange; } diff --git a/compiler/rustc_public_bridge/src/context/impls.rs b/compiler/rustc_public_bridge/src/context/impls.rs index 268aa6927d286..8079fc95f97dd 100644 --- a/compiler/rustc_public_bridge/src/context/impls.rs +++ b/compiler/rustc_public_bridge/src/context/impls.rs @@ -24,23 +24,23 @@ use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc_span::{FileNameDisplayPreference, Span, Symbol}; use rustc_target::callconv::FnAbi; -use super::{SmirAllocRange, CompilerCtxt, SmirTy, SmirTypingEnv}; +use super::{AllocRangeHelpers, CompilerCtxt, TyHelpers, TypingEnvHelpers}; use crate::builder::BodyBuilder; use crate::{Bridge, SmirError, Tables, filter_def_ids}; -impl<'tcx, B: Bridge> SmirTy<'tcx> for CompilerCtxt<'tcx, B> { +impl<'tcx, B: Bridge> TyHelpers<'tcx> for CompilerCtxt<'tcx, B> { fn new_foreign(&self, def_id: DefId) -> ty::Ty<'tcx> { ty::Ty::new_foreign(self.tcx, def_id) } } -impl<'tcx, B: Bridge> SmirTypingEnv<'tcx> for CompilerCtxt<'tcx, B> { +impl<'tcx, B: Bridge> TypingEnvHelpers<'tcx> for CompilerCtxt<'tcx, B> { fn fully_monomorphized(&self) -> ty::TypingEnv<'tcx> { ty::TypingEnv::fully_monomorphized() } } -impl<'tcx, B: Bridge> SmirAllocRange<'tcx> for CompilerCtxt<'tcx, B> { +impl<'tcx, B: Bridge> AllocRangeHelpers<'tcx> for CompilerCtxt<'tcx, B> { fn alloc_range( &self, offset: rustc_abi::Size, @@ -426,7 +426,7 @@ impl<'tcx, B: Bridge> CompilerCtxt<'tcx, B> { /// Evaluate constant as a target usize. pub fn eval_target_usize(&self, cnst: MirConst<'tcx>) -> Result { - use crate::context::SmirTypingEnv; + use crate::context::TypingEnvHelpers; cnst.try_eval_target_usize(self.tcx, self.fully_monomorphized()) .ok_or_else(|| B::Error::new(format!("Const `{cnst:?}` cannot be encoded as u64"))) } diff --git a/compiler/rustc_public_bridge/src/context/mod.rs b/compiler/rustc_public_bridge/src/context/mod.rs index d2fbf976a24fa..3aa5c33c57db9 100644 --- a/compiler/rustc_public_bridge/src/context/mod.rs +++ b/compiler/rustc_public_bridge/src/context/mod.rs @@ -12,9 +12,9 @@ use rustc_middle::ty::{Ty, TyCtxt}; use crate::{Bridge, SmirError}; mod impls; -mod traits; +mod helpers; -pub use traits::*; +pub use helpers::*; /// Provides direct access to rustc's internal queries. /// From 08e3cf511819ecc058230ccf2dd4a8e4f55625e1 Mon Sep 17 00:00:00 2001 From: Makai Date: Tue, 15 Jul 2025 13:53:51 +0000 Subject: [PATCH 04/10] rename `ui-fulldeps/stable-mir` --- tests/ui-fulldeps/{stable-mir => rustc_public}/check_abi.rs | 0 .../ui-fulldeps/{stable-mir => rustc_public}/check_allocation.rs | 0 .../ui-fulldeps/{stable-mir => rustc_public}/check_assoc_items.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/check_attribute.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/check_binop.rs | 0 .../{stable-mir => rustc_public}/check_coroutine_body.rs | 0 .../ui-fulldeps/{stable-mir => rustc_public}/check_crate_defs.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/check_def_ty.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/check_defs.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/check_foreign.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/check_instance.rs | 0 .../ui-fulldeps/{stable-mir => rustc_public}/check_intrinsics.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/check_item_kind.rs | 0 .../{stable-mir => rustc_public}/check_normalization.rs | 0 .../{stable-mir => rustc_public}/check_trait_queries.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/check_transform.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/check_ty_fold.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/check_variant.rs | 0 .../{stable-mir => rustc_public}/closure-generic-body.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/closure_body.rs | 0 .../{stable-mir => rustc_public}/compilation-result.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/crate-info.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/projections.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/smir_internal.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/smir_serde.rs | 0 tests/ui-fulldeps/{stable-mir => rustc_public}/smir_visitor.rs | 0 26 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_abi.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_allocation.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_assoc_items.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_attribute.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_binop.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_coroutine_body.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_crate_defs.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_def_ty.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_defs.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_foreign.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_instance.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_intrinsics.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_item_kind.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_normalization.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_trait_queries.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_transform.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_ty_fold.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/check_variant.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/closure-generic-body.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/closure_body.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/compilation-result.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/crate-info.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/projections.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/smir_internal.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/smir_serde.rs (100%) rename tests/ui-fulldeps/{stable-mir => rustc_public}/smir_visitor.rs (100%) diff --git a/tests/ui-fulldeps/stable-mir/check_abi.rs b/tests/ui-fulldeps/rustc_public/check_abi.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_abi.rs rename to tests/ui-fulldeps/rustc_public/check_abi.rs diff --git a/tests/ui-fulldeps/stable-mir/check_allocation.rs b/tests/ui-fulldeps/rustc_public/check_allocation.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_allocation.rs rename to tests/ui-fulldeps/rustc_public/check_allocation.rs diff --git a/tests/ui-fulldeps/stable-mir/check_assoc_items.rs b/tests/ui-fulldeps/rustc_public/check_assoc_items.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_assoc_items.rs rename to tests/ui-fulldeps/rustc_public/check_assoc_items.rs diff --git a/tests/ui-fulldeps/stable-mir/check_attribute.rs b/tests/ui-fulldeps/rustc_public/check_attribute.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_attribute.rs rename to tests/ui-fulldeps/rustc_public/check_attribute.rs diff --git a/tests/ui-fulldeps/stable-mir/check_binop.rs b/tests/ui-fulldeps/rustc_public/check_binop.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_binop.rs rename to tests/ui-fulldeps/rustc_public/check_binop.rs diff --git a/tests/ui-fulldeps/stable-mir/check_coroutine_body.rs b/tests/ui-fulldeps/rustc_public/check_coroutine_body.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_coroutine_body.rs rename to tests/ui-fulldeps/rustc_public/check_coroutine_body.rs diff --git a/tests/ui-fulldeps/stable-mir/check_crate_defs.rs b/tests/ui-fulldeps/rustc_public/check_crate_defs.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_crate_defs.rs rename to tests/ui-fulldeps/rustc_public/check_crate_defs.rs diff --git a/tests/ui-fulldeps/stable-mir/check_def_ty.rs b/tests/ui-fulldeps/rustc_public/check_def_ty.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_def_ty.rs rename to tests/ui-fulldeps/rustc_public/check_def_ty.rs diff --git a/tests/ui-fulldeps/stable-mir/check_defs.rs b/tests/ui-fulldeps/rustc_public/check_defs.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_defs.rs rename to tests/ui-fulldeps/rustc_public/check_defs.rs diff --git a/tests/ui-fulldeps/stable-mir/check_foreign.rs b/tests/ui-fulldeps/rustc_public/check_foreign.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_foreign.rs rename to tests/ui-fulldeps/rustc_public/check_foreign.rs diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/rustc_public/check_instance.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_instance.rs rename to tests/ui-fulldeps/rustc_public/check_instance.rs diff --git a/tests/ui-fulldeps/stable-mir/check_intrinsics.rs b/tests/ui-fulldeps/rustc_public/check_intrinsics.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_intrinsics.rs rename to tests/ui-fulldeps/rustc_public/check_intrinsics.rs diff --git a/tests/ui-fulldeps/stable-mir/check_item_kind.rs b/tests/ui-fulldeps/rustc_public/check_item_kind.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_item_kind.rs rename to tests/ui-fulldeps/rustc_public/check_item_kind.rs diff --git a/tests/ui-fulldeps/stable-mir/check_normalization.rs b/tests/ui-fulldeps/rustc_public/check_normalization.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_normalization.rs rename to tests/ui-fulldeps/rustc_public/check_normalization.rs diff --git a/tests/ui-fulldeps/stable-mir/check_trait_queries.rs b/tests/ui-fulldeps/rustc_public/check_trait_queries.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_trait_queries.rs rename to tests/ui-fulldeps/rustc_public/check_trait_queries.rs diff --git a/tests/ui-fulldeps/stable-mir/check_transform.rs b/tests/ui-fulldeps/rustc_public/check_transform.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_transform.rs rename to tests/ui-fulldeps/rustc_public/check_transform.rs diff --git a/tests/ui-fulldeps/stable-mir/check_ty_fold.rs b/tests/ui-fulldeps/rustc_public/check_ty_fold.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_ty_fold.rs rename to tests/ui-fulldeps/rustc_public/check_ty_fold.rs diff --git a/tests/ui-fulldeps/stable-mir/check_variant.rs b/tests/ui-fulldeps/rustc_public/check_variant.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/check_variant.rs rename to tests/ui-fulldeps/rustc_public/check_variant.rs diff --git a/tests/ui-fulldeps/stable-mir/closure-generic-body.rs b/tests/ui-fulldeps/rustc_public/closure-generic-body.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/closure-generic-body.rs rename to tests/ui-fulldeps/rustc_public/closure-generic-body.rs diff --git a/tests/ui-fulldeps/stable-mir/closure_body.rs b/tests/ui-fulldeps/rustc_public/closure_body.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/closure_body.rs rename to tests/ui-fulldeps/rustc_public/closure_body.rs diff --git a/tests/ui-fulldeps/stable-mir/compilation-result.rs b/tests/ui-fulldeps/rustc_public/compilation-result.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/compilation-result.rs rename to tests/ui-fulldeps/rustc_public/compilation-result.rs diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/rustc_public/crate-info.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/crate-info.rs rename to tests/ui-fulldeps/rustc_public/crate-info.rs diff --git a/tests/ui-fulldeps/stable-mir/projections.rs b/tests/ui-fulldeps/rustc_public/projections.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/projections.rs rename to tests/ui-fulldeps/rustc_public/projections.rs diff --git a/tests/ui-fulldeps/stable-mir/smir_internal.rs b/tests/ui-fulldeps/rustc_public/smir_internal.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/smir_internal.rs rename to tests/ui-fulldeps/rustc_public/smir_internal.rs diff --git a/tests/ui-fulldeps/stable-mir/smir_serde.rs b/tests/ui-fulldeps/rustc_public/smir_serde.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/smir_serde.rs rename to tests/ui-fulldeps/rustc_public/smir_serde.rs diff --git a/tests/ui-fulldeps/stable-mir/smir_visitor.rs b/tests/ui-fulldeps/rustc_public/smir_visitor.rs similarity index 100% rename from tests/ui-fulldeps/stable-mir/smir_visitor.rs rename to tests/ui-fulldeps/rustc_public/smir_visitor.rs From 9a37aab5589ecfe4101b727b2a91c3846a0068cd Mon Sep 17 00:00:00 2001 From: Makai Date: Tue, 15 Jul 2025 13:54:44 +0000 Subject: [PATCH 05/10] rename `ui/stable-mir-print` --- .../{stable-mir-print => rustc_public-ir-print}/async-closure.rs | 0 .../async-closure.stdout | 0 .../{stable-mir-print => rustc_public-ir-print}/basic_function.rs | 0 .../basic_function.stdout | 0 tests/ui/{stable-mir-print => rustc_public-ir-print}/operands.rs | 0 .../{stable-mir-print => rustc_public-ir-print}/operands.stdout | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{stable-mir-print => rustc_public-ir-print}/async-closure.rs (100%) rename tests/ui/{stable-mir-print => rustc_public-ir-print}/async-closure.stdout (100%) rename tests/ui/{stable-mir-print => rustc_public-ir-print}/basic_function.rs (100%) rename tests/ui/{stable-mir-print => rustc_public-ir-print}/basic_function.stdout (100%) rename tests/ui/{stable-mir-print => rustc_public-ir-print}/operands.rs (100%) rename tests/ui/{stable-mir-print => rustc_public-ir-print}/operands.stdout (100%) diff --git a/tests/ui/stable-mir-print/async-closure.rs b/tests/ui/rustc_public-ir-print/async-closure.rs similarity index 100% rename from tests/ui/stable-mir-print/async-closure.rs rename to tests/ui/rustc_public-ir-print/async-closure.rs diff --git a/tests/ui/stable-mir-print/async-closure.stdout b/tests/ui/rustc_public-ir-print/async-closure.stdout similarity index 100% rename from tests/ui/stable-mir-print/async-closure.stdout rename to tests/ui/rustc_public-ir-print/async-closure.stdout diff --git a/tests/ui/stable-mir-print/basic_function.rs b/tests/ui/rustc_public-ir-print/basic_function.rs similarity index 100% rename from tests/ui/stable-mir-print/basic_function.rs rename to tests/ui/rustc_public-ir-print/basic_function.rs diff --git a/tests/ui/stable-mir-print/basic_function.stdout b/tests/ui/rustc_public-ir-print/basic_function.stdout similarity index 100% rename from tests/ui/stable-mir-print/basic_function.stdout rename to tests/ui/rustc_public-ir-print/basic_function.stdout diff --git a/tests/ui/stable-mir-print/operands.rs b/tests/ui/rustc_public-ir-print/operands.rs similarity index 100% rename from tests/ui/stable-mir-print/operands.rs rename to tests/ui/rustc_public-ir-print/operands.rs diff --git a/tests/ui/stable-mir-print/operands.stdout b/tests/ui/rustc_public-ir-print/operands.stdout similarity index 100% rename from tests/ui/stable-mir-print/operands.stdout rename to tests/ui/rustc_public-ir-print/operands.stdout From a1deaa7097aa92bfb184824faf30791c03d190f8 Mon Sep 17 00:00:00 2001 From: Makai Date: Tue, 15 Jul 2025 15:58:40 +0000 Subject: [PATCH 06/10] `SmirError` to `Error` --- compiler/rustc_public/src/alloc.rs | 2 +- compiler/rustc_public/src/error.rs | 4 +-- compiler/rustc_public/src/mir/mono.rs | 26 +++++++++---------- .../src/unstable/convert/stable/mir.rs | 5 ++-- .../src/unstable/internal_cx/mod.rs | 2 +- compiler/rustc_public_bridge/src/alloc.rs | 2 +- compiler/rustc_public_bridge/src/bridge.rs | 2 +- .../rustc_public_bridge/src/context/impls.rs | 2 +- .../rustc_public_bridge/src/context/mod.rs | 4 +-- compiler/rustc_public_bridge/src/lib.rs | 2 +- 10 files changed, 25 insertions(+), 26 deletions(-) diff --git a/compiler/rustc_public/src/alloc.rs b/compiler/rustc_public/src/alloc.rs index cb6cc37e82981..dcb3cc0e75fe2 100644 --- a/compiler/rustc_public/src/alloc.rs +++ b/compiler/rustc_public/src/alloc.rs @@ -7,7 +7,7 @@ use rustc_abi::Align; use rustc_middle::mir::ConstValue; use rustc_middle::mir::interpret::AllocRange; -use rustc_public_bridge::bridge::SmirError; +use rustc_public_bridge::bridge::Error as _; use rustc_public_bridge::context::CompilerCtxt; use rustc_public_bridge::{Tables, alloc}; diff --git a/compiler/rustc_public/src/error.rs b/compiler/rustc_public/src/error.rs index bc2124d1716f1..70a74eaa9fbc5 100644 --- a/compiler/rustc_public/src/error.rs +++ b/compiler/rustc_public/src/error.rs @@ -7,7 +7,7 @@ use std::fmt::{Debug, Display, Formatter}; use std::{fmt, io}; -use rustc_public_bridge::bridge::SmirError; +use rustc_public_bridge::bridge; macro_rules! error { ($fmt: literal $(,)?) => { Error(format!($fmt)) }; @@ -32,7 +32,7 @@ pub enum CompilerError { #[derive(Clone, Debug, Eq, PartialEq)] pub struct Error(pub(crate) String); -impl SmirError for Error { +impl bridge::Error for Error { fn new(msg: String) -> Self { Self(msg) } diff --git a/compiler/rustc_public/src/mir/mono.rs b/compiler/rustc_public/src/mir/mono.rs index c85f0fa36f7d4..06f6ac17e7b54 100644 --- a/compiler/rustc_public/src/mir/mono.rs +++ b/compiler/rustc_public/src/mir/mono.rs @@ -1,7 +1,7 @@ use std::fmt::{Debug, Formatter}; use std::io; -use rustc_public_bridge::bridge::SmirError; +use rustc_public_bridge::bridge; use serde::Serialize; use crate::abi::FnAbi; @@ -120,9 +120,9 @@ impl Instance { /// Resolve an instance starting from a function definition and generic arguments. pub fn resolve(def: FnDef, args: &GenericArgs) -> Result { with(|context| { - context - .resolve_instance(def, args) - .ok_or_else(|| Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`"))) + context.resolve_instance(def, args).ok_or_else(|| { + bridge::Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`")) + }) }) } @@ -134,9 +134,9 @@ impl Instance { /// Resolve an instance for a given function pointer. pub fn resolve_for_fn_ptr(def: FnDef, args: &GenericArgs) -> Result { with(|context| { - context - .resolve_for_fn_ptr(def, args) - .ok_or_else(|| Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`"))) + context.resolve_for_fn_ptr(def, args).ok_or_else(|| { + bridge::Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`")) + }) }) } @@ -147,9 +147,9 @@ impl Instance { kind: ClosureKind, ) -> Result { with(|context| { - context - .resolve_closure(def, args, kind) - .ok_or_else(|| Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`"))) + context.resolve_closure(def, args, kind).ok_or_else(|| { + bridge::Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`")) + }) }) } @@ -201,7 +201,7 @@ impl TryFrom for Instance { if !context.requires_monomorphization(def_id) { Ok(context.mono_instance(def_id)) } else { - Err(Error::new("Item requires monomorphization".to_string())) + Err(bridge::Error::new("Item requires monomorphization".to_string())) } }) } @@ -217,7 +217,7 @@ impl TryFrom for CrateItem { if value.kind == InstanceKind::Item && context.has_body(value.def.def_id()) { Ok(CrateItem(context.instance_def_id(value.def))) } else { - Err(Error::new(format!("Item kind `{:?}` cannot be converted", value.kind))) + Err(bridge::Error::new(format!("Item kind `{:?}` cannot be converted", value.kind))) } }) } @@ -263,7 +263,7 @@ impl TryFrom for StaticDef { if matches!(value.kind(), ItemKind::Static) { Ok(StaticDef(value.0)) } else { - Err(Error::new(format!("Expected a static item, but found: {value:?}"))) + Err(bridge::Error::new(format!("Expected a static item, but found: {value:?}"))) } } } diff --git a/compiler/rustc_public/src/unstable/convert/stable/mir.rs b/compiler/rustc_public/src/unstable/convert/stable/mir.rs index cb68129c6606a..8dee579e598b5 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/mir.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/mir.rs @@ -2,9 +2,8 @@ use rustc_middle::mir::mono::MonoItem; use rustc_middle::{bug, mir}; -use rustc_public_bridge::Tables; -use rustc_public_bridge::bridge::SmirError; use rustc_public_bridge::context::CompilerCtxt; +use rustc_public_bridge::{Tables, bridge}; use crate::compiler_interface::BridgeTys; use crate::mir::alloc::GlobalAlloc; @@ -914,7 +913,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::ErrorHandled { type T = Error; fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { - Error::new(format!("{self:?}")) + bridge::Error::new(format!("{self:?}")) } } diff --git a/compiler/rustc_public/src/unstable/internal_cx/mod.rs b/compiler/rustc_public/src/unstable/internal_cx/mod.rs index 44fbfde877550..601ca4fb5cfdb 100644 --- a/compiler/rustc_public/src/unstable/internal_cx/mod.rs +++ b/compiler/rustc_public/src/unstable/internal_cx/mod.rs @@ -1,8 +1,8 @@ //! Implementation of InternalCx. +pub(crate) use helpers::*; use rustc_middle::ty::{List, Ty, TyCtxt}; use rustc_middle::{mir, ty}; -pub(crate) use helpers::*; use super::InternalCx; diff --git a/compiler/rustc_public_bridge/src/alloc.rs b/compiler/rustc_public_bridge/src/alloc.rs index c866b05e6cf22..4a4725390a0fe 100644 --- a/compiler/rustc_public_bridge/src/alloc.rs +++ b/compiler/rustc_public_bridge/src/alloc.rs @@ -12,7 +12,7 @@ use rustc_middle::ty::{Ty, layout}; use super::{CompilerCtxt, Tables}; use crate::bridge::Allocation as _; -use crate::{Bridge, SmirError}; +use crate::{Bridge, Error}; pub fn create_ty_and_layout<'tcx, B: Bridge>( cx: &CompilerCtxt<'tcx, B>, diff --git a/compiler/rustc_public_bridge/src/bridge.rs b/compiler/rustc_public_bridge/src/bridge.rs index 675bb2d8bc33a..d4f4847c8d3bd 100644 --- a/compiler/rustc_public_bridge/src/bridge.rs +++ b/compiler/rustc_public_bridge/src/bridge.rs @@ -9,7 +9,7 @@ use std::fmt::Debug; use super::context::CompilerCtxt; use super::{Bridge, Tables}; -pub trait SmirError { +pub trait Error { fn new(msg: String) -> Self; fn from_internal(err: T) -> Self; } diff --git a/compiler/rustc_public_bridge/src/context/impls.rs b/compiler/rustc_public_bridge/src/context/impls.rs index 8079fc95f97dd..5637da9e5b107 100644 --- a/compiler/rustc_public_bridge/src/context/impls.rs +++ b/compiler/rustc_public_bridge/src/context/impls.rs @@ -26,7 +26,7 @@ use rustc_target::callconv::FnAbi; use super::{AllocRangeHelpers, CompilerCtxt, TyHelpers, TypingEnvHelpers}; use crate::builder::BodyBuilder; -use crate::{Bridge, SmirError, Tables, filter_def_ids}; +use crate::{Bridge, Error, Tables, filter_def_ids}; impl<'tcx, B: Bridge> TyHelpers<'tcx> for CompilerCtxt<'tcx, B> { fn new_foreign(&self, def_id: DefId) -> ty::Ty<'tcx> { diff --git a/compiler/rustc_public_bridge/src/context/mod.rs b/compiler/rustc_public_bridge/src/context/mod.rs index 3aa5c33c57db9..b436319ae8bf6 100644 --- a/compiler/rustc_public_bridge/src/context/mod.rs +++ b/compiler/rustc_public_bridge/src/context/mod.rs @@ -9,10 +9,10 @@ use rustc_middle::ty; use rustc_middle::ty::layout::{FnAbiOfHelpers, HasTyCtxt, HasTypingEnv, LayoutOfHelpers}; use rustc_middle::ty::{Ty, TyCtxt}; -use crate::{Bridge, SmirError}; +use crate::{Bridge, Error}; -mod impls; mod helpers; +mod impls; pub use helpers::*; diff --git a/compiler/rustc_public_bridge/src/lib.rs b/compiler/rustc_public_bridge/src/lib.rs index 2bb259a857c0c..c0e1b6d4f511a 100644 --- a/compiler/rustc_public_bridge/src/lib.rs +++ b/compiler/rustc_public_bridge/src/lib.rs @@ -222,7 +222,7 @@ pub trait Bridge: Sized { type MirConstId: Copy + Debug + PartialEq + IndexedVal; type Layout: Copy + Debug + PartialEq + IndexedVal; - type Error: SmirError; + type Error: Error; type CrateItem: CrateItem; type AdtDef: AdtDef; type ForeignModuleDef: ForeignModuleDef; From 95338717f10b46dfac7ee8333672ede004ca212b Mon Sep 17 00:00:00 2001 From: Makai Date: Tue, 15 Jul 2025 16:02:24 +0000 Subject: [PATCH 07/10] Update docs in `rustc_public_bridge` --- compiler/rustc_public_bridge/src/alloc.rs | 2 +- compiler/rustc_public_bridge/src/builder.rs | 7 +++---- compiler/rustc_public_bridge/src/context/impls.rs | 4 ++-- compiler/rustc_public_bridge/src/context/mod.rs | 4 ++-- compiler/rustc_public_bridge/src/lib.rs | 6 +++--- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_public_bridge/src/alloc.rs b/compiler/rustc_public_bridge/src/alloc.rs index 4a4725390a0fe..ecf9004562c2b 100644 --- a/compiler/rustc_public_bridge/src/alloc.rs +++ b/compiler/rustc_public_bridge/src/alloc.rs @@ -1,4 +1,4 @@ -//! Internal memory allocator implementation for StableMIR. +//! Internal memory allocator implementation for rustc_public. //! //! This module handles all direct interactions with rustc queries and performs //! the actual memory allocations. The stable interface in `rustc_public::alloc` diff --git a/compiler/rustc_public_bridge/src/builder.rs b/compiler/rustc_public_bridge/src/builder.rs index 2141053d09af0..ea7f37d72d0dd 100644 --- a/compiler/rustc_public_bridge/src/builder.rs +++ b/compiler/rustc_public_bridge/src/builder.rs @@ -1,8 +1,7 @@ -//! Logic required to produce a monomorphic stable body. +//! Logic required to produce a monomorphic body. //! -//! We first retrieve and monomorphize the rustc body representation, i.e., we generate a +//! We retrieve and monomorphize the rustc body representation, i.e., we generate a //! monomorphic body using internal representation. -//! After that, we convert the internal representation into a stable one. use rustc_hir::def::DefKind; use rustc_middle::mir; @@ -25,7 +24,7 @@ impl<'tcx> BodyBuilder<'tcx> { BodyBuilder { tcx, instance } } - /// Build a stable monomorphic body for a given instance based on the MIR body. + /// Build a monomorphic body for a given instance based on the MIR body. /// /// All constants are also evaluated. pub(crate) fn build(mut self) -> mir::Body<'tcx> { diff --git a/compiler/rustc_public_bridge/src/context/impls.rs b/compiler/rustc_public_bridge/src/context/impls.rs index 5637da9e5b107..612e44b56b1af 100644 --- a/compiler/rustc_public_bridge/src/context/impls.rs +++ b/compiler/rustc_public_bridge/src/context/impls.rs @@ -1,4 +1,4 @@ -//! Implementation of StableMIR Context. +//! Implementation of CompilerCtxt. #![allow(rustc::usage_of_qualified_ty)] @@ -85,7 +85,7 @@ impl<'tcx, B: Bridge> CompilerCtxt<'tcx, B> { /// Return whether the item has a body defined by the user. /// /// Note that intrinsics may have a placeholder body that shouldn't be used in practice. - /// In StableMIR, we handle this case as if the body is not available. + /// In rustc_public, we handle this case as if the body is not available. pub(crate) fn item_has_body(&self, def_id: DefId) -> bool { let must_override = if let Some(intrinsic) = self.tcx.intrinsic(def_id) { intrinsic.must_be_overridden diff --git a/compiler/rustc_public_bridge/src/context/mod.rs b/compiler/rustc_public_bridge/src/context/mod.rs index b436319ae8bf6..857a2d4e26bce 100644 --- a/compiler/rustc_public_bridge/src/context/mod.rs +++ b/compiler/rustc_public_bridge/src/context/mod.rs @@ -1,4 +1,4 @@ -//! Implementation of StableMIR Context. +//! Implementation of CompilerCtxt. #![allow(rustc::usage_of_qualified_ty)] @@ -19,7 +19,7 @@ pub use helpers::*; /// Provides direct access to rustc's internal queries. /// /// `CompilerInterface` must go through -/// this context to obtain rustc-level information. +/// this context to obtain internal information. pub struct CompilerCtxt<'tcx, B: Bridge> { pub tcx: TyCtxt<'tcx>, _marker: PhantomData, diff --git a/compiler/rustc_public_bridge/src/lib.rs b/compiler/rustc_public_bridge/src/lib.rs index c0e1b6d4f511a..dec3be70baff4 100644 --- a/compiler/rustc_public_bridge/src/lib.rs +++ b/compiler/rustc_public_bridge/src/lib.rs @@ -1,6 +1,6 @@ -//! Crate that implements what will become the rustc side of Stable MIR. +//! Crate that implements what will become the rustc side of rustc_public. //! -//! This crate is responsible for building Stable MIR components from internal components. +//! This crate serves as a proxy for making calls to rustc queries. //! //! This crate is not intended to be invoked directly by users. //! This crate is the public API of rustc that will be invoked by the `rustc_public` crate. @@ -210,7 +210,7 @@ impl<'tcx, B: Bridge> Tables<'tcx, B> { } } -/// A trait defining types that are used to emulate StableMIR components, which is really +/// A trait defining types that are used to emulate rustc_public components, which is really /// useful when programming in rustc_public-agnostic settings. pub trait Bridge: Sized { type DefId: Copy + Debug + PartialEq + IndexedVal; From 483877a9b2140065df08e15a27c20c9431028ec5 Mon Sep 17 00:00:00 2001 From: Makai Date: Tue, 15 Jul 2025 16:22:33 +0000 Subject: [PATCH 08/10] Update docs in `rustc_public` --- compiler/rustc_public/src/alloc.rs | 2 +- .../rustc_public/src/compiler_interface.rs | 4 ++-- compiler/rustc_public/src/error.rs | 2 +- compiler/rustc_public/src/mir/alloc.rs | 2 +- compiler/rustc_public/src/mir/body.rs | 6 +++--- compiler/rustc_public/src/mir/mono.rs | 4 ++-- compiler/rustc_public/src/mir/pretty.rs | 2 +- compiler/rustc_public/src/mir/visit.rs | 2 +- .../rustc_public/src/rustc_internal/mod.rs | 12 ++++++------ .../rustc_public/src/rustc_internal/pretty.rs | 2 +- .../src/unstable/convert/internal.rs | 2 +- .../rustc_public/src/unstable/convert/mod.rs | 2 +- compiler/rustc_public/src/unstable/mod.rs | 19 ++++++++++--------- 13 files changed, 31 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_public/src/alloc.rs b/compiler/rustc_public/src/alloc.rs index dcb3cc0e75fe2..75ad31022ff57 100644 --- a/compiler/rustc_public/src/alloc.rs +++ b/compiler/rustc_public/src/alloc.rs @@ -1,4 +1,4 @@ -//! Memory allocation implementation for StableMIR. +//! Memory allocation implementation for rustc_public. //! //! This module is responsible for constructing stable components. //! All operations requiring rustc queries must be delegated diff --git a/compiler/rustc_public/src/compiler_interface.rs b/compiler/rustc_public/src/compiler_interface.rs index 043064951d5d4..5a09c3b24f0f1 100644 --- a/compiler/rustc_public/src/compiler_interface.rs +++ b/compiler/rustc_public/src/compiler_interface.rs @@ -1,6 +1,6 @@ //! Define the interface with the Rust compiler. //! -//! StableMIR users should not use any of the items in this module directly. +//! rustc_public users should not use any of the items in this module directly. //! These APIs have no stability guarantee. use std::cell::Cell; @@ -1067,7 +1067,7 @@ where F: FnOnce() -> T, { if TLV.is_set() { - Err(Error::from("StableMIR already running")) + Err(Error::from("rustc_public already running")) } else { let ptr: *const () = (&raw const interface) as _; TLV.set(&Cell::new(ptr), || Ok(f())) diff --git a/compiler/rustc_public/src/error.rs b/compiler/rustc_public/src/error.rs index 70a74eaa9fbc5..3d75a4bd31574 100644 --- a/compiler/rustc_public/src/error.rs +++ b/compiler/rustc_public/src/error.rs @@ -1,5 +1,5 @@ //! When things go wrong, we need some error handling. -//! There are a few different types of errors in StableMIR: +//! There are a few different types of errors in rustc_public: //! //! - [CompilerError]: This represents errors that can be raised when invoking the compiler. //! - [Error]: Generic error that represents the reason why a request that could not be fulfilled. diff --git a/compiler/rustc_public/src/mir/alloc.rs b/compiler/rustc_public/src/mir/alloc.rs index 9a94551f3ec8e..07a979f3811e4 100644 --- a/compiler/rustc_public/src/mir/alloc.rs +++ b/compiler/rustc_public/src/mir/alloc.rs @@ -9,7 +9,7 @@ use crate::target::{Endian, MachineInfo}; use crate::ty::{Allocation, Binder, ExistentialTraitRef, Ty}; use crate::{Error, IndexedVal, with}; -/// An allocation in the SMIR global memory can be either a function pointer, +/// An allocation in the rustc_public's IR global memory can be either a function pointer, /// a static, or a "real" allocation with some data in it. #[derive(Debug, Clone, Eq, PartialEq, Serialize)] pub enum GlobalAlloc { diff --git a/compiler/rustc_public/src/mir/body.rs b/compiler/rustc_public/src/mir/body.rs index 28a7aa6e75821..3320b98cd610e 100644 --- a/compiler/rustc_public/src/mir/body.rs +++ b/compiler/rustc_public/src/mir/body.rs @@ -10,7 +10,7 @@ use crate::ty::{ }; use crate::{Error, Opaque, Span, Symbol}; -/// The SMIR representation of a single function. +/// The rustc_public's IR representation of a single function. #[derive(Clone, Debug, Serialize)] pub struct Body { pub blocks: Vec, @@ -771,8 +771,8 @@ pub enum VarDebugInfoContents { // In MIR ProjectionElem is parameterized on the second Field argument and the Index argument. This // is so it can be used for both Places (for which the projection elements are of type // ProjectionElem) and user-provided type annotations (for which the projection elements -// are of type ProjectionElem<(), ()>). In SMIR we don't need this generality, so we just use -// ProjectionElem for Places. +// are of type ProjectionElem<(), ()>). +// In rustc_public's IR we don't need this generality, so we just use ProjectionElem for Places. #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub enum ProjectionElem { /// Dereference projections (e.g. `*_1`) project to the address referenced by the base place. diff --git a/compiler/rustc_public/src/mir/mono.rs b/compiler/rustc_public/src/mir/mono.rs index 06f6ac17e7b54..d488f5a25c7d9 100644 --- a/compiler/rustc_public/src/mir/mono.rs +++ b/compiler/rustc_public/src/mir/mono.rs @@ -62,7 +62,7 @@ impl Instance { /// For more information on fallback body, see . /// /// This call is much cheaper than `instance.body().is_some()`, since it doesn't try to build - /// the StableMIR body. + /// the rustc_public's IR body. pub fn has_body(&self) -> bool { with(|cx| cx.has_body(self.def.def_id())) } @@ -157,7 +157,7 @@ impl Instance { /// /// Allow users to check if this shim can be ignored when called directly. /// - /// We have decided not to export different types of Shims to StableMIR users, however, this + /// We have decided not to export different types of Shims to rustc_public users, however, this /// is a query that can be very helpful for users when processing DropGlue. /// /// When generating code for a Drop terminator, users can ignore an empty drop glue. diff --git a/compiler/rustc_public/src/mir/pretty.rs b/compiler/rustc_public/src/mir/pretty.rs index f496d80053e64..a433df2dba1a1 100644 --- a/compiler/rustc_public/src/mir/pretty.rs +++ b/compiler/rustc_public/src/mir/pretty.rs @@ -1,4 +1,4 @@ -//! Implement methods to pretty print stable MIR body. +//! Implement methods to pretty print rustc_public's IR body. use std::fmt::Debug; use std::io::Write; use std::{fmt, io, iter}; diff --git a/compiler/rustc_public/src/mir/visit.rs b/compiler/rustc_public/src/mir/visit.rs index 7dc99d1d1e188..04c4d4d2a82d7 100644 --- a/compiler/rustc_public/src/mir/visit.rs +++ b/compiler/rustc_public/src/mir/visit.rs @@ -1,4 +1,4 @@ -//! # The Stable MIR Visitor +//! # The rustc_public's IR Visitor //! //! ## Overview //! diff --git a/compiler/rustc_public/src/rustc_internal/mod.rs b/compiler/rustc_public/src/rustc_internal/mod.rs index ca999b62f8074..a119958974e4f 100644 --- a/compiler/rustc_public/src/rustc_internal/mod.rs +++ b/compiler/rustc_public/src/rustc_internal/mod.rs @@ -1,7 +1,7 @@ -//! Module that implements the bridge between Stable MIR and internal compiler MIR. +//! Module that implements the bridge between rustc_public's IR and internal compiler MIR. //! //! For that, we define APIs that will temporarily be public to 3P that exposes rustc internal APIs -//! until stable MIR is complete. +//! until rustc_public's IR is complete. use std::cell::{Cell, RefCell}; @@ -26,7 +26,7 @@ pub mod pretty; /// /// # Panics /// -/// This function will panic if StableMIR has not been properly initialized. +/// This function will panic if rustc_public has not been properly initialized. pub fn stable<'tcx, S: Stable<'tcx>>(item: S) -> S::T { with_container(|tables, cx| item.stable(tables, cx)) } @@ -41,7 +41,7 @@ pub fn stable<'tcx, S: Stable<'tcx>>(item: S) -> S::T { /// /// # Panics /// -/// This function will panic if StableMIR has not been properly initialized. +/// This function will panic if rustc_public has not been properly initialized. pub fn internal<'tcx, S>(tcx: TyCtxt<'tcx>, item: S) -> S::T<'tcx> where S: RustcInternal, @@ -57,7 +57,7 @@ pub fn crate_num(item: &crate::Crate) -> CrateNum { } // A thread local variable that stores a pointer to the tables mapping between TyCtxt -// datastructures and stable MIR datastructures +// datastructures and rustc_public's IR datastructures scoped_thread_local! (static TLV: Cell<*const ()>); pub(crate) fn init<'tcx, F, T, B: Bridge>(container: &Container<'tcx, B>, f: F) -> T @@ -176,7 +176,7 @@ macro_rules! optional { /// Prefer using [run!] and [run_with_tcx] instead. /// -/// This macro implements the instantiation of a StableMIR driver, and it will invoke +/// This macro implements the instantiation of a rustc_public driver, and it will invoke /// the given callback after the compiler analyses. /// /// The third argument determines whether the callback requires `tcx` as an argument. diff --git a/compiler/rustc_public/src/rustc_internal/pretty.rs b/compiler/rustc_public/src/rustc_internal/pretty.rs index 28c5280fe04c9..83522e5197783 100644 --- a/compiler/rustc_public/src/rustc_internal/pretty.rs +++ b/compiler/rustc_public/src/rustc_internal/pretty.rs @@ -7,7 +7,7 @@ use super::run; pub fn write_smir_pretty<'tcx, W: io::Write>(tcx: TyCtxt<'tcx>, w: &mut W) -> io::Result<()> { writeln!( w, - "// WARNING: This is highly experimental output it's intended for stable-mir developers only." + "// WARNING: This is highly experimental output it's intended for rustc_public developers only." )?; writeln!( w, diff --git a/compiler/rustc_public/src/unstable/convert/internal.rs b/compiler/rustc_public/src/unstable/convert/internal.rs index 0571a03b62bb8..b2d38e497bc82 100644 --- a/compiler/rustc_public/src/unstable/convert/internal.rs +++ b/compiler/rustc_public/src/unstable/convert/internal.rs @@ -1,4 +1,4 @@ -//! Module containing the translation from stable mir constructs to the rustc counterpart. +//! Module containing the translation from rustc_public constructs to the rustc counterpart. //! //! This module will only include a few constructs to allow users to invoke internal rustc APIs //! due to incomplete stable coverage. diff --git a/compiler/rustc_public/src/unstable/convert/mod.rs b/compiler/rustc_public/src/unstable/convert/mod.rs index a2e83c6e23944..f20406631e3ff 100644 --- a/compiler/rustc_public/src/unstable/convert/mod.rs +++ b/compiler/rustc_public/src/unstable/convert/mod.rs @@ -1,4 +1,4 @@ -//! This module holds the logic to convert rustc internal ADTs into stable mir ADTs. +//! This module holds the logic to convert rustc internal ADTs into rustc_public 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_public_bridge functions. diff --git a/compiler/rustc_public/src/unstable/mod.rs b/compiler/rustc_public/src/unstable/mod.rs index ca154a3378a7f..72b14cfa072ae 100644 --- a/compiler/rustc_public/src/unstable/mod.rs +++ b/compiler/rustc_public/src/unstable/mod.rs @@ -1,6 +1,6 @@ //! Module that collects the things that have no stability guarantees. //! -//! We want to keep StableMIR definitions and logic separate from +//! We want to keep rustc_public's IR definitions and logic separate from //! any sort of conversion and usage of internal rustc code. So we //! restrict the usage of internal items to be inside this module. @@ -53,16 +53,16 @@ pub trait InternalCx<'tcx>: Copy + Clone { fn adt_def(self, def_id: rustc_hir::def_id::DefId) -> ty::AdtDef<'tcx>; } -/// Trait used to convert between an internal MIR type to a Stable MIR type. +/// Trait used to convert between an internal MIR type to a rustc_public's IR type. /// -/// This trait is currently exposed to users so they can have interoperability between internal MIR -/// and StableMIR constructs. However, they should be used seldom and they have no influence -/// in this crate semver. +/// This trait is currently exposed to users so they can have interoperability +/// between internal MIR and rustc_public's IR constructs. +/// However, they should be used seldom and they have no influence in this crate semver. #[doc(hidden)] pub trait Stable<'tcx>: PointeeSized { /// The stable representation of the type implementing Stable. type T; - /// Converts an object to the equivalent Stable MIR representation. + /// Converts an object to the equivalent rustc_public's IR representation. fn stable<'cx>( &self, tables: &mut Tables<'cx, BridgeTys>, @@ -70,12 +70,13 @@ pub trait Stable<'tcx>: PointeeSized { ) -> Self::T; } -/// Trait used to translate a stable construct to its rustc counterpart. +/// Trait used to translate a rustc_public's IR construct to its rustc counterpart. /// /// This is basically a mirror of [Stable]. /// -/// This trait is currently exposed to users so they can have interoperability between internal MIR -/// and StableMIR constructs. They should be used seldom as they have no stability guarantees. +/// This trait is currently exposed to users so they can have interoperability +/// between internal MIR and rustc_public's IR constructs. +/// They should be used seldom as they have no stability guarantees. #[doc(hidden)] pub trait RustcInternal { type T<'tcx>; From 4d79328091167135e890b77f0fbf5b8b9479c80b Mon Sep 17 00:00:00 2001 From: Makai Date: Tue, 15 Jul 2025 16:37:26 +0000 Subject: [PATCH 09/10] use `RustcPublic` instead of `StableMir` --- compiler/rustc_public/src/rustc_internal/mod.rs | 12 ++++++------ tests/ui-fulldeps/rustc_public/check_abi.rs | 2 +- tests/ui-fulldeps/rustc_public/check_allocation.rs | 2 +- tests/ui-fulldeps/rustc_public/check_attribute.rs | 2 +- tests/ui-fulldeps/rustc_public/check_binop.rs | 2 +- tests/ui-fulldeps/rustc_public/check_crate_defs.rs | 2 +- tests/ui-fulldeps/rustc_public/check_def_ty.rs | 2 +- tests/ui-fulldeps/rustc_public/check_defs.rs | 2 +- tests/ui-fulldeps/rustc_public/check_foreign.rs | 2 +- tests/ui-fulldeps/rustc_public/check_instance.rs | 2 +- tests/ui-fulldeps/rustc_public/check_intrinsics.rs | 2 +- tests/ui-fulldeps/rustc_public/check_item_kind.rs | 2 +- .../ui-fulldeps/rustc_public/check_normalization.rs | 2 +- .../ui-fulldeps/rustc_public/check_trait_queries.rs | 2 +- tests/ui-fulldeps/rustc_public/check_transform.rs | 2 +- tests/ui-fulldeps/rustc_public/check_ty_fold.rs | 2 +- tests/ui-fulldeps/rustc_public/check_variant.rs | 2 +- tests/ui-fulldeps/rustc_public/compilation-result.rs | 2 +- tests/ui-fulldeps/rustc_public/crate-info.rs | 2 +- tests/ui-fulldeps/rustc_public/projections.rs | 2 +- tests/ui-fulldeps/rustc_public/smir_internal.rs | 2 +- tests/ui-fulldeps/rustc_public/smir_serde.rs | 2 +- tests/ui-fulldeps/rustc_public/smir_visitor.rs | 2 +- 23 files changed, 28 insertions(+), 28 deletions(-) diff --git a/compiler/rustc_public/src/rustc_internal/mod.rs b/compiler/rustc_public/src/rustc_internal/mod.rs index a119958974e4f..225c811ab3a54 100644 --- a/compiler/rustc_public/src/rustc_internal/mod.rs +++ b/compiler/rustc_public/src/rustc_internal/mod.rs @@ -191,7 +191,7 @@ macro_rules! run_driver { use rustc_public::CompilerError; use std::ops::ControlFlow; - pub struct StableMir ControlFlow> + pub struct RustcPublic ControlFlow> where B: Send, C: Send, @@ -201,15 +201,15 @@ macro_rules! run_driver { result: Option>, } - impl StableMir + impl RustcPublic where B: Send, C: Send, F: FnOnce($($crate::optional!($with_tcx TyCtxt))?) -> ControlFlow + Send, { - /// Creates a new `StableMir` instance, with given test_function and arguments. + /// Creates a new `RustcPublic` instance, with given test_function and arguments. pub fn new(callback: F) -> Self { - StableMir { callback: Some(callback), result: None } + RustcPublic { callback: Some(callback), result: None } } /// Runs the compiler against given target and tests it with `test_function` @@ -236,7 +236,7 @@ macro_rules! run_driver { } } - impl Callbacks for StableMir + impl Callbacks for RustcPublic where B: Send, C: Send, @@ -265,6 +265,6 @@ macro_rules! run_driver { } } - StableMir::new($callback).run($args) + RustcPublic::new($callback).run($args) }}; } diff --git a/tests/ui-fulldeps/rustc_public/check_abi.rs b/tests/ui-fulldeps/rustc_public/check_abi.rs index fc2227d147db1..57c8377ea3675 100644 --- a/tests/ui-fulldeps/rustc_public/check_abi.rs +++ b/tests/ui-fulldeps/rustc_public/check_abi.rs @@ -167,7 +167,7 @@ impl MirVisitor for AdtDefVisitor { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "alloc_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_allocation.rs b/tests/ui-fulldeps/rustc_public/check_allocation.rs index 83845a9aa422b..70e4ee3fe3477 100644 --- a/tests/ui-fulldeps/rustc_public/check_allocation.rs +++ b/tests/ui-fulldeps/rustc_public/check_allocation.rs @@ -202,7 +202,7 @@ fn get_item<'a>( /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "alloc_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_attribute.rs b/tests/ui-fulldeps/rustc_public/check_attribute.rs index d8807872ec46a..0c34ac4dfe957 100644 --- a/tests/ui-fulldeps/rustc_public/check_attribute.rs +++ b/tests/ui-fulldeps/rustc_public/check_attribute.rs @@ -52,7 +52,7 @@ fn get_item<'a>( /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "attribute_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_binop.rs b/tests/ui-fulldeps/rustc_public/check_binop.rs index aa089a5d12578..35be6f973cc70 100644 --- a/tests/ui-fulldeps/rustc_public/check_binop.rs +++ b/tests/ui-fulldeps/rustc_public/check_binop.rs @@ -76,7 +76,7 @@ impl<'a> MirVisitor for Visitor<'a> { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "binop_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_crate_defs.rs b/tests/ui-fulldeps/rustc_public/check_crate_defs.rs index 27d5b0bc23882..3ca8b66e58dca 100644 --- a/tests/ui-fulldeps/rustc_public/check_crate_defs.rs +++ b/tests/ui-fulldeps/rustc_public/check_crate_defs.rs @@ -79,7 +79,7 @@ fn contains(items: &[T], expected: &[&str]) { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "crate_definitions.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_def_ty.rs b/tests/ui-fulldeps/rustc_public/check_def_ty.rs index b5954352dc027..176a9d79ef111 100644 --- a/tests/ui-fulldeps/rustc_public/check_def_ty.rs +++ b/tests/ui-fulldeps/rustc_public/check_def_ty.rs @@ -70,7 +70,7 @@ fn check_fn_def(ty: Ty) { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "defs_ty_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_defs.rs b/tests/ui-fulldeps/rustc_public/check_defs.rs index 5e45f19cac89b..0c45859a132a9 100644 --- a/tests/ui-fulldeps/rustc_public/check_defs.rs +++ b/tests/ui-fulldeps/rustc_public/check_defs.rs @@ -106,7 +106,7 @@ fn get_instances(body: mir::Body) -> Vec { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "defs_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_foreign.rs b/tests/ui-fulldeps/rustc_public/check_foreign.rs index 9aee067f41b68..78b62594c6188 100644 --- a/tests/ui-fulldeps/rustc_public/check_foreign.rs +++ b/tests/ui-fulldeps/rustc_public/check_foreign.rs @@ -52,7 +52,7 @@ fn test_foreign() -> ControlFlow<()> { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "foreign_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_instance.rs b/tests/ui-fulldeps/rustc_public/check_instance.rs index 189710760439d..fd7523963fa9b 100644 --- a/tests/ui-fulldeps/rustc_public/check_instance.rs +++ b/tests/ui-fulldeps/rustc_public/check_instance.rs @@ -81,7 +81,7 @@ fn test_body(body: mir::Body) { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "instance_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_intrinsics.rs b/tests/ui-fulldeps/rustc_public/check_intrinsics.rs index 854ac77956e04..f722f0bbd7180 100644 --- a/tests/ui-fulldeps/rustc_public/check_intrinsics.rs +++ b/tests/ui-fulldeps/rustc_public/check_intrinsics.rs @@ -110,7 +110,7 @@ impl<'a> MirVisitor for CallsVisitor<'a> { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "binop_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_item_kind.rs b/tests/ui-fulldeps/rustc_public/check_item_kind.rs index 58e740bdaef53..b759628f1a42d 100644 --- a/tests/ui-fulldeps/rustc_public/check_item_kind.rs +++ b/tests/ui-fulldeps/rustc_public/check_item_kind.rs @@ -41,7 +41,7 @@ fn test_item_kind() -> ControlFlow<()> { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "item_kind_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_normalization.rs b/tests/ui-fulldeps/rustc_public/check_normalization.rs index aa6a257dac6d0..db9d3031600de 100644 --- a/tests/ui-fulldeps/rustc_public/check_normalization.rs +++ b/tests/ui-fulldeps/rustc_public/check_normalization.rs @@ -55,7 +55,7 @@ fn check_ty(ty: Ty) { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "normalization_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_trait_queries.rs b/tests/ui-fulldeps/rustc_public/check_trait_queries.rs index a6c37883643fa..0dd13044fcce8 100644 --- a/tests/ui-fulldeps/rustc_public/check_trait_queries.rs +++ b/tests/ui-fulldeps/rustc_public/check_trait_queries.rs @@ -67,7 +67,7 @@ fn assert_impl(impl_names: &HashSet, target: &str) { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "trait_queries.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_transform.rs b/tests/ui-fulldeps/rustc_public/check_transform.rs index 3209fcf9ede51..b30d98c3b26f5 100644 --- a/tests/ui-fulldeps/rustc_public/check_transform.rs +++ b/tests/ui-fulldeps/rustc_public/check_transform.rs @@ -115,7 +115,7 @@ fn get_item<'a>( /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "transform_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_ty_fold.rs b/tests/ui-fulldeps/rustc_public/check_ty_fold.rs index 07ef0d2bb50b3..93cd304934409 100644 --- a/tests/ui-fulldeps/rustc_public/check_ty_fold.rs +++ b/tests/ui-fulldeps/rustc_public/check_ty_fold.rs @@ -73,7 +73,7 @@ impl<'a> MirVisitor for PlaceVisitor<'a> { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "ty_fold_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/check_variant.rs b/tests/ui-fulldeps/rustc_public/check_variant.rs index ebe76bd89d5d4..9ed16f2357c0e 100644 --- a/tests/ui-fulldeps/rustc_public/check_variant.rs +++ b/tests/ui-fulldeps/rustc_public/check_variant.rs @@ -120,7 +120,7 @@ fn check_statement_is_aggregate_assign( /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "defs_ty_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/compilation-result.rs b/tests/ui-fulldeps/rustc_public/compilation-result.rs index ed013375c7135..d33e602e8191a 100644 --- a/tests/ui-fulldeps/rustc_public/compilation-result.rs +++ b/tests/ui-fulldeps/rustc_public/compilation-result.rs @@ -20,7 +20,7 @@ use std::io::Write; /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "input_compilation_result_test.rs"; diff --git a/tests/ui-fulldeps/rustc_public/crate-info.rs b/tests/ui-fulldeps/rustc_public/crate-info.rs index 4f46dff9b8204..19082d7394abe 100644 --- a/tests/ui-fulldeps/rustc_public/crate-info.rs +++ b/tests/ui-fulldeps/rustc_public/crate-info.rs @@ -189,7 +189,7 @@ fn get_item<'a>( /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/projections.rs b/tests/ui-fulldeps/rustc_public/projections.rs index 3b360cd2fcfff..e0213b4253c7f 100644 --- a/tests/ui-fulldeps/rustc_public/projections.rs +++ b/tests/ui-fulldeps/rustc_public/projections.rs @@ -141,7 +141,7 @@ fn get_item<'a>( /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/smir_internal.rs b/tests/ui-fulldeps/rustc_public/smir_internal.rs index dd70cfe5f5e6e..b74bdfe4eb194 100644 --- a/tests/ui-fulldeps/rustc_public/smir_internal.rs +++ b/tests/ui-fulldeps/rustc_public/smir_internal.rs @@ -34,7 +34,7 @@ fn test_translation(tcx: TyCtxt<'_>) -> ControlFlow<()> { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "internal_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/smir_serde.rs b/tests/ui-fulldeps/rustc_public/smir_serde.rs index 31642c6cb94c0..972bc5efe206c 100644 --- a/tests/ui-fulldeps/rustc_public/smir_serde.rs +++ b/tests/ui-fulldeps/rustc_public/smir_serde.rs @@ -41,7 +41,7 @@ fn serialize_to_json(_tcx: TyCtxt<'_>) -> ControlFlow<()> { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "internal_input.rs"; diff --git a/tests/ui-fulldeps/rustc_public/smir_visitor.rs b/tests/ui-fulldeps/rustc_public/smir_visitor.rs index 66787e2927bde..9438f46a59b5a 100644 --- a/tests/ui-fulldeps/rustc_public/smir_visitor.rs +++ b/tests/ui-fulldeps/rustc_public/smir_visitor.rs @@ -177,7 +177,7 @@ impl mir::MutMirVisitor for TestMutVisitor { /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// Then it will create a `StableMir` using custom arguments and then +/// Then it will create a `RustcPublic` using custom arguments and then /// it will run the compiler. fn main() { let path = "sim_visitor_input.rs"; From 20a7f722d824ebc4e733ec848d797088363624e9 Mon Sep 17 00:00:00 2001 From: Makai Date: Thu, 17 Jul 2025 15:49:51 +0000 Subject: [PATCH 10/10] fix `ui/rustc_public-ir-print` outputs --- tests/ui/rustc_public-ir-print/async-closure.stdout | 2 +- tests/ui/rustc_public-ir-print/basic_function.stdout | 2 +- tests/ui/rustc_public-ir-print/operands.stdout | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ui/rustc_public-ir-print/async-closure.stdout b/tests/ui/rustc_public-ir-print/async-closure.stdout index 3181129972204..4afb15af7a933 100644 --- a/tests/ui/rustc_public-ir-print/async-closure.stdout +++ b/tests/ui/rustc_public-ir-print/async-closure.stdout @@ -1,4 +1,4 @@ -// WARNING: This is highly experimental output it's intended for stable-mir developers only. +// WARNING: This is highly experimental output it's intended for rustc_public developers only. // If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir. fn foo() -> () { let mut _0: (); diff --git a/tests/ui/rustc_public-ir-print/basic_function.stdout b/tests/ui/rustc_public-ir-print/basic_function.stdout index 319d9c1dc6996..dc885e009e914 100644 --- a/tests/ui/rustc_public-ir-print/basic_function.stdout +++ b/tests/ui/rustc_public-ir-print/basic_function.stdout @@ -1,4 +1,4 @@ -// WARNING: This is highly experimental output it's intended for stable-mir developers only. +// WARNING: This is highly experimental output it's intended for rustc_public developers only. // If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir. fn foo(_1: i32) -> i32 { let mut _0: i32; diff --git a/tests/ui/rustc_public-ir-print/operands.stdout b/tests/ui/rustc_public-ir-print/operands.stdout index 37c5ec1a95e6e..a4b1c07f3a0b5 100644 --- a/tests/ui/rustc_public-ir-print/operands.stdout +++ b/tests/ui/rustc_public-ir-print/operands.stdout @@ -1,4 +1,4 @@ -// WARNING: This is highly experimental output it's intended for stable-mir developers only. +// WARNING: This is highly experimental output it's intended for rustc_public developers only. // If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir. fn operands(_1: u8) -> () { let mut _0: ();