Skip to content

Commit 52055d1

Browse files
committed
Auto merge of #55554 - pietroalbini:beta-rollup, r=pietroalbini
[beta] Rollup backports Merged and approved: * #55494: borrowck=migrate must look at parents of closures * #55343: rustbuild: fix remap-debuginfo when building a release * #55412: Fix an ICE in the min_const_fn analysis Rolled up PRs: * #55550: [beta] Update the boostrap compiler r? @ghost
2 parents 2824a67 + d35d487 commit 52055d1

17 files changed

+303
-76
lines changed

src/Cargo.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
278278

279279
[[package]]
280280
name = "chalk-engine"
281-
version = "0.8.0"
281+
version = "0.8.1"
282282
source = "registry+https://github.com/rust-lang/crates.io-index"
283283
dependencies = [
284284
"chalk-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1888,7 +1888,7 @@ dependencies = [
18881888
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
18891889
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
18901890
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
1891-
"chalk-engine 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
1891+
"chalk-engine 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
18921892
"flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
18931893
"fmt_macros 0.0.0",
18941894
"graphviz 0.0.0",
@@ -2425,7 +2425,7 @@ name = "rustc_traits"
24252425
version = "0.0.0"
24262426
dependencies = [
24272427
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
2428-
"chalk-engine 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
2428+
"chalk-engine 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
24292429
"graphviz 0.0.0",
24302430
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
24312431
"rustc 0.0.0",
@@ -3193,7 +3193,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
31933193
"checksum cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6809b327f87369e6f3651efd2c5a96c49847a3ed2559477ecba79014751ee1"
31943194
"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
31953195
"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"
3196-
"checksum chalk-engine 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6749eb72e7d4355d944a99f15fbaea701b978c18c5e184a025fcde942b0c9779"
3196+
"checksum chalk-engine 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9adbe0fe1d6e937c3ee0571739a78f53c1de22f59df616060e868cf13c6c4ce5"
31973197
"checksum chalk-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "295635afd6853aa9f20baeb7f0204862440c0fe994c5a253d5f479dac41d047e"
31983198
"checksum chrono 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6962c635d530328acc53ac6a955e83093fedc91c5809dfac1fa60fa470830a37"
31993199
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"

src/bootstrap/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ impl Build {
765765

766766
let path = match which {
767767
GitRepo::Rustc => {
768-
let sha = self.rust_info.sha().expect("failed to find sha");
768+
let sha = self.rust_sha().unwrap_or(channel::CFG_RELEASE_NUM);
769769
format!("/rustc/{}", sha)
770770
}
771771
GitRepo::Llvm => format!("/rustc/llvm"),

src/librustc_mir/borrow_check/mod.rs

+27-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,33 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
346346
mbcx.errors_buffer.sort_by_key(|diag| diag.span.primary_span());
347347

348348
if tcx.migrate_borrowck() {
349-
match tcx.borrowck(def_id).signalled_any_error {
349+
// When borrowck=migrate, check if AST-borrowck would
350+
// error on the given code.
351+
352+
// rust-lang/rust#55492: loop over parents to ensure that
353+
// errors that AST-borrowck only detects in some parent of
354+
// a closure still allows NLL to signal an error.
355+
let mut curr_def_id = def_id;
356+
let signalled_any_error = loop {
357+
match tcx.borrowck(curr_def_id).signalled_any_error {
358+
SignalledError::NoErrorsSeen => {
359+
// keep traversing (and borrow-checking) parents
360+
}
361+
SignalledError::SawSomeError => {
362+
// stop search here
363+
break SignalledError::SawSomeError;
364+
}
365+
}
366+
367+
if tcx.is_closure(curr_def_id) {
368+
curr_def_id = tcx.parent_def_id(curr_def_id)
369+
.expect("a closure must have a parent_def_id");
370+
} else {
371+
break SignalledError::NoErrorsSeen;
372+
}
373+
};
374+
375+
match signalled_any_error {
350376
SignalledError::NoErrorsSeen => {
351377
// if AST-borrowck signalled no errors, then
352378
// downgrade all the buffered MIR-borrowck errors

src/librustc_mir/transform/qualify_min_const_fn.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ fn check_terminator(
317317
check_place(tcx, mir, location, span, PlaceMode::Read)?;
318318
check_operand(tcx, mir, value, span)
319319
},
320-
TerminatorKind::SwitchInt { .. } => Err((
320+
321+
TerminatorKind::FalseEdges { .. } | TerminatorKind::SwitchInt { .. } => Err((
321322
span,
322323
"`if`, `match`, `&&` and `||` are not stable in const fn".into(),
323324
)),
@@ -363,7 +364,7 @@ fn check_terminator(
363364
cleanup: _,
364365
} => check_operand(tcx, mir, cond, span),
365366

366-
| TerminatorKind::FalseEdges { .. } | TerminatorKind::FalseUnwind { .. } => span_bug!(
367+
| TerminatorKind::FalseUnwind { .. } => span_bug!(
367368
terminator.source_info.span,
368369
"min_const_fn encountered `{:#?}`",
369370
terminator

src/stage0.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# source tarball for a stable release you'll likely see `1.x.0` for rustc and
1313
# `0.x.0` for Cargo where they were released on `date`.
1414

15-
date: 2018-10-13
16-
rustc: beta
17-
cargo: beta
15+
date: 2018-10-25
16+
rustc: 1.30.0
17+
cargo: 0.31.0
1818

1919
# When making a stable release the process currently looks like:
2020
#

src/test/ui/borrowck/borrowck-closures-unique.nll.stderr

+2-6
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,15 @@ LL | let c2 = || set(x); //~ ERROR two closures require unique access to `x`
4040
LL | c1;
4141
| -- first borrow later used here
4242

43-
warning[E0594]: cannot assign to `x`, as it is not declared as mutable
43+
error[E0594]: cannot assign to `x`, as it is not declared as mutable
4444
--> $DIR/borrowck-closures-unique.rs:57:38
4545
|
4646
LL | fn e(x: &'static mut isize) {
4747
| - help: consider changing this to be mutable: `mut x`
4848
LL | let c1 = |y: &'static mut isize| x = y; //~ ERROR closure cannot assign to immutable argument
4949
| ^^^^^ cannot assign
50-
|
51-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
52-
It represents potential unsoundness in your code.
53-
This warning will become a hard error in the future.
5450

55-
error: aborting due to 3 previous errors
51+
error: aborting due to 4 previous errors
5652

5753
Some errors occurred: E0500, E0524, E0594.
5854
For more information about an error, try `rustc --explain E0500`.

src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr

+2-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than o
2020
LL | *y = 1;
2121
| ------ first borrow later used here
2222

23-
warning: captured variable cannot escape `FnMut` closure body
23+
error: captured variable cannot escape `FnMut` closure body
2424
--> $DIR/borrowck-describe-lvalue.rs:305:16
2525
|
2626
LL | || {
@@ -36,9 +36,6 @@ LL | | }
3636
|
3737
= note: `FnMut` closures only have access to their captured variables while they are executing...
3838
= note: ...therefore, they cannot allow references to captured variables to escape
39-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
40-
It represents potential unsoundness in your code.
41-
This warning will become a hard error in the future.
4239

4340
error[E0503]: cannot use `f.x` because it was mutably borrowed
4441
--> $DIR/borrowck-describe-lvalue.rs:53:9
@@ -382,7 +379,7 @@ LL | drop(x); //[ast]~ ERROR use of moved value: `x`
382379
|
383380
= note: move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait
384381

385-
error: aborting due to 29 previous errors
382+
error: aborting due to 30 previous errors
386383

387384
Some errors occurred: E0382, E0499, E0502, E0503.
388385
For more information about an error, try `rustc --explain E0382`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
error[E0595]: closure cannot assign to immutable argument `x`
2+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:22
3+
|
4+
LL | let mut c1 = |y: &'static mut isize| x = y;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably
6+
help: consider removing the `&mut`, as it is an immutable binding to a mutable reference
7+
|
8+
LL | x
9+
|
10+
11+
error[E0595]: closure cannot assign to immutable argument `x`
12+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:29:22
13+
|
14+
LL | let mut c1 = |z: &'static mut isize| {
15+
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably
16+
help: consider removing the `&mut`, as it is an immutable binding to a mutable reference
17+
|
18+
LL | x
19+
|
20+
21+
error[E0595]: closure cannot assign to immutable argument `x`
22+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:40:9
23+
|
24+
LL | pub fn capture_assign_whole(x: (i32,)) {
25+
| - help: make this binding mutable: `mut x`
26+
LL | || { x = (1,); };
27+
| ^^ cannot borrow mutably
28+
29+
error[E0595]: closure cannot assign to immutable argument `x`
30+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:43:9
31+
|
32+
LL | pub fn capture_assign_part(x: (i32,)) {
33+
| - help: make this binding mutable: `mut x`
34+
LL | || { x.0 = 1; };
35+
| ^^ cannot borrow mutably
36+
37+
error[E0595]: closure cannot assign to immutable argument `x`
38+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:9
39+
|
40+
LL | pub fn capture_reborrow_whole(x: (i32,)) {
41+
| - help: make this binding mutable: `mut x`
42+
LL | || { &mut x; };
43+
| ^^ cannot borrow mutably
44+
45+
error[E0595]: closure cannot assign to immutable argument `x`
46+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:49:9
47+
|
48+
LL | pub fn capture_reborrow_part(x: (i32,)) {
49+
| - help: make this binding mutable: `mut x`
50+
LL | || { &mut x.0; };
51+
| ^^ cannot borrow mutably
52+
53+
error: aborting due to 6 previous errors
54+
55+
For more information about this error, try `rustc --explain E0595`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
error[E0594]: cannot assign to `x`, as it is not declared as mutable
2+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:46
3+
|
4+
LL | pub fn e(x: &'static mut isize) {
5+
| - help: consider changing this to be mutable: `mut x`
6+
LL | static mut Y: isize = 3;
7+
LL | let mut c1 = |y: &'static mut isize| x = y;
8+
| ^^^^^ cannot assign
9+
10+
error[E0594]: cannot assign to `x`, as it is not declared as mutable
11+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:30:50
12+
|
13+
LL | pub fn ee(x: &'static mut isize) {
14+
| - help: consider changing this to be mutable: `mut x`
15+
...
16+
LL | let mut c2 = |y: &'static mut isize| x = y;
17+
| ^^^^^ cannot assign
18+
19+
error[E0594]: cannot assign to `x`, as it is not declared as mutable
20+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:40:14
21+
|
22+
LL | pub fn capture_assign_whole(x: (i32,)) {
23+
| - help: consider changing this to be mutable: `mut x`
24+
LL | || { x = (1,); };
25+
| ^^^^^^^^ cannot assign
26+
27+
error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
28+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:43:14
29+
|
30+
LL | pub fn capture_assign_part(x: (i32,)) {
31+
| - help: consider changing this to be mutable: `mut x`
32+
LL | || { x.0 = 1; };
33+
| ^^^^^^^ cannot assign
34+
35+
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
36+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:14
37+
|
38+
LL | pub fn capture_reborrow_whole(x: (i32,)) {
39+
| - help: consider changing this to be mutable: `mut x`
40+
LL | || { &mut x; };
41+
| ^^^^^^ cannot borrow as mutable
42+
43+
error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
44+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:49:14
45+
|
46+
LL | pub fn capture_reborrow_part(x: (i32,)) {
47+
| - help: consider changing this to be mutable: `mut x`
48+
LL | || { &mut x.0; };
49+
| ^^^^^^^^ cannot borrow as mutable
50+
51+
error: aborting due to 6 previous errors
52+
53+
Some errors occurred: E0594, E0596.
54+
For more information about an error, try `rustc --explain E0594`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
error[E0594]: cannot assign to `x`, as it is not declared as mutable
2+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:46
3+
|
4+
LL | pub fn e(x: &'static mut isize) {
5+
| - help: consider changing this to be mutable: `mut x`
6+
LL | static mut Y: isize = 3;
7+
LL | let mut c1 = |y: &'static mut isize| x = y;
8+
| ^^^^^ cannot assign
9+
10+
error[E0594]: cannot assign to `x`, as it is not declared as mutable
11+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:30:50
12+
|
13+
LL | pub fn ee(x: &'static mut isize) {
14+
| - help: consider changing this to be mutable: `mut x`
15+
...
16+
LL | let mut c2 = |y: &'static mut isize| x = y;
17+
| ^^^^^ cannot assign
18+
19+
error[E0594]: cannot assign to `x`, as it is not declared as mutable
20+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:40:14
21+
|
22+
LL | pub fn capture_assign_whole(x: (i32,)) {
23+
| - help: consider changing this to be mutable: `mut x`
24+
LL | || { x = (1,); };
25+
| ^^^^^^^^ cannot assign
26+
27+
error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
28+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:43:14
29+
|
30+
LL | pub fn capture_assign_part(x: (i32,)) {
31+
| - help: consider changing this to be mutable: `mut x`
32+
LL | || { x.0 = 1; };
33+
| ^^^^^^^ cannot assign
34+
35+
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
36+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:14
37+
|
38+
LL | pub fn capture_reborrow_whole(x: (i32,)) {
39+
| - help: consider changing this to be mutable: `mut x`
40+
LL | || { &mut x; };
41+
| ^^^^^^ cannot borrow as mutable
42+
43+
error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
44+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:49:14
45+
|
46+
LL | pub fn capture_reborrow_part(x: (i32,)) {
47+
| - help: consider changing this to be mutable: `mut x`
48+
LL | || { &mut x.0; };
49+
| ^^^^^^^^ cannot borrow as mutable
50+
51+
error: aborting due to 6 previous errors
52+
53+
Some errors occurred: E0594, E0596.
54+
For more information about an error, try `rustc --explain E0594`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// rust-lang/rust#55492: errors detected during MIR-borrowck's
2+
// analysis of a closure body may only be caught when AST-borrowck
3+
// looks at some parent.
4+
5+
// revisions: ast migrate nll
6+
7+
// Since we are testing nll (and migration) explicitly as a separate
8+
// revisions, don't worry about the --compare-mode=nll on this test.
9+
10+
// ignore-compare-mode-nll
11+
12+
//[ast]compile-flags: -Z borrowck=ast
13+
//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
14+
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows
15+
16+
17+
// transcribed from borrowck-closures-unique.rs
18+
mod borrowck_closures_unique {
19+
pub fn e(x: &'static mut isize) {
20+
static mut Y: isize = 3;
21+
let mut c1 = |y: &'static mut isize| x = y;
22+
unsafe { c1(&mut Y); }
23+
}
24+
}
25+
26+
mod borrowck_closures_unique_grandparent {
27+
pub fn ee(x: &'static mut isize) {
28+
static mut Z: isize = 3;
29+
let mut c1 = |z: &'static mut isize| {
30+
let mut c2 = |y: &'static mut isize| x = y;
31+
c2(z);
32+
};
33+
unsafe { c1(&mut Z); }
34+
}
35+
}
36+
37+
// adapted from mutability_errors.rs
38+
mod mutability_errors {
39+
pub fn capture_assign_whole(x: (i32,)) {
40+
|| { x = (1,); };
41+
}
42+
pub fn capture_assign_part(x: (i32,)) {
43+
|| { x.0 = 1; };
44+
}
45+
pub fn capture_reborrow_whole(x: (i32,)) {
46+
|| { &mut x; };
47+
}
48+
pub fn capture_reborrow_part(x: (i32,)) {
49+
|| { &mut x.0; };
50+
}
51+
}
52+
53+
fn main() {
54+
static mut X: isize = 2;
55+
unsafe { borrowck_closures_unique::e(&mut X); }
56+
57+
mutability_errors::capture_assign_whole((1000,));
58+
mutability_errors::capture_assign_part((2000,));
59+
mutability_errors::capture_reborrow_whole((3000,));
60+
mutability_errors::capture_reborrow_part((4000,));
61+
}

0 commit comments

Comments
 (0)