From e8743182288716556830f231c4ddeca19c39ce85 Mon Sep 17 00:00:00 2001 From: Sebastian Hahn Date: Fri, 22 Sep 2023 01:13:22 +0200 Subject: [PATCH] Remove ptr_map special casing for miri (#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. --- src/bytes.rs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/bytes.rs b/src/bytes.rs index 0b443c85b..3cbf00b52 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -1268,13 +1268,6 @@ unsafe fn release_shared(ptr: *mut Shared) { drop(Box::from_raw(ptr)); } -// Ideally we would always use this version of `ptr_map` since it is strict -// provenance compatible, but it results in worse codegen. We will however still -// use it on miri because it gives better diagnostics for people who test bytes -// code with miri. -// -// See https://github.com/tokio-rs/bytes/pull/545 for more info. -#[cfg(miri)] fn ptr_map(ptr: *mut u8, f: F) -> *mut u8 where F: FnOnce(usize) -> usize, @@ -1285,16 +1278,6 @@ where ptr.wrapping_add(diff) } -#[cfg(not(miri))] -fn ptr_map(ptr: *mut u8, f: F) -> *mut u8 -where - F: FnOnce(usize) -> usize, -{ - let old_addr = ptr as usize; - let new_addr = f(old_addr); - new_addr as *mut u8 -} - // compile-fails /// ```compile_fail