@@ -14,7 +14,7 @@ use std::sync::Arc;
14
14
use base;
15
15
use monomorphize:: Instance ;
16
16
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 } ;
18
18
use rustc:: middle:: exported_symbols:: SymbolExportLevel ;
19
19
use rustc:: session:: config;
20
20
use rustc:: ty:: TyCtxt ;
@@ -24,7 +24,7 @@ use rustc_allocator::ALLOCATOR_METHODS;
24
24
25
25
pub type ExportedSymbols = FxHashMap <
26
26
CrateNum ,
27
- Arc < Vec < ( String , DefId , SymbolExportLevel ) > > ,
27
+ Arc < Vec < ( String , Option < DefId > , SymbolExportLevel ) > > ,
28
28
> ;
29
29
30
30
pub fn threshold ( tcx : TyCtxt ) -> SymbolExportLevel {
@@ -65,11 +65,13 @@ pub fn provide_local(providers: &mut Providers) {
65
65
Rc :: new ( tcx. exported_symbols ( cnum)
66
66
. iter ( )
67
67
. 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
+ } )
73
75
} )
74
76
. collect ( ) )
75
77
} ;
@@ -95,25 +97,20 @@ pub fn provide_local(providers: &mut Providers) {
95
97
let name = tcx. symbol_name ( Instance :: mono ( tcx, def_id) ) ;
96
98
let export_level = export_level ( tcx, def_id) ;
97
99
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)
99
101
} )
100
102
. collect ( ) ;
101
103
102
- const INVALID_DEF_ID : DefId = DefId {
103
- krate : INVALID_CRATE ,
104
- index : CRATE_DEF_INDEX ,
105
- } ;
106
-
107
104
if let Some ( _) = * tcx. sess . entry_fn . borrow ( ) {
108
105
local_crate. push ( ( "main" . to_string ( ) ,
109
- INVALID_DEF_ID ,
106
+ None ,
110
107
SymbolExportLevel :: C ) ) ;
111
108
}
112
109
113
110
if tcx. sess . allocator_kind . get ( ) . is_some ( ) {
114
111
for method in ALLOCATOR_METHODS {
115
112
local_crate. push ( ( format ! ( "__rust_{}" , method. name) ,
116
- INVALID_DEF_ID ,
113
+ None ,
117
114
SymbolExportLevel :: Rust ) ) ;
118
115
}
119
116
}
@@ -123,12 +120,12 @@ pub fn provide_local(providers: &mut Providers) {
123
120
let idx = def_id. index ;
124
121
let disambiguator = tcx. sess . local_crate_disambiguator ( ) ;
125
122
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 ) ) ;
127
124
}
128
125
129
126
if tcx. sess . crate_types . borrow ( ) . contains ( & config:: CrateTypeDylib ) {
130
127
local_crate. push ( ( metadata_symbol_name ( tcx) ,
131
- INVALID_DEF_ID ,
128
+ None ,
132
129
SymbolExportLevel :: Rust ) ) ;
133
130
}
134
131
Arc :: new ( local_crate)
@@ -178,7 +175,7 @@ pub fn provide_extern(providers: &mut Providers) {
178
175
export_level ( tcx, def_id)
179
176
} ;
180
177
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)
182
179
} )
183
180
. collect ( ) ;
184
181
0 commit comments