diff options
| author | bors <bors@rust-lang.org> | 2020-01-17 15:58:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-17 15:58:24 +0000 |
| commit | 689fca01c5a1eac2d240bf08aa728171a28f2285 (patch) | |
| tree | 20c3e430ee7eac5254a495608ff233e9f4c7d74e /src/librustc_data_structures | |
| parent | 71c6346aa1afa5a0d246649d4919e11311e635f2 (diff) | |
| parent | 87a2896b0aa32343af271d430c1e9ce548e1ff1f (diff) | |
| download | rust-689fca01c5a1eac2d240bf08aa728171a28f2285.tar.gz rust-689fca01c5a1eac2d240bf08aa728171a28f2285.zip | |
Auto merge of #68311 - Dylan-DPC:rollup-wzgqw9t, r=Dylan-DPC
Rollup of 4 pull requests
Successful merges:
- #66564 (Document unsafe blocks in core::{cell, str, sync})
- #67791 (Implement Lift using interners instead of in_arena)
- #68278 ([self-profiler] Add example to `-Z help` to turn on query key recording)
- #68300 (Allow added string.insert benchmarks to compile)
Failed merges:
r? @ghost
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/profiling.rs | 2 | ||||
| -rw-r--r-- | src/librustc_data_structures/sharded.rs | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/librustc_data_structures/profiling.rs b/src/librustc_data_structures/profiling.rs index 004db0a79a8..44cef727f03 100644 --- a/src/librustc_data_structures/profiling.rs +++ b/src/librustc_data_structures/profiling.rs @@ -136,9 +136,11 @@ bitflags::bitflags! { } } +// keep this in sync with the `-Z self-profile-events` help message in librustc_session/options.rs const EVENT_FILTERS_BY_NAME: &[(&str, EventFilter)] = &[ ("none", EventFilter::NONE), ("all", EventFilter::ALL), + ("default", EventFilter::DEFAULT), ("generic-activity", EventFilter::GENERIC_ACTIVITIES), ("query-provider", EventFilter::QUERY_PROVIDERS), ("query-cache-hit", EventFilter::QUERY_CACHE_HITS), diff --git a/src/librustc_data_structures/sharded.rs b/src/librustc_data_structures/sharded.rs index 8b85d97a1d4..ee3f88ff167 100644 --- a/src/librustc_data_structures/sharded.rs +++ b/src/librustc_data_structures/sharded.rs @@ -137,6 +137,20 @@ impl<K: Eq + Hash + Copy> ShardedHashMap<K, ()> { } } +pub trait IntoPointer { + /// Returns a pointer which outlives `self`. + fn into_pointer(&self) -> *const (); +} + +impl<K: Eq + Hash + Copy + IntoPointer> ShardedHashMap<K, ()> { + pub fn contains_pointer_to<T: Hash + IntoPointer>(&self, value: &T) -> bool { + let hash = make_hash(&value); + let shard = self.get_shard_by_hash(hash).lock(); + let value = value.into_pointer(); + shard.raw_entry().from_hash(hash, |entry| entry.into_pointer() == value).is_some() + } +} + #[inline] fn make_hash<K: Hash + ?Sized>(val: &K) -> u64 { let mut state = FxHasher::default(); |
