about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2023-07-13 11:21:21 +1000
committerZalathar <Zalathar@users.noreply.github.com>2023-07-13 11:28:50 +1000
commit7a5ad35da4e5fd8cb4ec5bf181dbb75afd5dade9 (patch)
tree2adf13a3b437eb942cd15019cc4102f28030916f /compiler/rustc_codegen_llvm/src
parent29c53d87481913511955c7bb33826899b964f2fe (diff)
downloadrust-7a5ad35da4e5fd8cb4ec5bf181dbb75afd5dade9.tar.gz
rust-7a5ad35da4e5fd8cb4ec5bf181dbb75afd5dade9.zip
Pass a byte slice to `coverageinfo::hash_bytes` instead of an owned vector
The function body immediately treats it as a slice anyway, so this just makes
it possible to call the hash function with arbitrary read-only byte slices.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs2
-rw-r--r--compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
index 2b8f839134f..c9321d63e93 100644
--- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
+++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
@@ -95,7 +95,7 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) {
 
     let filenames_size = filenames_buffer.len();
     let filenames_val = cx.const_bytes(&filenames_buffer);
-    let filenames_ref = coverageinfo::hash_bytes(filenames_buffer);
+    let filenames_ref = coverageinfo::hash_bytes(&filenames_buffer);
 
     // Generate the LLVM IR representation of the coverage map and store it in a well-known global
     let cov_data_val = mapgen.generate_coverage_map(cx, version, filenames_size, filenames_val);
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs
index 42fdbd78618..090e88003d6 100644
--- a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs
+++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs
@@ -378,7 +378,7 @@ pub(crate) fn hash_str(strval: &str) -> u64 {
     unsafe { llvm::LLVMRustCoverageHashCString(strval.as_ptr()) }
 }
 
-pub(crate) fn hash_bytes(bytes: Vec<u8>) -> u64 {
+pub(crate) fn hash_bytes(bytes: &[u8]) -> u64 {
     unsafe { llvm::LLVMRustCoverageHashByteArray(bytes.as_ptr().cast(), bytes.len()) }
 }