Skip to content

Commit

Permalink
add RawList
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Markeffsky committed Apr 6, 2024
1 parent fcc477f commit 94d61d8
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 255 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/context.rs
Expand Up @@ -1875,7 +1875,7 @@ macro_rules! slice_interners {
List::empty()
} else {
self.interners.$field.intern_ref(v, || {
InternedInSet(List::from_arena(&*self.arena, v))
InternedInSet(List::from_arena(&*self.arena, (), v))
}).0
}
})+
Expand Down
19 changes: 5 additions & 14 deletions compiler/rustc_middle/src/ty/impls_ty.rs
Expand Up @@ -11,19 +11,20 @@ use rustc_data_structures::stable_hasher::HashingControls;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
use rustc_query_system::ich::StableHashingContext;
use std::cell::RefCell;
use std::ptr;

impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for &'tcx ty::List<T>
impl<'a, 'tcx, H, T> HashStable<StableHashingContext<'a>> for &'tcx ty::list::RawList<H, T>
where
T: HashStable<StableHashingContext<'a>>,
{
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
thread_local! {
static CACHE: RefCell<FxHashMap<(usize, usize, HashingControls), Fingerprint>> =
static CACHE: RefCell<FxHashMap<(*const (), HashingControls), Fingerprint>> =
RefCell::new(Default::default());
}

let hash = CACHE.with(|cache| {
let key = (self.as_ptr() as usize, self.len(), hcx.hashing_controls());
let key = (ptr::from_ref(*self).cast::<()>(), hcx.hashing_controls());
if let Some(&hash) = cache.borrow().get(&key) {
return hash;
}
Expand All @@ -40,7 +41,7 @@ where
}
}

impl<'a, 'tcx, T> ToStableHashKey<StableHashingContext<'a>> for &'tcx ty::List<T>
impl<'a, 'tcx, H, T> ToStableHashKey<StableHashingContext<'a>> for &'tcx ty::list::RawList<H, T>
where
T: HashStable<StableHashingContext<'a>>,
{
Expand All @@ -55,16 +56,6 @@ where
}
}

impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for &'tcx ty::ListWithCachedTypeInfo<T>
where
T: HashStable<StableHashingContext<'a>>,
{
#[inline]
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
self.as_list().hash_stable(hcx, hasher);
}
}

impl<'a> ToStableHashKey<StableHashingContext<'a>> for SimplifiedType {
type KeyType = Fingerprint;

Expand Down

0 comments on commit 94d61d8

Please sign in to comment.