diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index a2adecd96367e..e79ecdd959cd9 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -9,7 +9,7 @@ use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintLevelSource}; use crate::middle; 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; @@ -1047,10 +1047,6 @@ pub struct GlobalCtxt<'tcx> { pub(crate) alloc_map: Lock>, output_filenames: Arc, - - // FIXME(eddyb) this doesn't belong here and should be using a query. - pub(super) vtables_cache: - Lock, Option>), AllocId>>, } impl<'tcx> TyCtxt<'tcx> { @@ -1189,7 +1185,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(), } } diff --git a/compiler/rustc_middle/src/ty/vtable.rs b/compiler/rustc_middle/src/ty/vtable.rs index 5904f133e78c3..967149dc53c1a 100644 --- a/compiler/rustc_middle/src/ty/vtable.rs +++ b/compiler/rustc_middle/src/ty/vtable.rs @@ -52,11 +52,6 @@ impl<'tcx> TyCtxt<'tcx> { poly_trait_ref: Option>, ) -> 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)) } } diff --git a/src/test/incremental/reorder_vtable.rs b/src/test/incremental/reorder_vtable.rs new file mode 100644 index 0000000000000..a550fe6f01c19 --- /dev/null +++ b/src/test/incremental/reorder_vtable.rs @@ -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() + } +}