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 Mar 25, 2024
1 parent ce8d8a0 commit e874318
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/bytes.rs
Expand Up @@ -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<F>(ptr: *mut u8, f: F) -> *mut u8
where
F: FnOnce(usize) -> usize,
Expand All @@ -1285,16 +1278,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 e874318

Please sign in to comment.