diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-05-11 10:38:54 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-05-30 19:54:21 +0200 |
| commit | ee567fe1b1188077743263bebfefc3d2b7cdbcd2 (patch) | |
| tree | 03c3f9e6c0bf0d0f1abb769af2b31aee3266224c /compiler | |
| parent | 10fb4b2fe538df29ee9729f060db0ca74f6c28fb (diff) | |
| download | rust-ee567fe1b1188077743263bebfefc3d2b7cdbcd2.tar.gz rust-ee567fe1b1188077743263bebfefc3d2b7cdbcd2.zip | |
Remove StableVec.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast_lowering/src/lib.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/stable_hasher.rs | 32 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/arena.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/query/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/query/mod.rs | 1 |
7 files changed, 9 insertions, 41 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 7202774292f..a9950b82928 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -44,7 +44,6 @@ use rustc_ast::{self as ast, *}; use rustc_ast_pretty::pprust; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_data_structures::stable_hasher::StableVec; use rustc_data_structures::sync::Lrc; use rustc_errors::{struct_span_err, Applicability}; use rustc_hir as hir; @@ -506,7 +505,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { for (k, v) in self.resolver.trait_map().into_iter() { if let Some(Some(hir_id)) = self.node_id_to_hir_id.get(k) { let map = trait_map.entry(hir_id.owner).or_default(); - map.insert(hir_id.local_id, StableVec::new(v.to_vec())); + map.insert(hir_id.local_id, v.into_boxed_slice()); } } diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index ff28784a1dc..18b352cf3b0 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -550,35 +550,3 @@ pub fn hash_stable_hashmap<HCX, K, V, R, SK, F>( entries.sort_unstable_by(|&(ref sk1, _), &(ref sk2, _)| sk1.cmp(sk2)); entries.hash_stable(hcx, hasher); } - -/// A vector container that makes sure that its items are hashed in a stable -/// order. -#[derive(Debug)] -pub struct StableVec<T>(Vec<T>); - -impl<T> StableVec<T> { - pub fn new(v: Vec<T>) -> Self { - StableVec(v) - } -} - -impl<T> ::std::ops::Deref for StableVec<T> { - type Target = Vec<T>; - - fn deref(&self) -> &Vec<T> { - &self.0 - } -} - -impl<T, HCX> HashStable<HCX> for StableVec<T> -where - T: HashStable<HCX> + ToStableHashKey<HCX>, -{ - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { - let StableVec(ref v) = *self; - - let mut sorted: Vec<_> = v.iter().map(|x| x.to_stable_hash_key(hcx)).collect(); - sorted.sort_unstable(); - sorted.hash_stable(hcx, hasher); - } -} diff --git a/compiler/rustc_hir/src/arena.rs b/compiler/rustc_hir/src/arena.rs index b05ca381b8a..54559281d0a 100644 --- a/compiler/rustc_hir/src/arena.rs +++ b/compiler/rustc_hir/src/arena.rs @@ -43,6 +43,7 @@ macro_rules! arena_types { [] stmt: rustc_hir::Stmt<$tcx>, [] field_def: rustc_hir::FieldDef<$tcx>, [] trait_item_ref: rustc_hir::TraitItemRef, + [] trait_candidate: rustc_hir::TraitCandidate, [] ty: rustc_hir::Ty<$tcx>, [] type_binding: rustc_hir::TypeBinding<$tcx>, [] variant: rustc_hir::Variant<$tcx>, diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 8600276f05d..e9055c95410 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -11,7 +11,6 @@ pub use rustc_ast::{BorrowKind, ImplPolarity, IsAuto}; pub use rustc_ast::{CaptureBy, Movability, Mutability}; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::stable_hasher::StableVec; use rustc_data_structures::sync::{par_for_each_in, Send, Sync}; use rustc_macros::HashStable_Generic; use rustc_span::source_map::Spanned; @@ -662,7 +661,7 @@ pub struct Crate<'hir> { /// Map indicating what traits are in scope for places where this /// is relevant; generated by resolve. - pub trait_map: FxHashMap<LocalDefId, FxHashMap<ItemLocalId, StableVec<TraitCandidate>>>, + pub trait_map: FxHashMap<LocalDefId, FxHashMap<ItemLocalId, Box<[TraitCandidate]>>>, /// Collected attributes from HIR nodes. pub attrs: BTreeMap<HirId, &'hir [Attribute]>, diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 9bf69906911..d8a18b5a2d3 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1133,7 +1133,7 @@ rustc_queries! { desc { "computing whether impls specialize one another" } } query in_scope_traits_map(_: LocalDefId) - -> Option<&'tcx FxHashMap<ItemLocalId, StableVec<TraitCandidate>>> { + -> Option<&'tcx FxHashMap<ItemLocalId, Box<[TraitCandidate]>>> { desc { "traits in scope at a block" } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index f71158b510f..f185a7f54e5 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -30,7 +30,7 @@ use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableVec}; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::steal::Steal; use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal}; use rustc_errors::ErrorReported; @@ -2638,8 +2638,10 @@ impl<'tcx> TyCtxt<'tcx> { struct_lint_level(self.sess, lint, level, src, None, decorate); } - pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx StableVec<TraitCandidate>> { - self.in_scope_traits_map(id.owner).and_then(|map| map.get(&id.local_id)) + pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]> { + let map = self.in_scope_traits_map(id.owner)?; + let candidates = map.get(&id.local_id)?; + Some(&*candidates) } pub fn named_region(self, id: HirId) -> Option<resolve_lifetime::Region> { diff --git a/compiler/rustc_middle/src/ty/query/mod.rs b/compiler/rustc_middle/src/ty/query/mod.rs index bec13da017e..a5b540dcb70 100644 --- a/compiler/rustc_middle/src/ty/query/mod.rs +++ b/compiler/rustc_middle/src/ty/query/mod.rs @@ -34,7 +34,6 @@ use crate::ty::subst::{GenericArg, SubstsRef}; use crate::ty::util::AlwaysRequiresDrop; use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; -use rustc_data_structures::stable_hasher::StableVec; use rustc_data_structures::steal::Steal; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::Lrc; |
