97
97
extern crate rustc_middle;
98
98
99
99
use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
100
- use rustc_hir:: Node ;
101
100
use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
102
101
use rustc_middle:: mir:: mono:: { InstantiationMode , MonoItem } ;
103
102
use rustc_middle:: ty:: query:: Providers ;
@@ -168,17 +167,14 @@ fn compute_symbol_name<'tcx>(
168
167
169
168
debug ! ( "symbol_name(def_id={:?}, substs={:?})" , def_id, substs) ;
170
169
171
- // FIXME(eddyb) Precompute a custom symbol name based on attributes.
172
- let is_foreign = if let Some ( def_id) = def_id. as_local ( ) {
170
+ if let Some ( def_id) = def_id. as_local ( ) {
173
171
if tcx. proc_macro_decls_static ( ( ) ) == Some ( def_id) {
174
172
let stable_crate_id = tcx. sess . local_stable_crate_id ( ) ;
175
173
return tcx. sess . generate_proc_macro_decls_symbol ( stable_crate_id) ;
176
174
}
177
- matches ! ( tcx. hir( ) . get_by_def_id( def_id) , Node :: ForeignItem ( _) )
178
- } else {
179
- tcx. is_foreign_item ( def_id)
180
- } ;
175
+ }
181
176
177
+ // FIXME(eddyb) Precompute a custom symbol name based on attributes.
182
178
let attrs = tcx. codegen_fn_attrs ( def_id) ;
183
179
184
180
// Foreign items by default use no mangling for their symbol name. There's a
@@ -197,7 +193,7 @@ fn compute_symbol_name<'tcx>(
197
193
// show up in the `wasm-import-name` custom attribute in LLVM IR.
198
194
//
199
195
// [1]: https://bugs.llvm.org/show_bug.cgi?id=44316
200
- if is_foreign
196
+ if tcx . is_foreign_item ( def_id )
201
197
&& ( !tcx. sess . target . is_like_wasm
202
198
|| !tcx. wasm_import_module_map ( def_id. krate ) . contains_key ( & def_id) )
203
199
{
0 commit comments