Skip to content

Commit 5015fa3

Browse files
committed
Auto merge of #51094 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 3 pull requests Successful merges: - #51049 (Fix behaviour of divergence in while loop conditions) - #51057 (make ui tests robust with respect to NLL) - #51092 ([master] Release notes for 1.26.1) Failed merges:
2 parents 1e504d3 + 472b04d commit 5015fa3

File tree

74 files changed

+841
-366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+841
-366
lines changed

RELEASES.md

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
Version 1.26.1 (2018-05-29)
2+
==========================
3+
4+
Tools
5+
-----
6+
7+
- [RLS now works on Windows][50646]
8+
- [Rustfmt stopped badly formatting text in some cases][rustfmt/2695]
9+
10+
Compatibility Notes
11+
--------
12+
13+
- [`fn main() -> impl Trait` no longer works for non-Termination
14+
trait][50656]
15+
This reverts an accidental stabilization.
16+
- [`NaN > NaN` no longer returns true in const-fn contexts][50812]
17+
- [Prohibit using turbofish for `impl Trait` in method arguments][50950]
18+
19+
[50646]: https://github.com./rust-lang/rust/issues/50646
20+
[50656]: https://github.com./rust-lang/rust/pull/50656
21+
[50812]: https://github.com./rust-lang/rust/pull/50812
22+
[50950]: https://github.com./rust-lang/rust/issues/50950
23+
[rustfmt/2695]: https://github.com./rust-lang-nursery/rustfmt/issues/2695
24+
125
Version 1.26.0 (2018-05-10)
226
==========================
327

src/librustc_typeck/check/mod.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -3843,10 +3843,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
38433843
let ctxt = BreakableCtxt {
38443844
// cannot use break with a value from a while loop
38453845
coerce: None,
3846-
may_break: true,
3846+
may_break: false, // Will get updated if/when we find a `break`.
38473847
};
38483848

3849-
self.with_breakable_ctxt(expr.id, ctxt, || {
3849+
let (ctxt, ()) = self.with_breakable_ctxt(expr.id, ctxt, || {
38503850
self.check_expr_has_type_or_error(&cond, tcx.types.bool);
38513851
let cond_diverging = self.diverges.get();
38523852
self.check_block_no_value(&body);
@@ -3855,6 +3855,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
38553855
self.diverges.set(cond_diverging);
38563856
});
38573857

3858+
if ctxt.may_break {
3859+
// No way to know whether it's diverging because
3860+
// of a `break` or an outer `break` or `return`.
3861+
self.diverges.set(Diverges::Maybe);
3862+
}
3863+
38583864
self.tcx.mk_nil()
38593865
}
38603866
hir::ExprLoop(ref body, _, source) => {
@@ -3873,7 +3879,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
38733879

38743880
let ctxt = BreakableCtxt {
38753881
coerce,
3876-
may_break: false, // will get updated if/when we find a `break`
3882+
may_break: false, // Will get updated if/when we find a `break`.
38773883
};
38783884

38793885
let (ctxt, ()) = self.with_breakable_ctxt(expr.id, ctxt, || {
@@ -3882,7 +3888,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
38823888

38833889
if ctxt.may_break {
38843890
// No way to know whether it's diverging because
3885-
// of a `break` or an outer `break` or `return.
3891+
// of a `break` or an outer `break` or `return`.
38863892
self.diverges.set(Diverges::Maybe);
38873893
}
38883894

Original file line numberDiff line numberDiff line change
@@ -1,14 +1,40 @@
1-
error: compilation successful
2-
--> $DIR/borrowck-report-with-custom-diagnostic.rs:12:1
1+
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
2+
--> $DIR/borrowck-report-with-custom-diagnostic.rs:17:13
33
|
4-
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
5-
LL | | // Original borrow ends at end of function
6-
LL | | let mut x = 1;
7-
LL | | let y = &mut x;
8-
... |
9-
LL | | //~^ immutable borrow occurs here
10-
LL | | }
11-
| |_^
4+
LL | let y = &mut x;
5+
| ------ mutable borrow occurs here
6+
LL | //~^ mutable borrow occurs here
7+
LL | let z = &x; //~ ERROR cannot borrow
8+
| ^^ immutable borrow occurs here
9+
...
10+
LL | y.use_mut();
11+
| - borrow later used here
1212

13-
error: aborting due to previous error
13+
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
14+
--> $DIR/borrowck-report-with-custom-diagnostic.rs:30:21
15+
|
16+
LL | let y = &x;
17+
| -- immutable borrow occurs here
18+
LL | //~^ immutable borrow occurs here
19+
LL | let z = &mut x; //~ ERROR cannot borrow
20+
| ^^^^^^ mutable borrow occurs here
21+
...
22+
LL | y.use_ref();
23+
| - borrow later used here
24+
25+
error[E0499]: cannot borrow `x` as mutable more than once at a time
26+
--> $DIR/borrowck-report-with-custom-diagnostic.rs:45:17
27+
|
28+
LL | let y = &mut x;
29+
| ------ first mutable borrow occurs here
30+
LL | //~^ first mutable borrow occurs here
31+
LL | let z = &mut x; //~ ERROR cannot borrow
32+
| ^^^^^^ second mutable borrow occurs here
33+
...
34+
LL | y.use_mut();
35+
| - borrow later used here
36+
37+
error: aborting due to 3 previous errors
1438

39+
Some errors occurred: E0499, E0502.
40+
For more information about an error, try `rustc --explain E0499`.

src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
1616
//~^ mutable borrow occurs here
1717
let z = &x; //~ ERROR cannot borrow
1818
//~^ immutable borrow occurs here
19+
z.use_ref();
20+
y.use_mut();
1921
}
2022

2123
fn foo() {
@@ -27,6 +29,8 @@ fn foo() {
2729
//~^ immutable borrow occurs here
2830
let z = &mut x; //~ ERROR cannot borrow
2931
//~^ mutable borrow occurs here
32+
z.use_mut();
33+
y.use_ref();
3034
}
3135
false => ()
3236
}
@@ -40,5 +44,10 @@ fn bar() {
4044
//~^ first mutable borrow occurs here
4145
let z = &mut x; //~ ERROR cannot borrow
4246
//~^ second mutable borrow occurs here
47+
z.use_mut();
48+
y.use_mut();
4349
};
4450
}
51+
52+
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
53+
impl<T> Fake for T { }

src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ LL | let y = &mut x;
66
LL | //~^ mutable borrow occurs here
77
LL | let z = &x; //~ ERROR cannot borrow
88
| ^ immutable borrow occurs here
9-
LL | //~^ immutable borrow occurs here
9+
...
1010
LL | }
1111
| - mutable borrow ends here
1212

1313
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
14-
--> $DIR/borrowck-report-with-custom-diagnostic.rs:28:26
14+
--> $DIR/borrowck-report-with-custom-diagnostic.rs:30:26
1515
|
1616
LL | let y = &x;
1717
| - immutable borrow occurs here
1818
LL | //~^ immutable borrow occurs here
1919
LL | let z = &mut x; //~ ERROR cannot borrow
2020
| ^ mutable borrow occurs here
21-
LL | //~^ mutable borrow occurs here
21+
...
2222
LL | }
2323
| - immutable borrow ends here
2424

2525
error[E0499]: cannot borrow `x` as mutable more than once at a time
26-
--> $DIR/borrowck-report-with-custom-diagnostic.rs:41:22
26+
--> $DIR/borrowck-report-with-custom-diagnostic.rs:45:22
2727
|
2828
LL | let y = &mut x;
2929
| - first mutable borrow occurs here
3030
LL | //~^ first mutable borrow occurs here
3131
LL | let z = &mut x; //~ ERROR cannot borrow
3232
| ^ second mutable borrow occurs here
33-
LL | //~^ second mutable borrow occurs here
33+
...
3434
LL | };
3535
| - first borrow ends here
3636

Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
error: compilation successful
2-
--> $DIR/mut-borrow-outside-loop.rs:13:1
1+
error[E0499]: cannot borrow `void` as mutable more than once at a time
2+
--> $DIR/mut-borrow-outside-loop.rs:17:18
33
|
4-
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
5-
LL | | let mut void = ();
6-
LL | |
7-
LL | | let first = &mut void;
8-
... |
9-
LL | | }
10-
LL | | }
11-
| |_^
4+
LL | let first = &mut void;
5+
| --------- first mutable borrow occurs here
6+
LL | let second = &mut void; //~ ERROR cannot borrow
7+
| ^^^^^^^^^ second mutable borrow occurs here
8+
LL | first.use_mut();
9+
| ----- borrow later used here
1210

13-
error: aborting due to previous error
11+
error[E0499]: cannot borrow `inner_void` as mutable more than once at a time
12+
--> $DIR/mut-borrow-outside-loop.rs:25:28
13+
|
14+
LL | let inner_first = &mut inner_void;
15+
| --------------- first mutable borrow occurs here
16+
LL | let inner_second = &mut inner_void; //~ ERROR cannot borrow
17+
| ^^^^^^^^^^^^^^^ second mutable borrow occurs here
18+
LL | inner_second.use_mut();
19+
LL | inner_first.use_mut();
20+
| ----------- borrow later used here
21+
22+
error: aborting due to 2 previous errors
1423

24+
For more information about this error, try `rustc --explain E0499`.

src/test/ui/borrowck/mut-borrow-outside-loop.rs

+6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
1515

1616
let first = &mut void;
1717
let second = &mut void; //~ ERROR cannot borrow
18+
first.use_mut();
19+
second.use_mut();
1820

1921
loop {
2022
let mut inner_void = ();
2123

2224
let inner_first = &mut inner_void;
2325
let inner_second = &mut inner_void; //~ ERROR cannot borrow
26+
inner_second.use_mut();
27+
inner_first.use_mut();
2428
}
2529
}
2630

31+
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
32+
impl<T> Fake for T { }

src/test/ui/borrowck/mut-borrow-outside-loop.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ LL | }
1010
| - first borrow ends here
1111

1212
error[E0499]: cannot borrow `inner_void` as mutable more than once at a time
13-
--> $DIR/mut-borrow-outside-loop.rs:23:33
13+
--> $DIR/mut-borrow-outside-loop.rs:25:33
1414
|
1515
LL | let inner_first = &mut inner_void;
1616
| ---------- first mutable borrow occurs here
1717
LL | let inner_second = &mut inner_void; //~ ERROR cannot borrow
1818
| ^^^^^^^^^^ second mutable borrow occurs here
19+
...
1920
LL | }
2021
| - first borrow ends here
2122

src/test/ui/break-while-condition.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(never_type)]
12+
13+
fn main() {
14+
// The `if false` expressions are simply to
15+
// make sure we don't avoid checking everything
16+
// simply because a few expressions are unreachable.
17+
18+
if false {
19+
let _: ! = { //~ ERROR mismatched types
20+
'a: while break 'a {};
21+
};
22+
}
23+
24+
if false {
25+
let _: ! = {
26+
while false { //~ ERROR mismatched types
27+
break
28+
}
29+
};
30+
}
31+
32+
if false {
33+
let _: ! = {
34+
while false { //~ ERROR mismatched types
35+
return
36+
}
37+
};
38+
}
39+
}
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/break-while-condition.rs:19:20
3+
|
4+
LL | let _: ! = { //~ ERROR mismatched types
5+
| ____________________^
6+
LL | | 'a: while break 'a {};
7+
LL | | };
8+
| |_________^ expected !, found ()
9+
|
10+
= note: expected type `!`
11+
found type `()`
12+
13+
error[E0308]: mismatched types
14+
--> $DIR/break-while-condition.rs:26:13
15+
|
16+
LL | fn main() {
17+
| - expected `()` because of default return type
18+
...
19+
LL | / while false { //~ ERROR mismatched types
20+
LL | | break
21+
LL | | }
22+
| |_____________^ expected !, found ()
23+
|
24+
= note: expected type `!`
25+
found type `()`
26+
27+
error[E0308]: mismatched types
28+
--> $DIR/break-while-condition.rs:34:13
29+
|
30+
LL | fn main() {
31+
| - expected `()` because of default return type
32+
...
33+
LL | / while false { //~ ERROR mismatched types
34+
LL | | return
35+
LL | | }
36+
| |_____________^ expected !, found ()
37+
|
38+
= note: expected type `!`
39+
found type `()`
40+
41+
error: aborting due to 3 previous errors
42+
43+
For more information about this error, try `rustc --explain E0308`.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
error: compilation successful
2-
--> $DIR/issue-11715.rs:97:1
1+
error[E0499]: cannot borrow `x` as mutable more than once at a time
2+
--> $DIR/issue-11715.rs:100:13
33
|
4-
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
5-
LL | | let mut x = "foo";
6-
LL | | let y = &mut x;
7-
LL | | let z = &mut x; //~ ERROR cannot borrow
8-
LL | | }
9-
| |_^
4+
LL | let y = &mut x;
5+
| ------ first mutable borrow occurs here
6+
LL | let z = &mut x; //~ ERROR cannot borrow
7+
| ^^^^^^ second mutable borrow occurs here
8+
LL | z.use_mut();
9+
LL | y.use_mut();
10+
| - borrow later used here
1011

1112
error: aborting due to previous error
1213

14+
For more information about this error, try `rustc --explain E0499`.

src/test/ui/codemap_tests/issue-11715.rs

+5
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,9 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
9898
let mut x = "foo";
9999
let y = &mut x;
100100
let z = &mut x; //~ ERROR cannot borrow
101+
z.use_mut();
102+
y.use_mut();
101103
}
104+
105+
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
106+
impl<T> Fake for T { }

src/test/ui/codemap_tests/issue-11715.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let y = &mut x;
55
| - first mutable borrow occurs here
66
LL | let z = &mut x; //~ ERROR cannot borrow
77
| ^ second mutable borrow occurs here
8+
...
89
LL | }
910
| - first borrow ends here
1011

0 commit comments

Comments
 (0)