99// except according to those terms.
1010//! Set and unset common attributes on LLVM values.
1111
12- use std:: ffi:: { CStr , CString } ;
12+ use std:: ffi:: CString ;
1313
1414use rustc:: hir:: CodegenFnAttrFlags ;
1515use rustc:: hir:: def_id:: { DefId , LOCAL_CRATE } ;
@@ -75,7 +75,7 @@ pub fn set_frame_pointer_elimination(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value)
7575 if cx. sess ( ) . must_not_eliminate_frame_pointers ( ) {
7676 llvm:: AddFunctionAttrStringValue (
7777 llfn, llvm:: AttributePlace :: Function ,
78- cstr ( "no-frame-pointer-elim\0 " ) , cstr ( "true\0 " ) ) ;
78+ const_cstr ! ( "no-frame-pointer-elim" ) , const_cstr ! ( "true" ) ) ;
7979 }
8080}
8181
@@ -108,7 +108,7 @@ pub fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
108108 // This is defined in the `compiler-builtins` crate for each architecture.
109109 llvm:: AddFunctionAttrStringValue (
110110 llfn, llvm:: AttributePlace :: Function ,
111- cstr ( "probe-stack\0 " ) , cstr ( "__rust_probestack\0 " ) ) ;
111+ const_cstr ! ( "probe-stack" ) , const_cstr ! ( "__rust_probestack" ) ) ;
112112}
113113
114114pub fn llvm_target_features ( sess : & Session ) -> impl Iterator < Item = & str > {
@@ -202,7 +202,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value, id: DefId) {
202202 let val = CString :: new ( features) . unwrap ( ) ;
203203 llvm:: AddFunctionAttrStringValue (
204204 llfn, llvm:: AttributePlace :: Function ,
205- cstr ( "target-features\0 " ) , & val) ;
205+ const_cstr ! ( "target-features" ) , & val) ;
206206 }
207207
208208 // Note that currently the `wasm-import-module` doesn't do anything, but
@@ -213,17 +213,13 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value, id: DefId) {
213213 llvm:: AddFunctionAttrStringValue (
214214 llfn,
215215 llvm:: AttributePlace :: Function ,
216- cstr ( "wasm-import-module\0 " ) ,
216+ const_cstr ! ( "wasm-import-module" ) ,
217217 & module,
218218 ) ;
219219 }
220220 }
221221}
222222
223- fn cstr ( s : & ' static str ) -> & CStr {
224- CStr :: from_bytes_with_nul ( s. as_bytes ( ) ) . expect ( "null-terminated string" )
225- }
226-
227223pub fn provide ( providers : & mut Providers ) {
228224 providers. target_features_whitelist = |tcx, cnum| {
229225 assert_eq ! ( cnum, LOCAL_CRATE ) ;
0 commit comments