Skip to content

Commit

Permalink
Rollup merge of rust-lang#76962 - est31:const_cstr, r=oli-obk
Browse files Browse the repository at this point in the history
Use const_cstr macro in consts.rs
  • Loading branch information
RalfJung committed Sep 21, 2020
2 parents 18d1b1b + 812ff66 commit 62a2e1f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
use libc::c_uint;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::const_cstr;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::Node;
Expand All @@ -22,8 +23,6 @@ use rustc_span::Span;
use rustc_target::abi::{AddressSpace, Align, HasDataLayout, LayoutOf, Primitive, Scalar, Size};
use tracing::debug;

use std::ffi::CStr;

pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll Value {
let mut llvals = Vec::with_capacity(alloc.relocations().len() + 1);
let dl = cx.data_layout();
Expand Down Expand Up @@ -454,9 +453,9 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
.all(|&byte| byte == 0);

let sect_name = if all_bytes_are_zero {
CStr::from_bytes_with_nul_unchecked(b"__DATA,__thread_bss\0")
const_cstr!("__DATA,__thread_bss")
} else {
CStr::from_bytes_with_nul_unchecked(b"__DATA,__thread_data\0")
const_cstr!("__DATA,__thread_data")
};
llvm::LLVMSetSection(g, sect_name.as_ptr());
}
Expand Down

0 comments on commit 62a2e1f

Please sign in to comment.