Skip to content

Commit 507d497

Browse files
committed
Adjust some tests for invalid_reference_casting improvements
1 parent 20a6b57 commit 507d497

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

Diff for: library/core/src/cell.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,8 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RefMut<'_, T> {
18931893
/// on an _exclusive_ `UnsafeCell<T>`. Even though `T` and `UnsafeCell<T>` have the
18941894
/// same memory layout, the following is not allowed and undefined behavior:
18951895
///
1896-
/// ```rust,no_run
1896+
#[cfg_attr(bootstrap, doc = "```rust,no_run")]
1897+
#[cfg_attr(not(bootstrap), doc = "```rust,compile_fail")]
18971898
/// # use std::cell::UnsafeCell;
18981899
/// unsafe fn not_allowed<T>(ptr: &UnsafeCell<T>) -> &mut T {
18991900
/// let t = ptr as *const UnsafeCell<T> as *mut T;

Diff for: src/tools/miri/tests/fail/both_borrows/illegal_write1.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@revisions: stack tree
22
//@[tree]compile-flags: -Zmiri-tree-borrows
33

4+
#![allow(invalid_reference_casting)]
5+
46
fn main() {
57
let target = Box::new(42); // has an implicit raw
68
let xref = &*target;

Diff for: src/tools/miri/tests/fail/stacked_borrows/illegal_write3.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(invalid_reference_casting)]
2+
13
fn main() {
24
let target = 42;
35
// Make sure raw ptr with raw tag cannot mutate frozen location without breaking the shared ref.

Diff for: tests/ui/const-generics/issues/issue-100313.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl <const B: &'static bool> T<B> {
99
unsafe {
1010
*(B as *const bool as *mut bool) = false;
1111
//~^ ERROR evaluation of constant value failed [E0080]
12-
//~| ERROR casting `&T` to `&mut T` is undefined behavior
12+
//~| ERROR assigning to `&T` is undefined behavior
1313
}
1414
}
1515
}

Diff for: tests/ui/const-generics/issues/issue-100313.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
1+
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
22
--> $DIR/issue-100313.rs:10:13
33
|
44
LL | *(B as *const bool as *mut bool) = false;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `#[deny(invalid_reference_casting)]` on by default
88

0 commit comments

Comments
 (0)