Skip to content

Commit

Permalink
update fn ptr tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Feb 25, 2022
1 parent ddd3e3c commit e9b140b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
10 changes: 0 additions & 10 deletions tests/compile-fail/validity/fn_ptr_offset.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/compile-fail/validity/invalid_fnptr_null.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(invalid_value)]

fn main() {
let _b: fn() = unsafe { std::mem::transmute(0usize) }; //~ ERROR encountered a potentially null function pointer
let _b: fn() = unsafe { std::mem::transmute(0usize) }; //~ ERROR encountered a null function pointer
}
5 changes: 3 additions & 2 deletions tests/run-pass/function_pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ fn main() {
// Any non-null value is okay for function pointers.
unsafe {
let _x: fn() = mem::transmute(1usize);
let mut b = Box::new(42);
let ptr = &mut *b as *mut _;
let mut b = Box::new(42u8);
let ptr = &mut *b as *mut u8;
drop(b);
let _x: fn() = mem::transmute(ptr);
let _x: fn() = mem::transmute(ptr.wrapping_offset(1));
}
}

0 comments on commit e9b140b

Please sign in to comment.