@@ -252,22 +252,21 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
252252 codegen_fn_attrs. flags |= CodegenFnAttrFlags :: TRACK_CALLER
253253 }
254254 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' ) {
257258 // `#[export_name = ...]` will be converted to a null-terminated string,
258259 // 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 } ) ;
260261 }
261- if s . as_str ( ) . starts_with ( "llvm." ) {
262+ if exported_name . as_str ( ) . starts_with ( "llvm." ) {
262263 // Symbols starting with "llvm." are reserved by LLVM
263264 // trying to define those would produce invalid IR.
264265 // LLVM complain about those *if* we enable LLVM verification checks
265266 // 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 } ) ;
269268 }
270- codegen_fn_attrs. export_name = Some ( s ) ;
269+ codegen_fn_attrs. export_name = Some ( exported_name ) ;
271270 mixed_export_name_no_mangle_lint_state. track_export_name ( attr. span ( ) ) ;
272271 }
273272 }
0 commit comments