about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-06-28 22:13:42 +0000
committerbors <bors@rust-lang.org>2025-06-28 22:13:42 +0000
commitcf38b8e663f15db10ce49d7bbce02c99fc3dbc0c (patch)
tree188e9299c1c3de8ac30fedbe365acb8fe49da568 /compiler/rustc_const_eval/src
parent11ad40bb839ca16f74784b4ab72596ad85587298 (diff)
parenta62de822fa254bb062a9f927c00d7cc82580d8e4 (diff)
downloadrust-cf38b8e663f15db10ce49d7bbce02c99fc3dbc0c.tar.gz
rust-cf38b8e663f15db10ce49d7bbce02c99fc3dbc0c.zip
Auto merge of #143157 - matthiaskrgr:rollup-90rtm3a, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#123476 (std::net: adding `unix_socket_exclbind` feature for solaris/illumos.)
 - rust-lang/rust#142708 (Do not include NUL-terminator in computed length)
 - rust-lang/rust#142963 (Skip unnecessary components in x64 try builds)
 - rust-lang/rust#142987 (rustdoc: show attributes on enum variants)
 - rust-lang/rust#143031 (Add windows-gnullvm hosts to the manifest)
 - rust-lang/rust#143082 (update internal `send_signal` comment)
 - rust-lang/rust#143110 (Use tidy to sort `sym::*` items)
 - rust-lang/rust#143111 (BTreeSet: remove duplicated code by reusing `from_sorted_iter`)
 - rust-lang/rust#143114 (Minor Documentation Improvements)

r? `@ghost`
`@rustbot` modify labels: rollup

try-job: dist-i586-gnu-i586-i686-musl
Diffstat (limited to 'compiler/rustc_const_eval/src')
-rw-r--r--compiler/rustc_const_eval/src/util/caller_location.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_const_eval/src/util/caller_location.rs b/compiler/rustc_const_eval/src/util/caller_location.rs
index ab2de279ed8..f489b05fbbd 100644
--- a/compiler/rustc_const_eval/src/util/caller_location.rs
+++ b/compiler/rustc_const_eval/src/util/caller_location.rs
@@ -21,13 +21,14 @@ fn alloc_caller_location<'tcx>(
     assert!(!filename.as_str().as_bytes().contains(&0));
 
     let loc_details = ecx.tcx.sess.opts.unstable_opts.location_detail;
-    let file_wide_ptr = {
+    let filename = {
         let filename = if loc_details.file { filename.as_str() } else { "<redacted>" };
         let filename_with_nul = filename.to_owned() + "\0";
         // This can fail if rustc runs out of memory right here. Trying to emit an error would be
         // pointless, since that would require allocating more memory than these short strings.
         let file_ptr = ecx.allocate_bytes_dedup(filename_with_nul.as_bytes()).unwrap();
-        Immediate::new_slice(file_ptr.into(), filename_with_nul.len().try_into().unwrap(), ecx)
+        let file_len = u64::try_from(filename.len()).unwrap();
+        Immediate::new_slice(file_ptr.into(), file_len, ecx)
     };
     let line = if loc_details.line { Scalar::from_u32(line) } else { Scalar::from_u32(0) };
     let col = if loc_details.column { Scalar::from_u32(col) } else { Scalar::from_u32(0) };
@@ -41,11 +42,8 @@ fn alloc_caller_location<'tcx>(
     let location = ecx.allocate(loc_layout, MemoryKind::CallerLocation).unwrap();
 
     // Initialize fields.
-    ecx.write_immediate(
-        file_wide_ptr,
-        &ecx.project_field(&location, FieldIdx::from_u32(0)).unwrap(),
-    )
-    .expect("writing to memory we just allocated cannot fail");
+    ecx.write_immediate(filename, &ecx.project_field(&location, FieldIdx::from_u32(0)).unwrap())
+        .expect("writing to memory we just allocated cannot fail");
     ecx.write_scalar(line, &ecx.project_field(&location, FieldIdx::from_u32(1)).unwrap())
         .expect("writing to memory we just allocated cannot fail");
     ecx.write_scalar(col, &ecx.project_field(&location, FieldIdx::from_u32(2)).unwrap())