Skip to content

Commit 74d6b85

Browse files
incr.comp.: Fix rebase fallout.
1 parent d5b1fee commit 74d6b85

File tree

8 files changed

+138
-31
lines changed

8 files changed

+138
-31
lines changed

src/librustc/ich/hcx.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use hir::map::definitions::Definitions;
1515
use ich::{self, CachingCodemapView};
1616
use middle::cstore::CrateStore;
1717
use session::config::DebugInfoLevel::NoDebugInfo;
18-
use ty::{self, TyCtxt, fast_reject};
18+
use ty::{TyCtxt, fast_reject};
1919
use session::Session;
2020

2121
use std::cmp::Ord;
@@ -252,7 +252,7 @@ impl<'gcx> StableHashingContext<'gcx> {
252252
}
253253
}
254254

255-
impl<'a, 'gcx, 'lcx> StableHashingContextProvider for ty::TyCtxt<'a, 'gcx, 'lcx> {
255+
impl<'a, 'gcx, 'lcx> StableHashingContextProvider for TyCtxt<'a, 'gcx, 'lcx> {
256256
type ContextType = StableHashingContext<'gcx>;
257257
fn create_stable_hashing_context(&self) -> Self::ContextType {
258258
(*self).create_stable_hashing_context()

src/librustc/infer/error_reporting/different_lifetimes.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
332332

333333
(Some(rl::Region::EarlyBound(_, id)), ty::BrNamed(def_id, _)) => {
334334
debug!("EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \
335-
def_id={:?}",
336-
self.infcx.tcx.hir.local_def_id(id),
337-
def_id);
338-
if self.infcx.tcx.hir.local_def_id(id) == def_id {
335+
def_id={:?}", id, def_id);
336+
if id == def_id {
339337
self.found_it = true;
340338
return; // we can stop visiting now
341339
}
@@ -344,11 +342,9 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
344342
(Some(rl::Region::LateBound(debruijn_index, id)), ty::BrNamed(def_id, _)) => {
345343
debug!("FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
346344
debruijn_index.depth);
347-
debug!("self.infcx.tcx.hir.local_def_id(id)={:?}",
348-
self.infcx.tcx.hir.local_def_id(id));
345+
debug!("id={:?}", id);
349346
debug!("def_id={:?}", def_id);
350-
if debruijn_index.depth == self.depth &&
351-
self.infcx.tcx.hir.local_def_id(id) == def_id {
347+
if debruijn_index.depth == self.depth && id == def_id {
352348
self.found_it = true;
353349
return; // we can stop visiting now
354350
}

src/librustc/middle/exported_symbols.rs

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ pub enum SymbolExportLevel {
1919
Rust,
2020
}
2121

22+
impl_stable_hash_for!(enum self::SymbolExportLevel {
23+
C,
24+
Rust
25+
});
26+
2227
impl SymbolExportLevel {
2328
pub fn is_below_threshold(self, threshold: SymbolExportLevel) -> bool {
2429
if threshold == SymbolExportLevel::Rust {

src/librustc/middle/trans.rs

+79
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ use syntax::ast::NodeId;
1212
use syntax::symbol::InternedString;
1313
use ty::Instance;
1414
use util::nodemap::FxHashMap;
15+
use rustc_data_structures::stable_hasher::{HashStable, StableHasherResult,
16+
StableHasher};
17+
use ich::{Fingerprint, StableHashingContext, NodeIdHashingMode};
1518

1619
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
1720
pub enum TransItem<'tcx> {
@@ -20,6 +23,26 @@ pub enum TransItem<'tcx> {
2023
GlobalAsm(NodeId),
2124
}
2225

26+
impl<'tcx> HashStable<StableHashingContext<'tcx>> for TransItem<'tcx> {
27+
fn hash_stable<W: StableHasherResult>(&self,
28+
hcx: &mut StableHashingContext<'tcx>,
29+
hasher: &mut StableHasher<W>) {
30+
::std::mem::discriminant(self).hash_stable(hcx, hasher);
31+
32+
match *self {
33+
TransItem::Fn(ref instance) => {
34+
instance.hash_stable(hcx, hasher);
35+
}
36+
TransItem::Static(node_id) |
37+
TransItem::GlobalAsm(node_id) => {
38+
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
39+
node_id.hash_stable(hcx, hasher);
40+
})
41+
}
42+
}
43+
}
44+
}
45+
2346
pub struct CodegenUnit<'tcx> {
2447
/// A name for this CGU. Incremental compilation requires that
2548
/// name be unique amongst **all** crates. Therefore, it should
@@ -44,13 +67,33 @@ pub enum Linkage {
4467
Common,
4568
}
4669

70+
impl_stable_hash_for!(enum self::Linkage {
71+
External,
72+
AvailableExternally,
73+
LinkOnceAny,
74+
LinkOnceODR,
75+
WeakAny,
76+
WeakODR,
77+
Appending,
78+
Internal,
79+
Private,
80+
ExternalWeak,
81+
Common
82+
});
83+
4784
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
4885
pub enum Visibility {
4986
Default,
5087
Hidden,
5188
Protected,
5289
}
5390

91+
impl_stable_hash_for!(enum self::Visibility {
92+
Default,
93+
Hidden,
94+
Protected
95+
});
96+
5497
impl<'tcx> CodegenUnit<'tcx> {
5598
pub fn new(name: InternedString) -> CodegenUnit<'tcx> {
5699
CodegenUnit {
@@ -78,6 +121,29 @@ impl<'tcx> CodegenUnit<'tcx> {
78121
}
79122
}
80123

124+
impl<'tcx> HashStable<StableHashingContext<'tcx>> for CodegenUnit<'tcx> {
125+
fn hash_stable<W: StableHasherResult>(&self,
126+
hcx: &mut StableHashingContext<'tcx>,
127+
hasher: &mut StableHasher<W>) {
128+
let CodegenUnit {
129+
ref items,
130+
name,
131+
} = *self;
132+
133+
name.hash_stable(hcx, hasher);
134+
135+
let mut items: Vec<(Fingerprint, _)> = items.iter().map(|(trans_item, &attrs)| {
136+
let mut hasher = StableHasher::new();
137+
trans_item.hash_stable(hcx, &mut hasher);
138+
let trans_item_fingerprint = hasher.finish();
139+
(trans_item_fingerprint, attrs)
140+
}).collect();
141+
142+
items.sort_unstable_by_key(|i| i.0);
143+
items.hash_stable(hcx, hasher);
144+
}
145+
}
146+
81147
#[derive(Clone, Default)]
82148
pub struct Stats {
83149
pub n_glues_created: usize,
@@ -92,6 +158,18 @@ pub struct Stats {
92158
pub fn_stats: Vec<(String, usize)>,
93159
}
94160

161+
impl_stable_hash_for!(struct self::Stats {
162+
n_glues_created,
163+
n_null_glues,
164+
n_real_glues,
165+
n_fns,
166+
n_inlines,
167+
n_closures,
168+
n_llvm_insns,
169+
llvm_insns,
170+
fn_stats
171+
});
172+
95173
impl Stats {
96174
pub fn extend(&mut self, stats: Stats) {
97175
self.n_glues_created += stats.n_glues_created;
@@ -108,3 +186,4 @@ impl Stats {
108186
self.fn_stats.extend(stats.fn_stats);
109187
}
110188
}
189+

src/librustc/session/config.rs

+33
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ pub use self::DebugInfoLevel::*;
1919
use session::{early_error, early_warn, Session};
2020
use session::search_paths::SearchPaths;
2121

22+
use ich::StableHashingContext;
2223
use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
2324
use rustc_back::target::Target;
25+
use rustc_data_structures::stable_hasher::ToStableHashKey;
2426
use lint;
2527
use middle::cstore;
2628

@@ -90,6 +92,25 @@ pub enum OutputType {
9092
DepInfo,
9193
}
9294

95+
impl_stable_hash_for!(enum self::OutputType {
96+
Bitcode,
97+
Assembly,
98+
LlvmAssembly,
99+
Mir,
100+
Metadata,
101+
Object,
102+
Exe,
103+
DepInfo
104+
});
105+
106+
impl<'tcx> ToStableHashKey<StableHashingContext<'tcx>> for OutputType {
107+
type KeyType = OutputType;
108+
#[inline]
109+
fn to_stable_hash_key(&self, _: &StableHashingContext<'tcx>) -> Self::KeyType {
110+
*self
111+
}
112+
}
113+
93114
impl OutputType {
94115
fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool {
95116
match *self {
@@ -149,6 +170,10 @@ impl Default for ErrorOutputType {
149170
#[derive(Clone, Hash)]
150171
pub struct OutputTypes(BTreeMap<OutputType, Option<PathBuf>>);
151172

173+
impl_stable_hash_for!(tuple_struct self::OutputTypes {
174+
map
175+
});
176+
152177
impl OutputTypes {
153178
pub fn new(entries: &[(OutputType, Option<PathBuf>)]) -> OutputTypes {
154179
OutputTypes(BTreeMap::from_iter(entries.iter()
@@ -373,6 +398,14 @@ pub struct OutputFilenames {
373398
pub outputs: OutputTypes,
374399
}
375400

401+
impl_stable_hash_for!(struct self::OutputFilenames {
402+
out_directory,
403+
out_filestem,
404+
single_output_file,
405+
extra,
406+
outputs
407+
});
408+
376409
/// Codegen unit names generated by the numbered naming scheme will contain this
377410
/// marker right before the index of the codegen unit.
378411
pub const NUMBERED_CODEGEN_UNIT_MARKER: &'static str = ".cgu-";

src/librustc_data_structures/stable_hasher.rs

+8
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,14 @@ impl<CTX> HashStable<CTX> for String {
386386
}
387387
}
388388

389+
impl<HCX> ToStableHashKey<HCX> for String {
390+
type KeyType = String;
391+
#[inline]
392+
fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType {
393+
self.clone()
394+
}
395+
}
396+
389397
impl<CTX> HashStable<CTX> for bool {
390398
#[inline]
391399
fn hash_stable<W: StableHasherResult>(&self,

src/librustc_trans/base.rs

+6-19
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ use rustc::middle::trans::{Linkage, Visibility, Stats};
4141
use rustc::middle::cstore::{EncodedMetadata, EncodedMetadataHashes};
4242
use rustc::ty::{self, Ty, TyCtxt};
4343
use rustc::ty::maps::Providers;
44-
use rustc::dep_graph::AssertDepGraphSafe;
4544
use rustc::middle::cstore::{self, LinkMeta, LinkagePreference};
4645
use rustc::hir::map as hir_map;
4746
use rustc::util::common::{time, print_time_passes_entry};
@@ -894,7 +893,7 @@ fn iter_globals(llmod: llvm::ModuleRef) -> ValueIter {
894893
/// This list is later used by linkers to determine the set of symbols needed to
895894
/// be exposed from a dynamic library and it's also encoded into the metadata.
896895
pub fn find_exported_symbols(tcx: TyCtxt) -> NodeSet {
897-
tcx.reachable_set(LOCAL_CRATE).iter().cloned().filter(|&id| {
896+
tcx.reachable_set(LOCAL_CRATE).0.iter().cloned().filter(|&id| {
898897
// Next, we want to ignore some FFI functions that are not exposed from
899898
// this crate. Reachable FFI functions can be lumped into two
900899
// categories:
@@ -1370,8 +1369,8 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
13701369
let dep_node = cgu.work_product_dep_node();
13711370
let ((stats, module), _) =
13721371
tcx.dep_graph.with_task(dep_node,
1373-
AssertDepGraphSafe(tcx),
1374-
AssertDepGraphSafe(cgu),
1372+
tcx,
1373+
cgu,
13751374
module_translation);
13761375
let time_to_translate = start_time.elapsed();
13771376

@@ -1392,14 +1391,10 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
13921391
return stats;
13931392

13941393
fn module_translation<'a, 'tcx>(
1395-
tcx: AssertDepGraphSafe<TyCtxt<'a, 'tcx, 'tcx>>,
1396-
args: AssertDepGraphSafe<Arc<CodegenUnit<'tcx>>>)
1394+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
1395+
cgu: Arc<CodegenUnit<'tcx>>)
13971396
-> (Stats, ModuleTranslation)
13981397
{
1399-
// FIXME(#40304): We ought to be using the id as a key and some queries, I think.
1400-
let AssertDepGraphSafe(tcx) = tcx;
1401-
let AssertDepGraphSafe(cgu) = args;
1402-
14031398
let cgu_name = cgu.name().to_string();
14041399
let cgu_id = cgu.work_product_id();
14051400
let symbol_name_hash = cgu.compute_symbol_name_hash(tcx);
@@ -1564,6 +1559,7 @@ pub fn visibility_to_llvm(linkage: Visibility) -> llvm::Visibility {
15641559
Visibility::Default => llvm::Visibility::Default,
15651560
Visibility::Hidden => llvm::Visibility::Hidden,
15661561
Visibility::Protected => llvm::Visibility::Protected,
1562+
}
15671563
}
15681564

15691565
// FIXME(mw): Anything that is produced via DepGraph::with_task() must implement
@@ -1577,17 +1573,8 @@ pub fn visibility_to_llvm(linkage: Visibility) -> llvm::Visibility {
15771573
mod temp_stable_hash_impls {
15781574
use rustc_data_structures::stable_hasher::{StableHasherResult, StableHasher,
15791575
HashStable};
1580-
use context::Stats;
15811576
use ModuleTranslation;
15821577

1583-
impl<HCX> HashStable<HCX> for Stats {
1584-
fn hash_stable<W: StableHasherResult>(&self,
1585-
_: &mut HCX,
1586-
_: &mut StableHasher<W>) {
1587-
// do nothing
1588-
}
1589-
}
1590-
15911578
impl<HCX> HashStable<HCX> for ModuleTranslation {
15921579
fn hash_stable<W: StableHasherResult>(&self,
15931580
_: &mut HCX,

src/librustc_trans/context.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ use type_::Type;
2727
use rustc_data_structures::base_n;
2828
use rustc::middle::trans::Stats;
2929
use rustc_data_structures::stable_hasher::StableHashingContextProvider;
30-
use rustc::session::config::{self, NoDebugInfo, OutputFilenames};
31-
use rustc::session::Session;
3230
use rustc::session::config::{self, NoDebugInfo};
31+
use rustc::session::Session;
3332
use rustc::ty::layout::{LayoutCx, LayoutError, LayoutTyper, TyLayout};
3433
use rustc::ty::{self, Ty, TyCtxt};
3534
use rustc::util::nodemap::FxHashMap;

0 commit comments

Comments
 (0)