Skip to content

Commit a1e2c0f

Browse files
Remove untracked vtable-const-allocation cache from tcx
1 parent a479766 commit a1e2c0f

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintLevelSource};
99
use crate::middle;
1010
use crate::middle::resolve_lifetime::{self, LifetimeScopeForPath, ObjectLifetimeDefault};
1111
use crate::middle::stability;
12-
use crate::mir::interpret::{self, AllocId, Allocation, ConstValue, Scalar};
12+
use crate::mir::interpret::{self, Allocation, ConstValue, Scalar};
1313
use crate::mir::{Body, Field, Local, Place, PlaceElem, ProjectionKind, Promoted};
1414
use crate::thir::Thir;
1515
use crate::traits;
@@ -1047,10 +1047,6 @@ pub struct GlobalCtxt<'tcx> {
10471047
pub(crate) alloc_map: Lock<interpret::AllocMap<'tcx>>,
10481048

10491049
output_filenames: Arc<OutputFilenames>,
1050-
1051-
// FIXME(eddyb) this doesn't belong here and should be using a query.
1052-
pub(super) vtables_cache:
1053-
Lock<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), AllocId>>,
10541050
}
10551051

10561052
impl<'tcx> TyCtxt<'tcx> {
@@ -1189,7 +1185,6 @@ impl<'tcx> TyCtxt<'tcx> {
11891185
const_stability_interner: Default::default(),
11901186
alloc_map: Lock::new(interpret::AllocMap::new()),
11911187
output_filenames: Arc::new(output_filenames),
1192-
vtables_cache: Default::default(),
11931188
}
11941189
}
11951190

compiler/rustc_middle/src/ty/vtable.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ impl<'tcx> TyCtxt<'tcx> {
5252
poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
5353
) -> AllocId {
5454
let tcx = self;
55-
let vtables_cache = tcx.vtables_cache.lock();
56-
if let Some(alloc_id) = vtables_cache.get(&(ty, poly_trait_ref)).cloned() {
57-
return alloc_id;
58-
}
59-
drop(vtables_cache);
6055

6156
let vtable_entries = if let Some(poly_trait_ref) = poly_trait_ref {
6257
let trait_ref = poly_trait_ref.with_self_ty(tcx, ty);
@@ -119,9 +114,6 @@ impl<'tcx> TyCtxt<'tcx> {
119114
}
120115

121116
vtable.mutability = Mutability::Not;
122-
let alloc_id = tcx.create_memory_alloc(tcx.intern_const_alloc(vtable));
123-
let mut vtables_cache = self.vtables_cache.lock();
124-
vtables_cache.insert((ty, poly_trait_ref), alloc_id);
125-
alloc_id
117+
tcx.create_memory_alloc(tcx.intern_const_alloc(vtable))
126118
}
127119
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// revisions:rpass1 rpass2
2+
3+
trait Foo {
4+
#[cfg(rpass1)]
5+
fn method1(&self) -> u32;
6+
7+
fn method2(&self) -> u32;
8+
9+
#[cfg(rpass2)]
10+
fn method1(&self) -> u32;
11+
}
12+
13+
impl Foo for u32 {
14+
fn method1(&self) -> u32 { 17 }
15+
fn method2(&self) -> u32 { 42 }
16+
}
17+
18+
fn main() {
19+
let x: &dyn Foo = &0u32;
20+
assert_eq!(mod1::foo(x), 17);
21+
}
22+
23+
mod mod1 {
24+
pub fn foo(x: &dyn super::Foo) -> u32 {
25+
x.method1()
26+
}
27+
}

0 commit comments

Comments
 (0)