Skip to content

Commit

Permalink
Remove ptr_map special casing for miri (tokio-rs#565)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shahn committed Sep 21, 2023
1 parent a14ef46 commit c803868
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,13 +1221,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<F>(ptr: *mut u8, f: F) -> *mut u8
where
F: FnOnce(usize) -> usize,
Expand All @@ -1238,16 +1231,6 @@ where
ptr.wrapping_add(diff)
}

#[cfg(not(miri))]
fn ptr_map<F>(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
Expand Down

0 comments on commit c803868

Please sign in to comment.