Remove untracked vtable-const-allocation cache from tcx
(cherry picked from commit a1e2c0f0ad)
This commit is contained in:
parent
7b7bdc06bb
commit
cb8ea8ca2d
3 changed files with 29 additions and 14 deletions
|
|
@ -10,7 +10,7 @@ use crate::middle;
|
|||
use crate::middle::cstore::EncodedMetadata;
|
||||
use crate::middle::resolve_lifetime::{self, LifetimeScopeForPath, ObjectLifetimeDefault};
|
||||
use crate::middle::stability;
|
||||
use crate::mir::interpret::{self, AllocId, Allocation, ConstValue, Scalar};
|
||||
use crate::mir::interpret::{self, Allocation, ConstValue, Scalar};
|
||||
use crate::mir::{Body, Field, Local, Place, PlaceElem, ProjectionKind, Promoted};
|
||||
use crate::thir::Thir;
|
||||
use crate::traits;
|
||||
|
|
@ -1062,9 +1062,6 @@ pub struct GlobalCtxt<'tcx> {
|
|||
layout_interner: ShardedHashMap<&'tcx Layout, ()>,
|
||||
|
||||
output_filenames: Arc<OutputFilenames>,
|
||||
|
||||
pub(super) vtables_cache:
|
||||
Lock<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), AllocId>>,
|
||||
}
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
|
|
@ -1212,7 +1209,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
const_stability_interner: Default::default(),
|
||||
alloc_map: Lock::new(interpret::AllocMap::new()),
|
||||
output_filenames: Arc::new(output_filenames),
|
||||
vtables_cache: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,11 +52,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
||||
) -> AllocId {
|
||||
let tcx = self;
|
||||
let vtables_cache = tcx.vtables_cache.lock();
|
||||
if let Some(alloc_id) = vtables_cache.get(&(ty, poly_trait_ref)).cloned() {
|
||||
return alloc_id;
|
||||
}
|
||||
drop(vtables_cache);
|
||||
|
||||
let vtable_entries = if let Some(poly_trait_ref) = poly_trait_ref {
|
||||
let trait_ref = poly_trait_ref.with_self_ty(tcx, ty);
|
||||
|
|
@ -119,9 +114,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
vtable.mutability = Mutability::Not;
|
||||
let alloc_id = tcx.create_memory_alloc(tcx.intern_const_alloc(vtable));
|
||||
let mut vtables_cache = self.vtables_cache.lock();
|
||||
vtables_cache.insert((ty, poly_trait_ref), alloc_id);
|
||||
alloc_id
|
||||
tcx.create_memory_alloc(tcx.intern_const_alloc(vtable))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
src/test/incremental/reorder_vtable.rs
Normal file
27
src/test/incremental/reorder_vtable.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// revisions:rpass1 rpass2
|
||||
|
||||
trait Foo {
|
||||
#[cfg(rpass1)]
|
||||
fn method1(&self) -> u32;
|
||||
|
||||
fn method2(&self) -> u32;
|
||||
|
||||
#[cfg(rpass2)]
|
||||
fn method1(&self) -> u32;
|
||||
}
|
||||
|
||||
impl Foo for u32 {
|
||||
fn method1(&self) -> u32 { 17 }
|
||||
fn method2(&self) -> u32 { 42 }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: &dyn Foo = &0u32;
|
||||
assert_eq!(mod1::foo(x), 17);
|
||||
}
|
||||
|
||||
mod mod1 {
|
||||
pub fn foo(x: &dyn super::Foo) -> u32 {
|
||||
x.method1()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue