Skip to content

Commit 9aba496

Browse files
authored
Rollup merge of #76962 - est31:const_cstr, r=oli-obk
Use const_cstr macro in consts.rs
2 parents 5760b08 + 812ff66 commit 9aba496

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

compiler/rustc_codegen_llvm/src/consts.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::type_of::LayoutLlvmExt;
77
use crate::value::Value;
88
use libc::c_uint;
99
use rustc_codegen_ssa::traits::*;
10+
use rustc_data_structures::const_cstr;
1011
use rustc_hir as hir;
1112
use rustc_hir::def_id::DefId;
1213
use rustc_hir::Node;
@@ -22,8 +23,6 @@ use rustc_span::Span;
2223
use rustc_target::abi::{AddressSpace, Align, HasDataLayout, LayoutOf, Primitive, Scalar, Size};
2324
use tracing::debug;
2425

25-
use std::ffi::CStr;
26-
2726
pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll Value {
2827
let mut llvals = Vec::with_capacity(alloc.relocations().len() + 1);
2928
let dl = cx.data_layout();
@@ -454,9 +453,9 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
454453
.all(|&byte| byte == 0);
455454

456455
let sect_name = if all_bytes_are_zero {
457-
CStr::from_bytes_with_nul_unchecked(b"__DATA,__thread_bss\0")
456+
const_cstr!("__DATA,__thread_bss")
458457
} else {
459-
CStr::from_bytes_with_nul_unchecked(b"__DATA,__thread_data\0")
458+
const_cstr!("__DATA,__thread_data")
460459
};
461460
llvm::LLVMSetSection(g, sect_name.as_ptr());
462461
}

0 commit comments

Comments
 (0)