diff options
| author | Urgau <urgau@numericable.fr> | 2023-06-08 21:36:20 +0200 |
|---|---|---|
| committer | Urgau <urgau@numericable.fr> | 2023-07-29 12:20:59 +0200 |
| commit | 507d497cfa014514c5dd904f9d273810e888f757 (patch) | |
| tree | ba53d9556891c394d755cb3e002f8e84a74d6977 | |
| parent | 20a6b571063d33c4b1a786c558f74edbda3012ea (diff) | |
| download | rust-507d497cfa014514c5dd904f9d273810e888f757.tar.gz rust-507d497cfa014514c5dd904f9d273810e888f757.zip | |
Adjust some tests for invalid_reference_casting improvements
| -rw-r--r-- | library/core/src/cell.rs | 3 | ||||
| -rw-r--r-- | src/tools/miri/tests/fail/both_borrows/illegal_write1.rs | 2 | ||||
| -rw-r--r-- | src/tools/miri/tests/fail/stacked_borrows/illegal_write3.rs | 2 | ||||
| -rw-r--r-- | tests/ui/const-generics/issues/issue-100313.rs | 2 | ||||
| -rw-r--r-- | tests/ui/const-generics/issues/issue-100313.stderr | 4 |
5 files changed, 9 insertions, 4 deletions
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 909b32547e7..bf4c682d33e 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -1893,7 +1893,8 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RefMut<'_, T> { /// on an _exclusive_ `UnsafeCell<T>`. Even though `T` and `UnsafeCell<T>` have the /// same memory layout, the following is not allowed and undefined behavior: /// -/// ```rust,no_run +#[cfg_attr(bootstrap, doc = "```rust,no_run")] +#[cfg_attr(not(bootstrap), doc = "```rust,compile_fail")] /// # use std::cell::UnsafeCell; /// unsafe fn not_allowed<T>(ptr: &UnsafeCell<T>) -> &mut T { /// let t = ptr as *const UnsafeCell<T> as *mut T; diff --git a/src/tools/miri/tests/fail/both_borrows/illegal_write1.rs b/src/tools/miri/tests/fail/both_borrows/illegal_write1.rs index d3991949cc3..92f273f67bb 100644 --- a/src/tools/miri/tests/fail/both_borrows/illegal_write1.rs +++ b/src/tools/miri/tests/fail/both_borrows/illegal_write1.rs @@ -1,6 +1,8 @@ //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows +#![allow(invalid_reference_casting)] + fn main() { let target = Box::new(42); // has an implicit raw let xref = &*target; diff --git a/src/tools/miri/tests/fail/stacked_borrows/illegal_write3.rs b/src/tools/miri/tests/fail/stacked_borrows/illegal_write3.rs index 6f55b63cb5c..f79f7b561b8 100644 --- a/src/tools/miri/tests/fail/stacked_borrows/illegal_write3.rs +++ b/src/tools/miri/tests/fail/stacked_borrows/illegal_write3.rs @@ -1,3 +1,5 @@ +#![allow(invalid_reference_casting)] + fn main() { let target = 42; // Make sure raw ptr with raw tag cannot mutate frozen location without breaking the shared ref. diff --git a/tests/ui/const-generics/issues/issue-100313.rs b/tests/ui/const-generics/issues/issue-100313.rs index 9a9d4721c84..9af9b5ca458 100644 --- a/tests/ui/const-generics/issues/issue-100313.rs +++ b/tests/ui/const-generics/issues/issue-100313.rs @@ -9,7 +9,7 @@ impl <const B: &'static bool> T<B> { unsafe { *(B as *const bool as *mut bool) = false; //~^ ERROR evaluation of constant value failed [E0080] - //~| ERROR casting `&T` to `&mut T` is undefined behavior + //~| ERROR assigning to `&T` is undefined behavior } } } diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index 17e4850bd12..42ad4d61c8e 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -1,8 +1,8 @@ -error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` --> $DIR/issue-100313.rs:10:13 | LL | *(B as *const bool as *mut bool) = false; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[deny(invalid_reference_casting)]` on by default |
