diff options
| author | Ralf Jung <post@ralfj.de> | 2020-09-21 10:40:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-21 10:40:45 +0200 |
| commit | 9aba4962f5ee7fb215480809f4aeb241de6deba3 (patch) | |
| tree | f3d15d65e716472d05f17fe43ccb3a7166da165d /compiler/rustc_codegen_llvm/src | |
| parent | 5760b081a6a14dceafd00663757c895c71196449 (diff) | |
| parent | 812ff668032e5feb8cd702ecd9f4b5be21513f10 (diff) | |
| download | rust-9aba4962f5ee7fb215480809f4aeb241de6deba3.tar.gz rust-9aba4962f5ee7fb215480809f4aeb241de6deba3.zip | |
Rollup merge of #76962 - est31:const_cstr, r=oli-obk
Use const_cstr macro in consts.rs
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/consts.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index dc09790df02..6d3582d3027 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -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; @@ -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(); @@ -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()); } |
