about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-09-13 22:34:09 +0000
committerbors <bors@rust-lang.org>2020-09-13 22:34:09 +0000
commitf9a322a6fdd1e12fbe30441feaa4402e23efe303 (patch)
treea81dee2e5024531545a22108aabc1d7415776f49 /src
parent7402a394471a6738a40fea7d4f1891666e5a80c5 (diff)
parentfe716d0447208825de8ddb815b31905d905950c7 (diff)
downloadrust-f9a322a6fdd1e12fbe30441feaa4402e23efe303.tar.gz
rust-f9a322a6fdd1e12fbe30441feaa4402e23efe303.zip
Auto merge of #76678 - jonas-schievink:rollup-vzl9yhx, r=jonas-schievink
Rollup of 12 pull requests

Successful merges:

 - #75559 (unions: test move behavior of non-Copy fields)
 - #76441 (Note that parallel-compiler = true causes tests to fail)
 - #76527 (Remove internal and unstable MaybeUninit::UNINIT.)
 - #76629 (Simplify iter zip struct doc)
 - #76640 (Simplify SyncOnceCell's `take` and `drop`.)
 - #76646 (Add mailmap entry)
 - #76651 (Remove Windows details from Unix and VmWorks symlink() docstrings)
 - #76663 (Simplify iter chain struct doc)
 - #76665 (slice::from_raw_parts: explicitly mention that data must be initialized)
 - #76667 (Fix CI LLVM to work on NixOS out of the box)
 - #76668 (Add visualization of rustc span in doc)
 - #76677 (note that test_stable_pointers does not reflect a stable guarantee)

Failed merges:

r? `@ghost`
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/bootstrap.py2
-rw-r--r--src/test/ui/union/union-drop.rs7
-rw-r--r--src/test/ui/union/union-move.rs53
-rw-r--r--src/test/ui/union/union-move.stderr35
4 files changed, 96 insertions, 1 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 44a17f75451..5f78031e1c7 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -429,6 +429,8 @@ class RustBuild(object):
             llvm_assertions = self.get_toml('assertions', 'llvm') == 'true'
             if self.program_out_of_date(self.llvm_stamp(), llvm_sha + str(llvm_assertions)):
                 self._download_ci_llvm(llvm_sha, llvm_assertions)
+                for binary in ["llvm-config", "FileCheck"]:
+                    self.fix_bin_or_dylib("{}/bin/{}".format(self.llvm_root(), binary))
                 with output(self.llvm_stamp()) as llvm_stamp:
                     llvm_stamp.write(self.date + llvm_sha + str(llvm_assertions))
 
diff --git a/src/test/ui/union/union-drop.rs b/src/test/ui/union/union-drop.rs
index daa03ce6b6f..4df3ed50282 100644
--- a/src/test/ui/union/union-drop.rs
+++ b/src/test/ui/union/union-drop.rs
@@ -48,6 +48,11 @@ fn main() {
         {
             let y = Y { a: S };
         }
-        assert_eq!(CHECK, 2); // 2, dtor of Y is called
+        assert_eq!(CHECK, 2); // 2, Y has no dtor
+        {
+            let u2 = U { a: 1 };
+            std::mem::forget(u2);
+        }
+        assert_eq!(CHECK, 2); // 2, dtor of U *not* called for u2
     }
 }
diff --git a/src/test/ui/union/union-move.rs b/src/test/ui/union/union-move.rs
new file mode 100644
index 00000000000..a0a2d0d6598
--- /dev/null
+++ b/src/test/ui/union/union-move.rs
@@ -0,0 +1,53 @@
+//! Test the behavior of moving out of non-`Copy` union fields.
+//! Avoid types that `Drop`, we want to focus on moving.
+#![feature(untagged_unions)]
+
+use std::cell::RefCell;
+
+fn move_out<T>(x: T) {}
+
+union U1 {
+    f1_nocopy: RefCell<i32>,
+    f2_nocopy: RefCell<i32>,
+    f3_copy: i32,
+}
+
+union U2 {
+    f1_nocopy: RefCell<i32>,
+}
+impl Drop for U2 {
+    fn drop(&mut self) {}
+}
+
+fn test1(x: U1) {
+    // Moving out of a nocopy field prevents accessing other nocopy field.
+    unsafe {
+        move_out(x.f1_nocopy);
+        move_out(x.f2_nocopy); //~ ERROR use of moved value: `x`
+    }
+}
+
+fn test2(x: U1) {
+    // "Moving" out of copy field doesn't prevent later field accesses.
+    unsafe {
+        move_out(x.f3_copy);
+        move_out(x.f2_nocopy); // no error
+    }
+}
+
+fn test3(x: U1) {
+    // Moving out of a nocopy field prevents accessing other copy field.
+    unsafe {
+        move_out(x.f2_nocopy);
+        move_out(x.f3_copy); //~ ERROR use of moved value: `x`
+    }
+}
+
+fn test4(x: U2) {
+    // Cannot move out of union that implements `Drop`.
+    unsafe {
+        move_out(x.f1_nocopy); //~ ERROR cannot move out of type `U2`, which implements the `Drop`
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/union/union-move.stderr b/src/test/ui/union/union-move.stderr
new file mode 100644
index 00000000000..5679192b641
--- /dev/null
+++ b/src/test/ui/union/union-move.stderr
@@ -0,0 +1,35 @@
+error[E0382]: use of moved value: `x`
+  --> $DIR/union-move.rs:26:18
+   |
+LL | fn test1(x: U1) {
+   |          - move occurs because `x` has type `U1`, which does not implement the `Copy` trait
+...
+LL |         move_out(x.f1_nocopy);
+   |                  ----------- value moved here
+LL |         move_out(x.f2_nocopy);
+   |                  ^^^^^^^^^^^ value used here after move
+
+error[E0382]: use of moved value: `x`
+  --> $DIR/union-move.rs:42:18
+   |
+LL | fn test3(x: U1) {
+   |          - move occurs because `x` has type `U1`, which does not implement the `Copy` trait
+...
+LL |         move_out(x.f2_nocopy);
+   |                  ----------- value moved here
+LL |         move_out(x.f3_copy);
+   |                  ^^^^^^^^^ value used here after move
+
+error[E0509]: cannot move out of type `U2`, which implements the `Drop` trait
+  --> $DIR/union-move.rs:49:18
+   |
+LL |         move_out(x.f1_nocopy);
+   |                  ^^^^^^^^^^^
+   |                  |
+   |                  cannot move out of here
+   |                  move occurs because `x.f1_nocopy` has type `RefCell<i32>`, which does not implement the `Copy` trait
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0382, E0509.
+For more information about an error, try `rustc --explain E0382`.