forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#76678 - jonas-schievink:rollup-vzl9yhx, r=jon…
…as-schievink Rollup of 12 pull requests Successful merges: - rust-lang#75559 (unions: test move behavior of non-Copy fields) - rust-lang#76441 (Note that parallel-compiler = true causes tests to fail) - rust-lang#76527 (Remove internal and unstable MaybeUninit::UNINIT.) - rust-lang#76629 (Simplify iter zip struct doc) - rust-lang#76640 (Simplify SyncOnceCell's `take` and `drop`.) - rust-lang#76646 (Add mailmap entry) - rust-lang#76651 (Remove Windows details from Unix and VmWorks symlink() docstrings) - rust-lang#76663 (Simplify iter chain struct doc) - rust-lang#76665 (slice::from_raw_parts: explicitly mention that data must be initialized) - rust-lang#76667 (Fix CI LLVM to work on NixOS out of the box) - rust-lang#76668 (Add visualization of rustc span in doc) - rust-lang#76677 (note that test_stable_pointers does not reflect a stable guarantee) Failed merges: r? `@ghost`
- Loading branch information
Showing
18 changed files
with
148 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |