From ddd3e3c4e016677613fe04d5ef3995f362f4a93d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 25 Feb 2022 12:05:59 -0500 Subject: [PATCH 1/4] rustup --- rust-version | 2 +- src/diagnostics.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-version b/rust-version index 903f326d3f..ab902204cd 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -3d127e2040b57157936f5f24e114a8b4c9a505ef +d4de1f230ca30b7ce08fbf453daebf8b2e7ffcc9 diff --git a/src/diagnostics.rs b/src/diagnostics.rs index 7181480607..d651aabb86 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -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), }; From e9b140b4a5aa71b16a3c89be483b6fecd600379e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 24 Feb 2022 19:41:11 -0500 Subject: [PATCH 2/4] update fn ptr tests --- tests/compile-fail/validity/fn_ptr_offset.rs | 10 ---------- tests/compile-fail/validity/invalid_fnptr_null.rs | 2 +- tests/run-pass/function_pointers.rs | 5 +++-- 3 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 tests/compile-fail/validity/fn_ptr_offset.rs diff --git a/tests/compile-fail/validity/fn_ptr_offset.rs b/tests/compile-fail/validity/fn_ptr_offset.rs deleted file mode 100644 index 27d8c830ce..0000000000 --- a/tests/compile-fail/validity/fn_ptr_offset.rs +++ /dev/null @@ -1,10 +0,0 @@ -use std::mem; - -fn f() {} - -fn main() { - let x : fn() = f; - let y : *mut u8 = unsafe { mem::transmute(x) }; - let y = y.wrapping_offset(1); - let _x : fn() = unsafe { mem::transmute(y) }; //~ ERROR encountered a potentially null function pointer -} diff --git a/tests/compile-fail/validity/invalid_fnptr_null.rs b/tests/compile-fail/validity/invalid_fnptr_null.rs index 2270740fe1..0634fba36a 100644 --- a/tests/compile-fail/validity/invalid_fnptr_null.rs +++ b/tests/compile-fail/validity/invalid_fnptr_null.rs @@ -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 } diff --git a/tests/run-pass/function_pointers.rs b/tests/run-pass/function_pointers.rs index dcef1fa221..e7d9b2ddd9 100644 --- a/tests/run-pass/function_pointers.rs +++ b/tests/run-pass/function_pointers.rs @@ -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)); } } From 71075672f5af74aa3e119892ffe57fee2a336e1e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 27 Feb 2022 15:22:49 -0500 Subject: [PATCH 3/4] rustup --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index ab902204cd..ba41809f07 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -d4de1f230ca30b7ce08fbf453daebf8b2e7ffcc9 +6a705566166debf5eff88c57140df607fa409aaa From c347b04e8280f09fd3f5d5f28020b6c50505895c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 27 Feb 2022 15:27:34 -0500 Subject: [PATCH 4/4] add test for rust issue 94371 --- tests/run-pass/issue-94371.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/run-pass/issue-94371.rs diff --git a/tests/run-pass/issue-94371.rs b/tests/run-pass/issue-94371.rs new file mode 100644 index 0000000000..1336348efb --- /dev/null +++ b/tests/run-pass/issue-94371.rs @@ -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()); +}