diff options
Diffstat (limited to 'compiler/rustc_public/src/compiler_interface.rs')
| -rw-r--r-- | compiler/rustc_public/src/compiler_interface.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/compiler/rustc_public/src/compiler_interface.rs b/compiler/rustc_public/src/compiler_interface.rs index d15438c2b80..5a09c3b24f0 100644 --- a/compiler/rustc_public/src/compiler_interface.rs +++ b/compiler/rustc_public/src/compiler_interface.rs @@ -1,13 +1,13 @@ //! 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; use rustc_hir::def::DefKind; -use rustc_public_bridge::context::SmirCtxt; -use rustc_public_bridge::{Bridge, SmirContainer}; +use rustc_public_bridge::context::CompilerCtxt; +use rustc_public_bridge::{Bridge, Container}; use tracing::debug; use crate::abi::{FnAbi, Layout, LayoutShape, ReprOptions}; @@ -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<CrateItem>; /// 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 Container<'tcx, BridgeTys> { fn entry_fn(&self) -> Option<CrateItem> { let mut tables = self.tables.borrow_mut(); let cx = &*self.cx.borrow(); @@ -567,7 +567,7 @@ impl<'tcx> SmirInterface for SmirContainer<'tcx, BridgeTys> { DefKind::Fn => ForeignItemKind::Fn(tables.fn_def(def_id)), DefKind::Static { .. } => ForeignItemKind::Static(tables.static_def(def_id)), DefKind::ForeignTy => { - use rustc_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), @@ -1059,36 +1059,36 @@ 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<F, T>(interface: &dyn SmirInterface, f: F) -> Result<T, Error> +pub(crate) fn run<F, T>(interface: &dyn CompilerInterface, f: F) -> Result<T, Error> 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())) } } -/// 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<R>(f: impl FnOnce(&dyn SmirInterface) -> R) -> R { +pub(crate) fn with<R>(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); |
