about summary refs log tree commit diff
path: root/compiler/rustc_public_bridge/src
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_public_bridge/src')
-rw-r--r--compiler/rustc_public_bridge/src/alloc.rs21
-rw-r--r--compiler/rustc_public_bridge/src/bridge.rs6
-rw-r--r--compiler/rustc_public_bridge/src/builder.rs7
-rw-r--r--compiler/rustc_public_bridge/src/context/helpers.rs (renamed from compiler/rustc_public_bridge/src/context/traits.rs)8
-rw-r--r--compiler/rustc_public_bridge/src/context/impls.rs25
-rw-r--r--compiler/rustc_public_bridge/src/context/mod.rs26
-rw-r--r--compiler/rustc_public_bridge/src/lib.rs14
7 files changed, 51 insertions, 56 deletions
diff --git a/compiler/rustc_public_bridge/src/alloc.rs b/compiler/rustc_public_bridge/src/alloc.rs
index 23bbaddce06..7e6af342546 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`
@@ -10,22 +10,22 @@ 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};
+use crate::{Bridge, Error};
 
 pub fn create_ty_and_layout<'tcx, B: Bridge>(
-    cx: &SmirCtxt<'tcx, B>,
+    cx: &CompilerCtxt<'tcx, B>,
     ty: Ty<'tcx>,
 ) -> Result<TyAndLayout<'tcx, Ty<'tcx>>, &'tcx layout::LayoutError<'tcx>> {
-    use crate::context::SmirTypingEnv;
+    use crate::context::TypingEnvHelpers;
     cx.tcx.layout_of(cx.fully_monomorphized().as_query_input(ty))
 }
 
 pub fn try_new_scalar<'tcx, B: Bridge>(
     layout: TyAndLayout<'tcx, Ty<'tcx>>,
     scalar: Scalar,
-    cx: &SmirCtxt<'tcx, B>,
+    cx: &CompilerCtxt<'tcx, B>,
 ) -> Result<Allocation, B::Error> {
     let size = scalar.size();
     let mut allocation = Allocation::new(size, layout.align.abi, AllocInit::Uninit, ());
@@ -38,11 +38,10 @@ pub fn try_new_scalar<'tcx, B: Bridge>(
 
 pub fn try_new_slice<'tcx, B: Bridge>(
     layout: TyAndLayout<'tcx, Ty<'tcx>>,
-    data: ConstAllocation<'tcx>,
+    alloc_id: AllocId,
     meta: u64,
-    cx: &SmirCtxt<'tcx, B>,
+    cx: &CompilerCtxt<'tcx, B>,
 ) -> Result<Allocation, B::Error> {
-    let alloc_id = cx.tcx.reserve_and_set_memory_alloc(data);
     let ptr = Pointer::new(alloc_id.into(), Size::ZERO);
     let scalar_ptr = Scalar::from_pointer(ptr, &cx.tcx);
     let scalar_meta: Scalar = Scalar::from_target_usize(meta, &cx.tcx);
@@ -60,7 +59,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 +71,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<Option<u8>> = 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 379a8da5df9..d4f4847c8d3 100644
--- a/compiler/rustc_public_bridge/src/bridge.rs
+++ b/compiler/rustc_public_bridge/src/bridge.rs
@@ -6,10 +6,10 @@
 
 use std::fmt::Debug;
 
-use super::context::SmirCtxt;
+use super::context::CompilerCtxt;
 use super::{Bridge, Tables};
 
-pub trait SmirError {
+pub trait Error {
     fn new(msg: String) -> Self;
     fn from_internal<T: Debug>(err: T) -> Self;
 }
@@ -25,7 +25,7 @@ pub trait Allocation<B: Bridge> {
         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/builder.rs b/compiler/rustc_public_bridge/src/builder.rs
index 2141053d09a..ea7f37d72d0 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/traits.rs b/compiler/rustc_public_bridge/src/context/helpers.rs
index 8483bee4aad..21eef29e5f1 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 fdefad2821b..9b3948d232d 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)]
 
@@ -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::{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> SmirTy<'tcx> for SmirCtxt<'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 SmirCtxt<'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 SmirCtxt<'tcx, B> {
+impl<'tcx, B: Bridge> AllocRangeHelpers<'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<T: ty::Lift<TyCtxt<'tcx>>>(&self, value: T) -> Option<T::Lifted> {
         self.tcx.lift(value)
     }
@@ -63,7 +63,7 @@ impl<'tcx, B: Bridge> SmirCtxt<'tcx, B> {
         self.tcx.coroutine_movability(def_id)
     }
 
-    pub fn valtree_to_const_val(&self, key: ty::Value<'tcx>) -> ConstValue<'tcx> {
+    pub fn valtree_to_const_val(&self, key: ty::Value<'tcx>) -> ConstValue {
         self.tcx.valtree_to_const_val(key)
     }
 
@@ -85,7 +85,7 @@ impl<'tcx, B: Bridge> SmirCtxt<'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
@@ -426,7 +426,7 @@ impl<'tcx, B: Bridge> SmirCtxt<'tcx, B> {
 
     /// Evaluate constant as a target usize.
     pub fn eval_target_usize(&self, cnst: MirConst<'tcx>) -> Result<u64, B::Error> {
-        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")))
     }
@@ -675,10 +675,7 @@ impl<'tcx, B: Bridge> SmirCtxt<'tcx, B> {
     }
 
     /// Try to evaluate an instance into a constant.
-    pub fn eval_instance(
-        &self,
-        instance: ty::Instance<'tcx>,
-    ) -> Result<ConstValue<'tcx>, ErrorHandled> {
+    pub fn eval_instance(&self, instance: ty::Instance<'tcx>) -> Result<ConstValue, ErrorHandled> {
         self.tcx.const_eval_instance(
             self.fully_monomorphized(),
             instance,
diff --git a/compiler/rustc_public_bridge/src/context/mod.rs b/compiler/rustc_public_bridge/src/context/mod.rs
index da20be2a4b3..857a2d4e26b 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)]
 
@@ -9,30 +9,30 @@ 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 helpers;
 mod impls;
-mod traits;
 
-pub use traits::*;
+pub use helpers::*;
 
 /// Provides direct access to rustc's internal queries.
 ///
-/// `SmirInterface` must go through
-/// this context to obtain rustc-level information.
-pub struct SmirCtxt<'tcx, B: Bridge> {
+/// `CompilerInterface` must go through
+/// this context to obtain internal information.
+pub struct CompilerCtxt<'tcx, B: Bridge> {
     pub tcx: TyCtxt<'tcx>,
     _marker: PhantomData<B>,
 }
 
-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<ty::layout::TyAndLayout<'tcx>, 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 652a8093a87..dec3be70baf 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.
@@ -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;
@@ -46,9 +46,9 @@ 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<Tables<'tcx, B>>,
-    pub cx: RefCell<SmirCtxt<'tcx, B>>,
+    pub cx: RefCell<CompilerCtxt<'tcx, B>>,
 }
 
 pub struct Tables<'tcx, B: Bridge> {
@@ -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;
@@ -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<Self>;
     type AdtDef: AdtDef<Self>;
     type ForeignModuleDef: ForeignModuleDef<Self>;