about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/consts.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/consts.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/consts.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs
index 40e686b253c..0b96b63bc85 100644
--- a/compiler/rustc_codegen_llvm/src/consts.rs
+++ b/compiler/rustc_codegen_llvm/src/consts.rs
@@ -17,7 +17,7 @@ use rustc_middle::ty::{self, Instance};
 use rustc_middle::{bug, span_bug};
 use tracing::{debug, instrument, trace};
 
-use crate::common::{AsCCharPtr, CodegenCx};
+use crate::common::CodegenCx;
 use crate::errors::SymbolAlreadyDefined;
 use crate::type_::Type;
 use crate::type_of::LayoutLlvmExt;
@@ -477,16 +477,14 @@ impl<'ll> CodegenCx<'ll, '_> {
                 .unwrap_or(true)
         {
             if let Some(section) = attrs.link_section {
-                let section = self.create_metadata(section.as_str().into());
+                let section = self.create_metadata(section.as_str().as_bytes());
                 assert!(alloc.provenance().ptrs().is_empty());
 
                 // The `inspect` method is okay here because we checked for provenance, and
                 // because we are doing this access to inspect the final interpreter state (not
                 // as part of the interpreter execution).
                 let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len());
-                let alloc = unsafe {
-                    llvm::LLVMMDStringInContext2(self.llcx, bytes.as_c_char_ptr(), bytes.len())
-                };
+                let alloc = self.create_metadata(bytes);
                 let data = [section, alloc];
                 let meta =
                     unsafe { llvm::LLVMMDNodeInContext2(self.llcx, data.as_ptr(), data.len()) };