Skip to content

Commit de2ac90

Browse files
committed
Fully remove rustc_middle::ich.
1 parent 886c073 commit de2ac90

File tree

7 files changed

+51
-60
lines changed

7 files changed

+51
-60
lines changed

compiler/rustc_middle/src/ich/mod.rs

-53
This file was deleted.

compiler/rustc_middle/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ pub mod query;
7777
pub mod arena;
7878
pub mod dep_graph;
7979
pub mod hir;
80-
pub mod ich;
8180
pub mod infer;
8281
pub mod lint;
8382
pub mod middle;

compiler/rustc_middle/src/traits/specialization_graph.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::ich;
21
use crate::ty::fast_reject::SimplifiedType;
32
use crate::ty::fold::TypeFoldable;
43
use crate::ty::{self, TyCtxt};
@@ -241,6 +240,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for Children {
241240
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
242241
let Children { ref nonblanket_impls, ref blanket_impls } = *self;
243242

244-
ich::hash_stable_trait_impls(hcx, hasher, blanket_impls, nonblanket_impls);
243+
ty::hash_stable_trait_impls(hcx, hasher, blanket_impls, nonblanket_impls);
245244
}
246245
}

compiler/rustc_middle/src/ty/context.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_ast as ast;
2323
use rustc_ast::expand::allocator::AllocatorKind;
2424
use rustc_attr as attr;
2525
use rustc_crate::cstore::{CrateStoreDyn, EncodedMetadata};
26-
use rustc_crate::ich::{NodeIdHashingMode, StableHashingContext};
26+
use rustc_crate::ich::{NodeIdHashingMode, StableHashingContext, StableHashingContextProvider};
2727
use rustc_crate::stability;
2828
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
2929
use rustc_data_structures::profiling::SelfProfilerRef;
@@ -883,6 +883,12 @@ impl<'tcx> Deref for TyCtxt<'tcx> {
883883
}
884884
}
885885

886+
impl StableHashingContextProvider<'tcx> for TyCtxt<'tcx> {
887+
fn get_stable_hashing_context(&self) -> StableHashingContext<'tcx> {
888+
(*self).create_stable_hashing_context()
889+
}
890+
}
891+
886892
pub struct GlobalCtxt<'tcx> {
887893
pub arena: &'tcx WorkerLocal<Arena<'tcx>>,
888894

compiler/rustc_middle/src/ich/impls_ty.rs renamed to compiler/rustc_middle/src/ty/impls_ty.rs

+39
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,52 @@
44
use crate::middle::region;
55
use crate::mir;
66
use crate::ty;
7+
use crate::ty::fast_reject;
78
use rustc_crate::ich::StableHashingContext;
89
use rustc_data_structures::fingerprint::Fingerprint;
910
use rustc_data_structures::fx::FxHashMap;
1011
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
12+
use rustc_span::def_id::DefId;
13+
use smallvec::SmallVec;
1114
use std::cell::RefCell;
1215
use std::mem;
1316

17+
pub fn hash_stable_trait_impls<'a>(
18+
hcx: &mut StableHashingContext<'a>,
19+
hasher: &mut StableHasher,
20+
blanket_impls: &[DefId],
21+
non_blanket_impls: &FxHashMap<fast_reject::SimplifiedType, Vec<DefId>>,
22+
) {
23+
{
24+
let mut blanket_impls: SmallVec<[_; 8]> =
25+
blanket_impls.iter().map(|&def_id| hcx.def_path_hash(def_id)).collect();
26+
27+
if blanket_impls.len() > 1 {
28+
blanket_impls.sort_unstable();
29+
}
30+
31+
blanket_impls.hash_stable(hcx, hasher);
32+
}
33+
34+
{
35+
let mut keys: SmallVec<[_; 8]> =
36+
non_blanket_impls.keys().map(|k| (k, k.map_def(|d| hcx.def_path_hash(d)))).collect();
37+
keys.sort_unstable_by(|&(_, ref k1), &(_, ref k2)| k1.cmp(k2));
38+
keys.len().hash_stable(hcx, hasher);
39+
for (key, ref stable_key) in keys {
40+
stable_key.hash_stable(hcx, hasher);
41+
let mut impls: SmallVec<[_; 8]> =
42+
non_blanket_impls[key].iter().map(|&impl_id| hcx.def_path_hash(impl_id)).collect();
43+
44+
if impls.len() > 1 {
45+
impls.sort_unstable();
46+
}
47+
48+
impls.hash_stable(hcx, hasher);
49+
}
50+
}
51+
}
52+
1453
impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for &'tcx ty::List<T>
1554
where
1655
T: HashStable<StableHashingContext<'a>>,

compiler/rustc_middle/src/ty/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@ pub mod walk;
114114
mod consts;
115115
mod context;
116116
mod diagnostics;
117+
mod impls_ty;
117118
mod instance;
118119
mod list;
119120
mod structural_impls;
120121
mod sty;
121122

122123
pub use context::ENCODE_METADATA;
124+
pub use impls_ty::hash_stable_trait_impls;
123125

124126
// Data types
125127

compiler/rustc_middle/src/ty/trait_def.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use crate::ich;
21
use crate::traits::specialization_graph;
32
use crate::ty::fast_reject;
43
use crate::ty::fold::TypeFoldable;
5-
use crate::ty::{Ty, TyCtxt};
4+
use crate::ty::{self, Ty, TyCtxt};
65
use rustc_crate::ich::StableHashingContext;
76
use rustc_hir as hir;
87
use rustc_hir::def_id::{CrateNum, DefId};
@@ -252,6 +251,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for TraitImpls {
252251
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
253252
let TraitImpls { ref blanket_impls, ref non_blanket_impls } = *self;
254253

255-
ich::hash_stable_trait_impls(hcx, hasher, blanket_impls, non_blanket_impls);
254+
ty::hash_stable_trait_impls(hcx, hasher, blanket_impls, non_blanket_impls);
256255
}
257256
}

0 commit comments

Comments
 (0)