Skip to content

Commit aa87845

Browse files
committed
SmirCtxt to CompilerCtxt, SmirInterface to CompilerInterface
aaa
1 parent e27f16a commit aa87845

File tree

15 files changed

+186
-186
lines changed

15 files changed

+186
-186
lines changed

compiler/rustc_public/src/alloc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_abi::Align;
88
use rustc_middle::mir::ConstValue;
99
use rustc_middle::mir::interpret::AllocRange;
1010
use rustc_public_bridge::bridge::SmirError;
11-
use rustc_public_bridge::context::SmirCtxt;
11+
use rustc_public_bridge::context::CompilerCtxt;
1212
use rustc_public_bridge::{Tables, alloc};
1313

1414
use super::Error;
@@ -35,7 +35,7 @@ pub(crate) fn new_allocation<'tcx>(
3535
ty: rustc_middle::ty::Ty<'tcx>,
3636
const_value: ConstValue<'tcx>,
3737
tables: &mut Tables<'tcx, BridgeTys>,
38-
cx: &SmirCtxt<'tcx, BridgeTys>,
38+
cx: &CompilerCtxt<'tcx, BridgeTys>,
3939
) -> Allocation {
4040
try_new_allocation(ty, const_value, tables, cx)
4141
.unwrap_or_else(|_| panic!("Failed to convert: {const_value:?} to {ty:?}"))
@@ -46,7 +46,7 @@ pub(crate) fn try_new_allocation<'tcx>(
4646
ty: rustc_middle::ty::Ty<'tcx>,
4747
const_value: ConstValue<'tcx>,
4848
tables: &mut Tables<'tcx, BridgeTys>,
49-
cx: &SmirCtxt<'tcx, BridgeTys>,
49+
cx: &CompilerCtxt<'tcx, BridgeTys>,
5050
) -> Result<Allocation, Error> {
5151
let layout = alloc::create_ty_and_layout(cx, ty).map_err(|e| Error::from_internal(e))?;
5252
match const_value {
@@ -70,7 +70,7 @@ pub(super) fn allocation_filter<'tcx>(
7070
alloc: &rustc_middle::mir::interpret::Allocation,
7171
alloc_range: AllocRange,
7272
tables: &mut Tables<'tcx, BridgeTys>,
73-
cx: &SmirCtxt<'tcx, BridgeTys>,
73+
cx: &CompilerCtxt<'tcx, BridgeTys>,
7474
) -> Allocation {
7575
alloc::allocation_filter(alloc, alloc_range, tables, cx)
7676
}

compiler/rustc_public/src/compiler_interface.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use std::cell::Cell;
77

88
use rustc_hir::def::DefKind;
9-
use rustc_public_bridge::context::SmirCtxt;
9+
use rustc_public_bridge::context::CompilerCtxt;
1010
use rustc_public_bridge::{Bridge, SmirContainer};
1111
use tracing::debug;
1212

@@ -66,13 +66,13 @@ impl Bridge for BridgeTys {
6666
type Allocation = crate::ty::Allocation;
6767
}
6868

69-
/// Stable public API for querying compiler information.
69+
/// Public API for querying compiler information.
7070
///
71-
/// All queries are delegated to [`rustc_public_bridge::context::SmirCtxt`] that provides
71+
/// All queries are delegated to [`rustc_public_bridge::context::CompilerCtxt`] that provides
7272
/// similar APIs but based on internal rustc constructs.
7373
///
7474
/// Do not use this directly. This is currently used in the macro expansion.
75-
pub(crate) trait SmirInterface {
75+
pub(crate) trait CompilerInterface {
7676
fn entry_fn(&self) -> Option<CrateItem>;
7777
/// Retrieve all items of the local crate that have a MIR associated with them.
7878
fn all_local_items(&self) -> CrateItems;
@@ -316,7 +316,7 @@ pub(crate) trait SmirInterface {
316316
fn associated_items(&self, def_id: DefId) -> AssocItems;
317317
}
318318

319-
impl<'tcx> SmirInterface for SmirContainer<'tcx, BridgeTys> {
319+
impl<'tcx> CompilerInterface for SmirContainer<'tcx, BridgeTys> {
320320
fn entry_fn(&self) -> Option<CrateItem> {
321321
let mut tables = self.tables.borrow_mut();
322322
let cx = &*self.cx.borrow();
@@ -1059,10 +1059,10 @@ impl<'tcx> SmirInterface for SmirContainer<'tcx, BridgeTys> {
10591059
}
10601060
}
10611061

1062-
// A thread local variable that stores a pointer to [`SmirInterface`].
1062+
// A thread local variable that stores a pointer to [`CompilerInterface`].
10631063
scoped_tls::scoped_thread_local!(static TLV: Cell<*const ()>);
10641064

1065-
pub(crate) fn run<F, T>(interface: &dyn SmirInterface, f: F) -> Result<T, Error>
1065+
pub(crate) fn run<F, T>(interface: &dyn CompilerInterface, f: F) -> Result<T, Error>
10661066
where
10671067
F: FnOnce() -> T,
10681068
{
@@ -1074,21 +1074,21 @@ where
10741074
}
10751075
}
10761076

1077-
/// Execute the given function with access the [`SmirInterface`].
1077+
/// Execute the given function with access the [`CompilerInterface`].
10781078
///
10791079
/// I.e., This function will load the current interface and calls a function with it.
10801080
/// Do not nest these, as that will ICE.
1081-
pub(crate) fn with<R>(f: impl FnOnce(&dyn SmirInterface) -> R) -> R {
1081+
pub(crate) fn with<R>(f: impl FnOnce(&dyn CompilerInterface) -> R) -> R {
10821082
assert!(TLV.is_set());
10831083
TLV.with(|tlv| {
10841084
let ptr = tlv.get();
10851085
assert!(!ptr.is_null());
1086-
f(unsafe { *(ptr as *const &dyn SmirInterface) })
1086+
f(unsafe { *(ptr as *const &dyn CompilerInterface) })
10871087
})
10881088
}
10891089

10901090
fn smir_crate<'tcx>(
1091-
cx: &SmirCtxt<'tcx, BridgeTys>,
1091+
cx: &CompilerCtxt<'tcx, BridgeTys>,
10921092
crate_num: rustc_span::def_id::CrateNum,
10931093
) -> Crate {
10941094
let name = cx.crate_name(crate_num);

compiler/rustc_public/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::{fmt, io};
2424

2525
pub(crate) use rustc_public_bridge::IndexedVal;
2626
use rustc_public_bridge::Tables;
27-
use rustc_public_bridge::context::SmirCtxt;
27+
use rustc_public_bridge::context::CompilerCtxt;
2828
/// Export the rustc_internal APIs. Note that this module has no stability
2929
/// guarantees and it is not taken into account for semver.
3030
#[cfg(feature = "rustc_internal")]
@@ -288,7 +288,7 @@ impl rustc_public_bridge::bridge::Allocation<compiler_interface::BridgeTys>
288288
align: u64,
289289
mutability: rustc_middle::mir::Mutability,
290290
tables: &mut Tables<'tcx, compiler_interface::BridgeTys>,
291-
cx: &SmirCtxt<'tcx, compiler_interface::BridgeTys>,
291+
cx: &CompilerCtxt<'tcx, compiler_interface::BridgeTys>,
292292
) -> Self {
293293
Self {
294294
bytes,

compiler/rustc_public/src/rustc_internal/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use std::cell::{Cell, RefCell};
77

88
use rustc_middle::ty::TyCtxt;
9-
use rustc_public_bridge::context::SmirCtxt;
9+
use rustc_public_bridge::context::CompilerCtxt;
1010
use rustc_public_bridge::{Bridge, SmirContainer, Tables};
1111
use rustc_span::def_id::CrateNum;
1212
use scoped_tls::scoped_thread_local;
@@ -72,7 +72,7 @@ where
7272
/// Loads the current context and calls a function with it.
7373
/// Do not nest these, as that will ICE.
7474
pub(crate) fn with_container<R, B: Bridge>(
75-
f: impl for<'tcx> FnOnce(&mut Tables<'tcx, B>, &SmirCtxt<'tcx, B>) -> R,
75+
f: impl for<'tcx> FnOnce(&mut Tables<'tcx, B>, &CompilerCtxt<'tcx, B>) -> R,
7676
) -> R {
7777
assert!(TLV.is_set());
7878
TLV.with(|tlv| {
@@ -89,8 +89,8 @@ pub fn run<F, T>(tcx: TyCtxt<'_>, f: F) -> Result<T, Error>
8989
where
9090
F: FnOnce() -> T,
9191
{
92-
let smir_cx = RefCell::new(SmirCtxt::new(tcx));
93-
let container = SmirContainer { tables: RefCell::new(Tables::default()), cx: smir_cx };
92+
let compiler_cx = RefCell::new(CompilerCtxt::new(tcx));
93+
let container = SmirContainer { tables: RefCell::new(Tables::default()), cx: compiler_cx };
9494

9595
crate::compiler_interface::run(&container, || init(&container, f))
9696
}

compiler/rustc_public/src/unstable/convert/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use std::ops::RangeInclusive;
1010

1111
use rustc_public_bridge::Tables;
12-
use rustc_public_bridge::context::SmirCtxt;
12+
use rustc_public_bridge::context::CompilerCtxt;
1313

1414
use super::Stable;
1515
use crate::compiler_interface::BridgeTys;
@@ -26,7 +26,7 @@ where
2626
fn stable<'cx>(
2727
&self,
2828
tables: &mut Tables<'cx, BridgeTys>,
29-
cx: &SmirCtxt<'cx, BridgeTys>,
29+
cx: &CompilerCtxt<'cx, BridgeTys>,
3030
) -> Self::T {
3131
(*self).stable(tables, cx)
3232
}
@@ -41,7 +41,7 @@ where
4141
fn stable<'cx>(
4242
&self,
4343
tables: &mut Tables<'cx, BridgeTys>,
44-
cx: &SmirCtxt<'cx, BridgeTys>,
44+
cx: &CompilerCtxt<'cx, BridgeTys>,
4545
) -> Self::T {
4646
self.as_ref().map(|value| value.stable(tables, cx))
4747
}
@@ -57,7 +57,7 @@ where
5757
fn stable<'cx>(
5858
&self,
5959
tables: &mut Tables<'cx, BridgeTys>,
60-
cx: &SmirCtxt<'cx, BridgeTys>,
60+
cx: &CompilerCtxt<'cx, BridgeTys>,
6161
) -> Self::T {
6262
match self {
6363
Ok(val) => Ok(val.stable(tables, cx)),
@@ -74,7 +74,7 @@ where
7474
fn stable<'cx>(
7575
&self,
7676
tables: &mut Tables<'cx, BridgeTys>,
77-
cx: &SmirCtxt<'cx, BridgeTys>,
77+
cx: &CompilerCtxt<'cx, BridgeTys>,
7878
) -> Self::T {
7979
self.iter().map(|e| e.stable(tables, cx)).collect()
8080
}
@@ -89,7 +89,7 @@ where
8989
fn stable<'cx>(
9090
&self,
9191
tables: &mut Tables<'cx, BridgeTys>,
92-
cx: &SmirCtxt<'cx, BridgeTys>,
92+
cx: &CompilerCtxt<'cx, BridgeTys>,
9393
) -> Self::T {
9494
(self.0.stable(tables, cx), self.1.stable(tables, cx))
9595
}
@@ -103,7 +103,7 @@ where
103103
fn stable<'cx>(
104104
&self,
105105
tables: &mut Tables<'cx, BridgeTys>,
106-
cx: &SmirCtxt<'cx, BridgeTys>,
106+
cx: &CompilerCtxt<'cx, BridgeTys>,
107107
) -> Self::T {
108108
RangeInclusive::new(self.start().stable(tables, cx), self.end().stable(tables, cx))
109109
}

0 commit comments

Comments
 (0)