Skip to content

Commit 4961a8e

Browse files
incr.comp.: Fix ICE caused by trying to hash INVALID_CRATE_NUM.
1 parent 74d6b85 commit 4961a8e

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

src/librustc/ty/maps.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ define_maps! { <'tcx>
14171417
[] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Rc<Vec<CrateNum>>,
14181418

14191419
[] fn exported_symbols: ExportedSymbols(CrateNum)
1420-
-> Arc<Vec<(String, DefId, SymbolExportLevel)>>,
1420+
-> Arc<Vec<(String, Option<DefId>, SymbolExportLevel)>>,
14211421
[] fn collect_and_partition_translation_items:
14221422
collect_and_partition_translation_items_node(CrateNum)
14231423
-> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),

src/librustc_trans/back/symbol_export.rs

+15-18
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::sync::Arc;
1414
use base;
1515
use monomorphize::Instance;
1616
use rustc::hir::def_id::CrateNum;
17-
use rustc::hir::def_id::{DefId, LOCAL_CRATE, INVALID_CRATE, CRATE_DEF_INDEX};
17+
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
1818
use rustc::middle::exported_symbols::SymbolExportLevel;
1919
use rustc::session::config;
2020
use rustc::ty::TyCtxt;
@@ -24,7 +24,7 @@ use rustc_allocator::ALLOCATOR_METHODS;
2424

2525
pub type ExportedSymbols = FxHashMap<
2626
CrateNum,
27-
Arc<Vec<(String, DefId, SymbolExportLevel)>>,
27+
Arc<Vec<(String, Option<DefId>, SymbolExportLevel)>>,
2828
>;
2929

3030
pub fn threshold(tcx: TyCtxt) -> SymbolExportLevel {
@@ -65,11 +65,13 @@ pub fn provide_local(providers: &mut Providers) {
6565
Rc::new(tcx.exported_symbols(cnum)
6666
.iter()
6767
.filter_map(|&(_, id, level)| {
68-
if level.is_below_threshold(export_threshold) {
69-
Some(id)
70-
} else {
71-
None
72-
}
68+
id.and_then(|id| {
69+
if level.is_below_threshold(export_threshold) {
70+
Some(id)
71+
} else {
72+
None
73+
}
74+
})
7375
})
7476
.collect())
7577
};
@@ -95,25 +97,20 @@ pub fn provide_local(providers: &mut Providers) {
9597
let name = tcx.symbol_name(Instance::mono(tcx, def_id));
9698
let export_level = export_level(tcx, def_id);
9799
debug!("EXPORTED SYMBOL (local): {} ({:?})", name, export_level);
98-
(str::to_owned(&name), def_id, export_level)
100+
(str::to_owned(&name), Some(def_id), export_level)
99101
})
100102
.collect();
101103

102-
const INVALID_DEF_ID: DefId = DefId {
103-
krate: INVALID_CRATE,
104-
index: CRATE_DEF_INDEX,
105-
};
106-
107104
if let Some(_) = *tcx.sess.entry_fn.borrow() {
108105
local_crate.push(("main".to_string(),
109-
INVALID_DEF_ID,
106+
None,
110107
SymbolExportLevel::C));
111108
}
112109

113110
if tcx.sess.allocator_kind.get().is_some() {
114111
for method in ALLOCATOR_METHODS {
115112
local_crate.push((format!("__rust_{}", method.name),
116-
INVALID_DEF_ID,
113+
None,
117114
SymbolExportLevel::Rust));
118115
}
119116
}
@@ -123,12 +120,12 @@ pub fn provide_local(providers: &mut Providers) {
123120
let idx = def_id.index;
124121
let disambiguator = tcx.sess.local_crate_disambiguator();
125122
let registrar = tcx.sess.generate_derive_registrar_symbol(disambiguator, idx);
126-
local_crate.push((registrar, def_id, SymbolExportLevel::C));
123+
local_crate.push((registrar, Some(def_id), SymbolExportLevel::C));
127124
}
128125

129126
if tcx.sess.crate_types.borrow().contains(&config::CrateTypeDylib) {
130127
local_crate.push((metadata_symbol_name(tcx),
131-
INVALID_DEF_ID,
128+
None,
132129
SymbolExportLevel::Rust));
133130
}
134131
Arc::new(local_crate)
@@ -178,7 +175,7 @@ pub fn provide_extern(providers: &mut Providers) {
178175
export_level(tcx, def_id)
179176
};
180177
debug!("EXPORTED SYMBOL (re-export): {} ({:?})", name, export_level);
181-
(str::to_owned(&name), def_id, export_level)
178+
(str::to_owned(&name), Some(def_id), export_level)
182179
})
183180
.collect();
184181

0 commit comments

Comments
 (0)