about summary refs log tree commit diff
path: root/compiler/rustc_smir/src/rustc_internal/mod.rs
diff options
context:
space:
mode:
authorCelina G. Val <celinval@amazon.com>2023-10-19 17:06:53 -0700
committerCelina G. Val <celinval@amazon.com>2023-10-19 17:12:26 -0700
commit6ed2a76bcc2a963c28080d6ee3ad928ec9367a03 (patch)
tree8bb460c975fdab978c539884f4388b14b9b2e8ed /compiler/rustc_smir/src/rustc_internal/mod.rs
parentcc705b801236d064260bb67b3a0a25e4747fa7ec (diff)
downloadrust-6ed2a76bcc2a963c28080d6ee3ad928ec9367a03.tar.gz
rust-6ed2a76bcc2a963c28080d6ee3ad928ec9367a03.zip
Add stable Instance::body() and RustcInternal trait
The `Instance::body()` returns a monomorphized body.

For that, we had to implement visitor that monomorphize types and
constants. We are also introducing the RustcInternal trait that will
allow us to convert back from Stable to Internal.

Note that this trait is not yet visible for our users as it depends on
Tables. We should probably add a new trait that can be exposed.
Diffstat (limited to 'compiler/rustc_smir/src/rustc_internal/mod.rs')
-rw-r--r--compiler/rustc_smir/src/rustc_internal/mod.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_smir/src/rustc_internal/mod.rs b/compiler/rustc_smir/src/rustc_internal/mod.rs
index 5ea805e5739..473a59f750a 100644
--- a/compiler/rustc_smir/src/rustc_internal/mod.rs
+++ b/compiler/rustc_smir/src/rustc_internal/mod.rs
@@ -20,6 +20,8 @@ use std::fmt::Debug;
 use std::hash::Hash;
 use std::ops::{ControlFlow, Index};
 
+mod internal;
+
 impl<'tcx> Index<stable_mir::DefId> for Tables<'tcx> {
     type Output = DefId;
 
@@ -231,3 +233,11 @@ impl<K: PartialEq + Hash + Eq, V: Copy + Debug + PartialEq + IndexedVal> Index<V
         k
     }
 }
+
+/// Trait used to translate a stable construct to its rustc counterpart.
+///
+/// This is basically a mirror of [crate::rustc_smir::Stable].
+pub(crate) trait RustcInternal<'tcx> {
+    type T;
+    fn internal(&self, tables: &mut Tables<'tcx>) -> Self::T;
+}