@@ -252,22 +252,21 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
252
252
codegen_fn_attrs. flags |= CodegenFnAttrFlags :: TRACK_CALLER
253
253
}
254
254
sym:: export_name => {
255
- if let Some ( s) = attr. value_str ( ) {
256
- if s. as_str ( ) . contains ( '\0' ) {
255
+ if let Some ( exported_name) = attr. value_str ( ) {
256
+ let value_span = attr. value_span ( ) . expect ( "attibute has value but not a span" ) ;
257
+ if exported_name. as_str ( ) . contains ( '\0' ) {
257
258
// `#[export_name = ...]` will be converted to a null-terminated string,
258
259
// so it may not contain any null characters.
259
- tcx. dcx ( ) . emit_err ( errors:: NullOnExport { span : attr . span ( ) } ) ;
260
+ tcx. dcx ( ) . emit_err ( errors:: NullOnExport { span : value_span } ) ;
260
261
}
261
- if s . as_str ( ) . starts_with ( "llvm." ) {
262
+ if exported_name . as_str ( ) . starts_with ( "llvm." ) {
262
263
// Symbols starting with "llvm." are reserved by LLVM
263
264
// trying to define those would produce invalid IR.
264
265
// LLVM complain about those *if* we enable LLVM verification checks
265
266
// but we often don't enable them by default due to perf reasons.
266
- tcx. dcx ( ) . emit_err ( errors:: ExportNameLLVMIntrinsic {
267
- span : attr. value_span ( ) . expect ( "attibute has value but not a span" ) ,
268
- } ) ;
267
+ tcx. dcx ( ) . emit_err ( errors:: ExportNameLLVMIntrinsic { span : value_span } ) ;
269
268
}
270
- codegen_fn_attrs. export_name = Some ( s ) ;
269
+ codegen_fn_attrs. export_name = Some ( exported_name ) ;
271
270
mixed_export_name_no_mangle_lint_state. track_export_name ( attr. span ( ) ) ;
272
271
}
273
272
}
0 commit comments