diff options
| author | Celina G. Val <celinval@amazon.com> | 2023-11-17 08:05:40 -0800 |
|---|---|---|
| committer | Celina G. Val <celinval@amazon.com> | 2023-11-21 19:16:58 -0800 |
| commit | 5b3cf6610b7c94d5eea715386946ba0bf564690e (patch) | |
| tree | fba1f6930bc8b415080c450d1dc9d4f5987e439a /compiler/stable_mir/src/mir | |
| parent | fa5ff859e610b46b924ac17df63de69c734759f8 (diff) | |
| download | rust-5b3cf6610b7c94d5eea715386946ba0bf564690e.tar.gz rust-5b3cf6610b7c94d5eea715386946ba0bf564690e.zip | |
Add support to get virtual table allocation
Diffstat (limited to 'compiler/stable_mir/src/mir')
| -rw-r--r-- | compiler/stable_mir/src/mir/alloc.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/stable_mir/src/mir/alloc.rs b/compiler/stable_mir/src/mir/alloc.rs index ca24653585c..ef9053b78ec 100644 --- a/compiler/stable_mir/src/mir/alloc.rs +++ b/compiler/stable_mir/src/mir/alloc.rs @@ -9,6 +9,7 @@ pub enum GlobalAlloc { /// The alloc ID is used as a function pointer. Function(Instance), /// This alloc ID points to a symbolic (not-reified) vtable. + /// The `None` trait ref is used to represent auto traits. VTable(Ty, Option<Binder<ExistentialTraitRef>>), /// The alloc ID points to a "lazy" static variable that did not get computed (yet). /// This is also used to break the cycle in recursive statics. @@ -23,6 +24,12 @@ impl From<AllocId> for GlobalAlloc { } } +impl GlobalAlloc { + pub fn vtable_allocation(&self) -> Option<AllocId> { + with(|cx| cx.vtable_allocation(self)) + } +} + /// A unique identification number for each provenance #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub struct AllocId(usize); |
