Skip to content

Commit e05a543

Browse files
committed
Auto merge of #1985 - RalfJung:fn-ptr, r=RalfJung
update fn ptr tests This adjusts the tests for rust-lang/rust#94343.
2 parents b490e6b + c347b04 commit e05a543

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3d127e2040b57157936f5f24e114a8b4c9a505ef
1+
6a705566166debf5eff88c57140df607fa409aaa

src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fn report_msg<'tcx>(
266266
) {
267267
let span = stacktrace.first().map_or(DUMMY_SP, |fi| fi.span);
268268
let mut err = match diag_level {
269-
DiagLevel::Error => tcx.sess.struct_span_err(span, title),
269+
DiagLevel::Error => tcx.sess.struct_span_err(span, title).forget_guarantee(),
270270
DiagLevel::Warning => tcx.sess.struct_span_warn(span, title),
271271
DiagLevel::Note => tcx.sess.diagnostic().span_note_diag(span, title),
272272
};

tests/compile-fail/validity/fn_ptr_offset.rs

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(invalid_value)]
22

33
fn main() {
4-
let _b: fn() = unsafe { std::mem::transmute(0usize) }; //~ ERROR encountered a potentially null function pointer
4+
let _b: fn() = unsafe { std::mem::transmute(0usize) }; //~ ERROR encountered a null function pointer
55
}

tests/run-pass/function_pointers.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ fn main() {
6262
// Any non-null value is okay for function pointers.
6363
unsafe {
6464
let _x: fn() = mem::transmute(1usize);
65-
let mut b = Box::new(42);
66-
let ptr = &mut *b as *mut _;
65+
let mut b = Box::new(42u8);
66+
let ptr = &mut *b as *mut u8;
6767
drop(b);
6868
let _x: fn() = mem::transmute(ptr);
69+
let _x: fn() = mem::transmute(ptr.wrapping_offset(1));
6970
}
7071
}

tests/run-pass/issue-94371.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#[repr(C)]
2+
struct Demo(u64, bool, u64, u32, u64, u64, u64);
3+
4+
fn test() -> (Demo, Demo) {
5+
let mut x = Demo(1, true, 3, 4, 5, 6, 7);
6+
let mut y = Demo(10, false, 12, 13, 14, 15, 16);
7+
std::mem::swap(&mut x, &mut y);
8+
(x, y)
9+
}
10+
11+
fn main() {
12+
drop(test());
13+
}

0 commit comments

Comments
 (0)