Skip to content

Commit 2737780

Browse files
committed
Remove StableVec.
1 parent e291be3 commit 2737780

File tree

6 files changed

+8
-41
lines changed

6 files changed

+8
-41
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use rustc_ast::{self as ast, *};
4444
use rustc_ast_pretty::pprust;
4545
use rustc_data_structures::captures::Captures;
4646
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
47-
use rustc_data_structures::stable_hasher::StableVec;
4847
use rustc_data_structures::sync::Lrc;
4948
use rustc_errors::{struct_span_err, Applicability};
5049
use rustc_hir as hir;
@@ -506,7 +505,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
506505
for (k, v) in self.resolver.trait_map().into_iter() {
507506
if let Some(Some(hir_id)) = self.node_id_to_hir_id.get(k) {
508507
let map = trait_map.entry(hir_id.owner).or_default();
509-
map.insert(hir_id.local_id, StableVec::new(v.to_vec()));
508+
map.insert(hir_id.local_id, v.into_boxed_slice());
510509
}
511510
}
512511

compiler/rustc_data_structures/src/stable_hasher.rs

-32
Original file line numberDiff line numberDiff line change
@@ -550,35 +550,3 @@ pub fn hash_stable_hashmap<HCX, K, V, R, SK, F>(
550550
entries.sort_unstable_by(|&(ref sk1, _), &(ref sk2, _)| sk1.cmp(sk2));
551551
entries.hash_stable(hcx, hasher);
552552
}
553-
554-
/// A vector container that makes sure that its items are hashed in a stable
555-
/// order.
556-
#[derive(Debug)]
557-
pub struct StableVec<T>(Vec<T>);
558-
559-
impl<T> StableVec<T> {
560-
pub fn new(v: Vec<T>) -> Self {
561-
StableVec(v)
562-
}
563-
}
564-
565-
impl<T> ::std::ops::Deref for StableVec<T> {
566-
type Target = Vec<T>;
567-
568-
fn deref(&self) -> &Vec<T> {
569-
&self.0
570-
}
571-
}
572-
573-
impl<T, HCX> HashStable<HCX> for StableVec<T>
574-
where
575-
T: HashStable<HCX> + ToStableHashKey<HCX>,
576-
{
577-
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
578-
let StableVec(ref v) = *self;
579-
580-
let mut sorted: Vec<_> = v.iter().map(|x| x.to_stable_hash_key(hcx)).collect();
581-
sorted.sort_unstable();
582-
sorted.hash_stable(hcx, hasher);
583-
}
584-
}

compiler/rustc_hir/src/hir.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub use rustc_ast::{BorrowKind, ImplPolarity, IsAuto};
1111
pub use rustc_ast::{CaptureBy, Movability, Mutability};
1212
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
1313
use rustc_data_structures::fx::FxHashMap;
14-
use rustc_data_structures::stable_hasher::StableVec;
1514
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
1615
use rustc_macros::HashStable_Generic;
1716
use rustc_span::source_map::Spanned;
@@ -662,7 +661,7 @@ pub struct Crate<'hir> {
662661

663662
/// Map indicating what traits are in scope for places where this
664663
/// is relevant; generated by resolve.
665-
pub trait_map: FxHashMap<LocalDefId, FxHashMap<ItemLocalId, StableVec<TraitCandidate>>>,
664+
pub trait_map: FxHashMap<LocalDefId, FxHashMap<ItemLocalId, Box<[TraitCandidate]>>>,
666665

667666
/// Collected attributes from HIR nodes.
668667
pub attrs: BTreeMap<HirId, &'hir [Attribute]>,

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ rustc_queries! {
11271127
desc { "computing whether impls specialize one another" }
11281128
}
11291129
query in_scope_traits_map(_: LocalDefId)
1130-
-> Option<&'tcx FxHashMap<ItemLocalId, StableVec<TraitCandidate>>> {
1130+
-> Option<&'tcx FxHashMap<ItemLocalId, Box<[TraitCandidate]>>> {
11311131
desc { "traits in scope at a block" }
11321132
}
11331133

compiler/rustc_middle/src/ty/context.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_attr as attr;
3131
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
3232
use rustc_data_structures::profiling::SelfProfilerRef;
3333
use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
34-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableVec};
34+
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3535
use rustc_data_structures::steal::Steal;
3636
use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
3737
use rustc_errors::ErrorReported;
@@ -2651,8 +2651,10 @@ impl<'tcx> TyCtxt<'tcx> {
26512651
struct_lint_level(self.sess, lint, level, src, None, decorate);
26522652
}
26532653

2654-
pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx StableVec<TraitCandidate>> {
2655-
self.in_scope_traits_map(id.owner).and_then(|map| map.get(&id.local_id))
2654+
pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]> {
2655+
let map = self.in_scope_traits_map(id.owner)?;
2656+
let candidates = map.get(&id.local_id)?;
2657+
Some(&*candidates)
26562658
}
26572659

26582660
pub fn named_region(self, id: HirId) -> Option<resolve_lifetime::Region> {

compiler/rustc_middle/src/ty/query/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use crate::ty::subst::{GenericArg, SubstsRef};
3434
use crate::ty::util::AlwaysRequiresDrop;
3535
use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
3636
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
37-
use rustc_data_structures::stable_hasher::StableVec;
3837
use rustc_data_structures::steal::Steal;
3938
use rustc_data_structures::svh::Svh;
4039
use rustc_data_structures::sync::Lrc;

0 commit comments

Comments
 (0)