forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#68189 - jonas-schievink:beta-next, r=Mark-Sim…
…ulacrum [Beta] Backports I did not include rust-lang#67134 and rust-lang#67289 since they seem to be on beta already. * Fix up Command Debug output when arg0 is specified. rust-lang#67219 * Do not ICE on unnamed future rust-lang#67289 * Don't suppress move errors for union fields rust-lang#67314 * Reenable static linking of libstdc++ on windows-gnu rust-lang#67410 * Use the correct type for static qualifs rust-lang#67621 * Treat extern statics just like statics in the "const pointer to static" representation rust-lang#67630 * Do not ICE on lifetime error involving closures rust-lang#67687
- Loading branch information
Showing
17 changed files
with
241 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
extern "C" { | ||
static X: i32; | ||
} | ||
|
||
static Y: i32 = 42; | ||
|
||
static mut BAR: *const &'static i32 = [&Y].as_ptr(); | ||
|
||
static mut FOO: *const &'static i32 = [unsafe { &X }].as_ptr(); | ||
|
||
fn main() {} | ||
|
||
// END RUST SOURCE | ||
// START rustc.FOO.PromoteTemps.before.mir | ||
// bb0: { | ||
// ... | ||
// _5 = const Scalar(AllocId(1).0x0) : &i32; | ||
// _4 = &(*_5); | ||
// _3 = [move _4]; | ||
// _2 = &_3; | ||
// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); | ||
// _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; | ||
// } | ||
// ... | ||
// bb2: { | ||
// StorageDead(_5); | ||
// StorageDead(_3); | ||
// return; | ||
// } | ||
// END rustc.FOO.PromoteTemps.before.mir | ||
// START rustc.BAR.PromoteTemps.before.mir | ||
// bb0: { | ||
// ... | ||
// _5 = const Scalar(AllocId(0).0x0) : &i32; | ||
// _4 = &(*_5); | ||
// _3 = [move _4]; | ||
// _2 = &_3; | ||
// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); | ||
// _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; | ||
// } | ||
// ... | ||
// bb2: { | ||
// StorageDead(_5); | ||
// StorageDead(_3); | ||
// return; | ||
// } | ||
// END rustc.BAR.PromoteTemps.before.mir | ||
// START rustc.BAR.PromoteTemps.after.mir | ||
// bb0: { | ||
// ... | ||
// _2 = &(promoted[0]: [&'static i32; 1]); | ||
// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); | ||
// _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; | ||
// } | ||
// ... | ||
// bb2: { | ||
// return; | ||
// } | ||
// END rustc.BAR.PromoteTemps.after.mir | ||
// START rustc.FOO.PromoteTemps.after.mir | ||
// bb0: { | ||
// ... | ||
// _2 = &(promoted[0]: [&'static i32; 1]); | ||
// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); | ||
// _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; | ||
// } | ||
// ... | ||
// bb2: { | ||
// return; | ||
// } | ||
// END rustc.FOO.PromoteTemps.after.mir |
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,30 @@ | ||
// Moving from a reference/raw pointer should be an error, even when they're | ||
// the field of a union. | ||
|
||
#![feature(untagged_unions)] | ||
|
||
union Pointers { | ||
a: &'static String, | ||
b: &'static mut String, | ||
c: *const String, | ||
d: *mut String, | ||
} | ||
|
||
unsafe fn move_ref(u: Pointers) -> String { | ||
*u.a | ||
//~^ ERROR cannot move out of `*u.a` | ||
} | ||
unsafe fn move_ref_mut(u: Pointers) -> String { | ||
*u.b | ||
//~^ ERROR cannot move out of `*u.b` | ||
} | ||
unsafe fn move_ptr(u: Pointers) -> String { | ||
*u.c | ||
//~^ ERROR cannot move out of `*u.c` | ||
} | ||
unsafe fn move_ptr_mut(u: Pointers) -> String { | ||
*u.d | ||
//~^ ERROR cannot move out of `*u.d` | ||
} | ||
|
||
fn main() {} |
27 changes: 27 additions & 0 deletions
27
src/test/ui/borrowck/move-from-union-field-issue-66500.stderr
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,27 @@ | ||
error[E0507]: cannot move out of `*u.a` which is behind a shared reference | ||
--> $DIR/move-from-union-field-issue-66500.rs:14:5 | ||
| | ||
LL | *u.a | ||
| ^^^^ move occurs because `*u.a` has type `std::string::String`, which does not implement the `Copy` trait | ||
|
||
error[E0507]: cannot move out of `*u.b` which is behind a mutable reference | ||
--> $DIR/move-from-union-field-issue-66500.rs:18:5 | ||
| | ||
LL | *u.b | ||
| ^^^^ move occurs because `*u.b` has type `std::string::String`, which does not implement the `Copy` trait | ||
|
||
error[E0507]: cannot move out of `*u.c` which is behind a raw pointer | ||
--> $DIR/move-from-union-field-issue-66500.rs:22:5 | ||
| | ||
LL | *u.c | ||
| ^^^^ move occurs because `*u.c` has type `std::string::String`, which does not implement the `Copy` trait | ||
|
||
error[E0507]: cannot move out of `*u.d` which is behind a raw pointer | ||
--> $DIR/move-from-union-field-issue-66500.rs:26:5 | ||
| | ||
LL | *u.d | ||
| ^^^^ move occurs because `*u.d` has type `std::string::String`, which does not implement the `Copy` trait | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0507`. |
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,24 @@ | ||
// run-pass | ||
|
||
// ignore-windows - this is a unix-specific test | ||
// ignore-cloudabi no processes | ||
// ignore-emscripten no processes | ||
// ignore-sgx no processes | ||
#![feature(process_set_argv0)] | ||
|
||
use std::os::unix::process::CommandExt; | ||
use std::process::Command; | ||
|
||
fn main() { | ||
let mut command = Command::new("some-boring-name"); | ||
|
||
assert_eq!(format!("{:?}", command), r#""some-boring-name""#); | ||
|
||
command.args(&["1", "2", "3"]); | ||
|
||
assert_eq!(format!("{:?}", command), r#""some-boring-name" "1" "2" "3""#); | ||
|
||
command.arg0("exciting-name"); | ||
|
||
assert_eq!(format!("{:?}", command), r#"["some-boring-name"] "exciting-name" "1" "2" "3""#); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,14 @@ | ||
// regression test for #67609. | ||
|
||
// check-pass | ||
|
||
static NONE: Option<String> = None; | ||
|
||
static NONE_REF_REF: &&Option<String> = { | ||
let x = &&NONE; | ||
x | ||
}; | ||
|
||
fn main() { | ||
println!("{:?}", NONE_REF_REF); | ||
} |
3 changes: 3 additions & 0 deletions
3
src/test/ui/lifetimes/unnamed-closure-doesnt-life-long-enough-issue-67634.rs
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,3 @@ | ||
fn main() { | ||
[0].iter().flat_map(|a| [0].iter().map(|_| &a)); //~ ERROR `a` does not live long enough | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/lifetimes/unnamed-closure-doesnt-life-long-enough-issue-67634.stderr
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,15 @@ | ||
error[E0597]: `a` does not live long enough | ||
--> $DIR/unnamed-closure-doesnt-life-long-enough-issue-67634.rs:2:49 | ||
| | ||
LL | [0].iter().flat_map(|a| [0].iter().map(|_| &a)); | ||
| - ^- ...but `a` will be dropped here, when the enclosing closure returns | ||
| | | | ||
| | `a` would have to be valid for `'_`... | ||
| has type `&i32` | ||
| | ||
= note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments | ||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#dangling-references> | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. |