about summary refs log tree commit diff
path: root/tests/ui/drop
diff options
context:
space:
mode:
authorObei Sideg <obei.sideg@gmail.com>2024-08-24 06:49:09 +0300
committerObei Sideg <obei.sideg@gmail.com>2024-09-13 14:10:56 +0300
commit3b0ce1bc33d30d7d116ee9af60df873e04bd74dc (patch)
treed6f3aef62b82ac74c47a292c38caee216e56c77b /tests/ui/drop
parent74cab947f79045e34eb973199274ee5f3c132bd8 (diff)
downloadrust-3b0ce1bc33d30d7d116ee9af60df873e04bd74dc.tar.gz
rust-3b0ce1bc33d30d7d116ee9af60df873e04bd74dc.zip
Update tests for hidden references to mutable static
Diffstat (limited to 'tests/ui/drop')
-rw-r--r--tests/ui/drop/drop-struct-as-object.rs3
-rw-r--r--tests/ui/drop/drop-struct-as-object.stderr2
-rw-r--r--tests/ui/drop/issue-23338-ensure-param-drop-order.rs3
-rw-r--r--tests/ui/drop/issue-23338-ensure-param-drop-order.stderr17
-rw-r--r--tests/ui/drop/issue-23611-enum-swap-in-drop.rs3
-rw-r--r--tests/ui/drop/issue-23611-enum-swap-in-drop.stderr17
-rw-r--r--tests/ui/drop/issue-48962.rs3
-rw-r--r--tests/ui/drop/repeat-drop.rs3
-rw-r--r--tests/ui/drop/static-issue-17302.rs29
9 files changed, 43 insertions, 37 deletions
diff --git a/tests/ui/drop/drop-struct-as-object.rs b/tests/ui/drop/drop-struct-as-object.rs
index 07c8950f1b2..46633bd7075 100644
--- a/tests/ui/drop/drop-struct-as-object.rs
+++ b/tests/ui/drop/drop-struct-as-object.rs
@@ -5,6 +5,9 @@
 // Test that destructor on a struct runs successfully after the struct
 // is boxed and converted to an object.
 
+// FIXME(static_mut_refs): this could use an atomic
+#![allow(static_mut_refs)]
+
 static mut value: usize = 0;
 
 struct Cat {
diff --git a/tests/ui/drop/drop-struct-as-object.stderr b/tests/ui/drop/drop-struct-as-object.stderr
index 10527c968ed..16f6d1110ba 100644
--- a/tests/ui/drop/drop-struct-as-object.stderr
+++ b/tests/ui/drop/drop-struct-as-object.stderr
@@ -1,5 +1,5 @@
 warning: method `get` is never used
-  --> $DIR/drop-struct-as-object.rs:15:8
+  --> $DIR/drop-struct-as-object.rs:18:8
    |
 LL | trait Dummy {
    |       ----- method in this trait
diff --git a/tests/ui/drop/issue-23338-ensure-param-drop-order.rs b/tests/ui/drop/issue-23338-ensure-param-drop-order.rs
index 1fa68a2e738..6fee4520cbc 100644
--- a/tests/ui/drop/issue-23338-ensure-param-drop-order.rs
+++ b/tests/ui/drop/issue-23338-ensure-param-drop-order.rs
@@ -1,5 +1,7 @@
 //@ run-pass
 #![allow(non_upper_case_globals)]
+// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
+#![allow(static_mut_refs)]
 
 // This test is ensuring that parameters are indeed dropped after
 // temporaries in a fn body.
@@ -91,7 +93,6 @@ pub mod d {
     pub fn max_width() -> u32 {
         unsafe {
             (mem::size_of_val(&trails) * 8) as u32
-            //~^ WARN shared reference to mutable static is discouraged [static_mut_refs]
         }
     }
 
diff --git a/tests/ui/drop/issue-23338-ensure-param-drop-order.stderr b/tests/ui/drop/issue-23338-ensure-param-drop-order.stderr
deleted file mode 100644
index 9126e602391..00000000000
--- a/tests/ui/drop/issue-23338-ensure-param-drop-order.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-warning: creating a shared reference to mutable static is discouraged
-  --> $DIR/issue-23338-ensure-param-drop-order.rs:93:31
-   |
-LL |             (mem::size_of_val(&trails) * 8) as u32
-   |                               ^^^^^^^ shared reference to mutable static
-   |
-   = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
-   = note: this will be a hard error in the 2024 edition
-   = note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
-   = note: `#[warn(static_mut_refs)]` on by default
-help: use `addr_of!` instead to create a raw pointer
-   |
-LL |             (mem::size_of_val(addr_of!(trails)) * 8) as u32
-   |                               ~~~~~~~~~      +
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/drop/issue-23611-enum-swap-in-drop.rs b/tests/ui/drop/issue-23611-enum-swap-in-drop.rs
index 1afaff0f735..410b07b16fc 100644
--- a/tests/ui/drop/issue-23611-enum-swap-in-drop.rs
+++ b/tests/ui/drop/issue-23611-enum-swap-in-drop.rs
@@ -1,5 +1,7 @@
 //@ run-pass
 #![allow(non_upper_case_globals)]
+// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
+#![allow(static_mut_refs)]
 
 // Issue 23611: this test is ensuring that, for an instance `X` of the
 // enum `E`, if you swap in a different variant during the execution
@@ -187,7 +189,6 @@ pub mod d {
     pub fn max_width() -> u32 {
         unsafe {
             (mem::size_of_val(&trails) * 8) as u32
-            //~^ WARN shared reference to mutable static is discouraged [static_mut_refs]
         }
     }
 
diff --git a/tests/ui/drop/issue-23611-enum-swap-in-drop.stderr b/tests/ui/drop/issue-23611-enum-swap-in-drop.stderr
deleted file mode 100644
index 6da87416802..00000000000
--- a/tests/ui/drop/issue-23611-enum-swap-in-drop.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-warning: creating a shared reference to mutable static is discouraged
-  --> $DIR/issue-23611-enum-swap-in-drop.rs:189:31
-   |
-LL |             (mem::size_of_val(&trails) * 8) as u32
-   |                               ^^^^^^^ shared reference to mutable static
-   |
-   = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
-   = note: this will be a hard error in the 2024 edition
-   = note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
-   = note: `#[warn(static_mut_refs)]` on by default
-help: use `addr_of!` instead to create a raw pointer
-   |
-LL |             (mem::size_of_val(addr_of!(trails)) * 8) as u32
-   |                               ~~~~~~~~~      +
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/drop/issue-48962.rs b/tests/ui/drop/issue-48962.rs
index 428a6ca6cd2..98d3af49ac1 100644
--- a/tests/ui/drop/issue-48962.rs
+++ b/tests/ui/drop/issue-48962.rs
@@ -1,6 +1,9 @@
 //@ run-pass
 #![allow(unused_must_use)]
 // Test that we are able to reinitialize box with moved referent
+// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
+#![allow(static_mut_refs)]
+
 static mut ORDER: [usize; 3] = [0, 0, 0];
 static mut INDEX: usize = 0;
 
diff --git a/tests/ui/drop/repeat-drop.rs b/tests/ui/drop/repeat-drop.rs
index b83bee8c1bf..7488d9113b0 100644
--- a/tests/ui/drop/repeat-drop.rs
+++ b/tests/ui/drop/repeat-drop.rs
@@ -3,6 +3,9 @@
 
 #![allow(dropping_references, dropping_copy_types)]
 
+// FIXME(static_mut_refs): this could use an atomic
+#![allow(static_mut_refs)]
+
 static mut CHECK: usize = 0;
 
 struct DropChecker(usize);
diff --git a/tests/ui/drop/static-issue-17302.rs b/tests/ui/drop/static-issue-17302.rs
new file mode 100644
index 00000000000..060f5564efd
--- /dev/null
+++ b/tests/ui/drop/static-issue-17302.rs
@@ -0,0 +1,29 @@
+//@ run-pass
+
+// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
+#![allow(static_mut_refs)]
+
+static mut DROPPED: [bool; 2] = [false, false];
+
+struct A(usize);
+struct Foo { _a: A, _b: isize }
+
+impl Drop for A {
+    fn drop(&mut self) {
+        let A(i) = *self;
+        unsafe { DROPPED[i] = true; }
+    }
+}
+
+fn main() {
+    {
+        Foo {
+            _a: A(0),
+            ..Foo { _a: A(1), _b: 2 }
+        };
+    }
+    unsafe {
+        assert!(DROPPED[0]);
+        assert!(DROPPED[1]);
+    }
+}