Skip to content

Commit 812ff66

Browse files
committedSep 20, 2020
Use const_cstr macro in consts.rs
1 parent 285fc7d commit 812ff66

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed
 

‎compiler/rustc_codegen_llvm/src/consts.rs

+3-4
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();
@@ -457,9 +456,9 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
457456
.all(|&byte| byte == 0);
458457

459458
let sect_name = if all_bytes_are_zero {
460-
CStr::from_bytes_with_nul_unchecked(b"__DATA,__thread_bss\0")
459+
const_cstr!("__DATA,__thread_bss")
461460
} else {
462-
CStr::from_bytes_with_nul_unchecked(b"__DATA,__thread_data\0")
461+
const_cstr!("__DATA,__thread_data")
463462
};
464463
llvm::LLVMSetSection(g, sect_name.as_ptr());
465464
}

0 commit comments

Comments
 (0)
Please sign in to comment.