Skip to content

Commit

Permalink
Auto merge of #1985 - RalfJung:fn-ptr, r=RalfJung
Browse files Browse the repository at this point in the history
update fn ptr tests

This adjusts the tests for rust-lang/rust#94343.
  • Loading branch information
bors committed Feb 25, 2022
2 parents 538aedf + 44a0b67 commit b7391a7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3d127e2040b57157936f5f24e114a8b4c9a505ef
9f8f0a6e9484fe25517c082a5cbe1e9edb17c8a8
2 changes: 1 addition & 1 deletion src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ fn report_msg<'tcx>(
) {
let span = stacktrace.first().map_or(DUMMY_SP, |fi| fi.span);
let mut err = match diag_level {
DiagLevel::Error => tcx.sess.struct_span_err(span, title),
DiagLevel::Error => tcx.sess.struct_span_err(span, title).forget_guarantee(),
DiagLevel::Warning => tcx.sess.struct_span_warn(span, title),
DiagLevel::Note => tcx.sess.diagnostic().span_note_diag(span, title),
};
Expand Down
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 b7391a7

Please sign in to comment.