Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update fn ptr tests #1985

Merged
merged 4 commits into from
Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3d127e2040b57157936f5f24e114a8b4c9a505ef
6a705566166debf5eff88c57140df607fa409aaa
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));
}
}
13 changes: 13 additions & 0 deletions tests/run-pass/issue-94371.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#[repr(C)]
struct Demo(u64, bool, u64, u32, u64, u64, u64);

fn test() -> (Demo, Demo) {
let mut x = Demo(1, true, 3, 4, 5, 6, 7);
let mut y = Demo(10, false, 12, 13, 14, 15, 16);
std::mem::swap(&mut x, &mut y);
(x, y)
}

fn main() {
drop(test());
}