Skip to content

Commit c803868

Browse files
committed
Remove ptr_map special casing for miri (tokio-rs#565)
Since Rust 1.65, which introduced LLVM 15, codegen for both versions of ptr_map is the same. The release happened in Nov 2022, which should mean the majority of users have upgraded.
1 parent a14ef46 commit c803868

File tree

1 file changed

+0
-17
lines changed

1 file changed

+0
-17
lines changed

src/bytes.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,13 +1221,6 @@ unsafe fn release_shared(ptr: *mut Shared) {
12211221
drop(Box::from_raw(ptr));
12221222
}
12231223

1224-
// Ideally we would always use this version of `ptr_map` since it is strict
1225-
// provenance compatible, but it results in worse codegen. We will however still
1226-
// use it on miri because it gives better diagnostics for people who test bytes
1227-
// code with miri.
1228-
//
1229-
// See https://github.com/tokio-rs/bytes/pull/545 for more info.
1230-
#[cfg(miri)]
12311224
fn ptr_map<F>(ptr: *mut u8, f: F) -> *mut u8
12321225
where
12331226
F: FnOnce(usize) -> usize,
@@ -1238,16 +1231,6 @@ where
12381231
ptr.wrapping_add(diff)
12391232
}
12401233

1241-
#[cfg(not(miri))]
1242-
fn ptr_map<F>(ptr: *mut u8, f: F) -> *mut u8
1243-
where
1244-
F: FnOnce(usize) -> usize,
1245-
{
1246-
let old_addr = ptr as usize;
1247-
let new_addr = f(old_addr);
1248-
new_addr as *mut u8
1249-
}
1250-
12511234
// compile-fails
12521235

12531236
/// ```compile_fail

0 commit comments

Comments
 (0)