Skip to content

Commit

Permalink
Auto merge of rust-lang#51094 - Mark-Simulacrum:rollup, r=Mark-Simula…
Browse files Browse the repository at this point in the history
…crum

Rollup of 3 pull requests

Successful merges:

 - rust-lang#51049 (Fix behaviour of divergence in while loop conditions)
 - rust-lang#51057 (make ui tests robust with respect to NLL)
 - rust-lang#51092 ([master] Release notes for 1.26.1)

Failed merges:
  • Loading branch information
bors committed May 26, 2018
2 parents 1e504d3 + 472b04d commit 5015fa3
Show file tree
Hide file tree
Showing 74 changed files with 841 additions and 366 deletions.
24 changes: 24 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
Version 1.26.1 (2018-05-29)
==========================

Tools
-----

- [RLS now works on Windows][50646]
- [Rustfmt stopped badly formatting text in some cases][rustfmt/2695]

Compatibility Notes
--------

- [`fn main() -> impl Trait` no longer works for non-Termination
trait][50656]
This reverts an accidental stabilization.
- [`NaN > NaN` no longer returns true in const-fn contexts][50812]
- [Prohibit using turbofish for `impl Trait` in method arguments][50950]

[50646]: https://github.com/rust-lang/rust/issues/50646
[50656]: https://github.com/rust-lang/rust/pull/50656
[50812]: https://github.com/rust-lang/rust/pull/50812
[50950]: https://github.com/rust-lang/rust/issues/50950
[rustfmt/2695]: https://github.com/rust-lang-nursery/rustfmt/issues/2695

Version 1.26.0 (2018-05-10)
==========================

Expand Down
14 changes: 10 additions & 4 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3843,10 +3843,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let ctxt = BreakableCtxt {
// cannot use break with a value from a while loop
coerce: None,
may_break: true,
may_break: false, // Will get updated if/when we find a `break`.
};

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

if ctxt.may_break {
// No way to know whether it's diverging because
// of a `break` or an outer `break` or `return`.
self.diverges.set(Diverges::Maybe);
}

self.tcx.mk_nil()
}
hir::ExprLoop(ref body, _, source) => {
Expand All @@ -3873,7 +3879,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {

let ctxt = BreakableCtxt {
coerce,
may_break: false, // will get updated if/when we find a `break`
may_break: false, // Will get updated if/when we find a `break`.
};

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

if ctxt.may_break {
// No way to know whether it's diverging because
// of a `break` or an outer `break` or `return.
// of a `break` or an outer `break` or `return`.
self.diverges.set(Diverges::Maybe);
}

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

error: aborting due to previous error
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-report-with-custom-diagnostic.rs:30:21
|
LL | let y = &x;
| -- immutable borrow occurs here
LL | //~^ immutable borrow occurs here
LL | let z = &mut x; //~ ERROR cannot borrow
| ^^^^^^ mutable borrow occurs here
...
LL | y.use_ref();
| - borrow later used here

error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/borrowck-report-with-custom-diagnostic.rs:45:17
|
LL | let y = &mut x;
| ------ first mutable borrow occurs here
LL | //~^ first mutable borrow occurs here
LL | let z = &mut x; //~ ERROR cannot borrow
| ^^^^^^ second mutable borrow occurs here
...
LL | y.use_mut();
| - borrow later used here

error: aborting due to 3 previous errors

Some errors occurred: E0499, E0502.
For more information about an error, try `rustc --explain E0499`.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
//~^ mutable borrow occurs here
let z = &x; //~ ERROR cannot borrow
//~^ immutable borrow occurs here
z.use_ref();
y.use_mut();
}

fn foo() {
Expand All @@ -27,6 +29,8 @@ fn foo() {
//~^ immutable borrow occurs here
let z = &mut x; //~ ERROR cannot borrow
//~^ mutable borrow occurs here
z.use_mut();
y.use_ref();
}
false => ()
}
Expand All @@ -40,5 +44,10 @@ fn bar() {
//~^ first mutable borrow occurs here
let z = &mut x; //~ ERROR cannot borrow
//~^ second mutable borrow occurs here
z.use_mut();
y.use_mut();
};
}

trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
impl<T> Fake for T { }
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ LL | let y = &mut x;
LL | //~^ mutable borrow occurs here
LL | let z = &x; //~ ERROR cannot borrow
| ^ immutable borrow occurs here
LL | //~^ immutable borrow occurs here
...
LL | }
| - mutable borrow ends here

error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-report-with-custom-diagnostic.rs:28:26
--> $DIR/borrowck-report-with-custom-diagnostic.rs:30:26
|
LL | let y = &x;
| - immutable borrow occurs here
LL | //~^ immutable borrow occurs here
LL | let z = &mut x; //~ ERROR cannot borrow
| ^ mutable borrow occurs here
LL | //~^ mutable borrow occurs here
...
LL | }
| - immutable borrow ends here

error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/borrowck-report-with-custom-diagnostic.rs:41:22
--> $DIR/borrowck-report-with-custom-diagnostic.rs:45:22
|
LL | let y = &mut x;
| - first mutable borrow occurs here
LL | //~^ first mutable borrow occurs here
LL | let z = &mut x; //~ ERROR cannot borrow
| ^ second mutable borrow occurs here
LL | //~^ second mutable borrow occurs here
...
LL | };
| - first borrow ends here

Expand Down
32 changes: 21 additions & 11 deletions src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
error: compilation successful
--> $DIR/mut-borrow-outside-loop.rs:13:1
error[E0499]: cannot borrow `void` as mutable more than once at a time
--> $DIR/mut-borrow-outside-loop.rs:17:18
|
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
LL | | let mut void = ();
LL | |
LL | | let first = &mut void;
... |
LL | | }
LL | | }
| |_^
LL | let first = &mut void;
| --------- first mutable borrow occurs here
LL | let second = &mut void; //~ ERROR cannot borrow
| ^^^^^^^^^ second mutable borrow occurs here
LL | first.use_mut();
| ----- borrow later used here

error: aborting due to previous error
error[E0499]: cannot borrow `inner_void` as mutable more than once at a time
--> $DIR/mut-borrow-outside-loop.rs:25:28
|
LL | let inner_first = &mut inner_void;
| --------------- first mutable borrow occurs here
LL | let inner_second = &mut inner_void; //~ ERROR cannot borrow
| ^^^^^^^^^^^^^^^ second mutable borrow occurs here
LL | inner_second.use_mut();
LL | inner_first.use_mut();
| ----------- borrow later used here

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0499`.
6 changes: 6 additions & 0 deletions src/test/ui/borrowck/mut-borrow-outside-loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ fn main() { #![rustc_error] // rust-lang/rust#49855

let first = &mut void;
let second = &mut void; //~ ERROR cannot borrow
first.use_mut();
second.use_mut();

loop {
let mut inner_void = ();

let inner_first = &mut inner_void;
let inner_second = &mut inner_void; //~ ERROR cannot borrow
inner_second.use_mut();
inner_first.use_mut();
}
}

trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
impl<T> Fake for T { }
3 changes: 2 additions & 1 deletion src/test/ui/borrowck/mut-borrow-outside-loop.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ LL | }
| - first borrow ends here

error[E0499]: cannot borrow `inner_void` as mutable more than once at a time
--> $DIR/mut-borrow-outside-loop.rs:23:33
--> $DIR/mut-borrow-outside-loop.rs:25:33
|
LL | let inner_first = &mut inner_void;
| ---------- first mutable borrow occurs here
LL | let inner_second = &mut inner_void; //~ ERROR cannot borrow
| ^^^^^^^^^^ second mutable borrow occurs here
...
LL | }
| - first borrow ends here

Expand Down
39 changes: 39 additions & 0 deletions src/test/ui/break-while-condition.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(never_type)]

fn main() {
// The `if false` expressions are simply to
// make sure we don't avoid checking everything
// simply because a few expressions are unreachable.

if false {
let _: ! = { //~ ERROR mismatched types
'a: while break 'a {};
};
}

if false {
let _: ! = {
while false { //~ ERROR mismatched types
break
}
};
}

if false {
let _: ! = {
while false { //~ ERROR mismatched types
return
}
};
}
}
43 changes: 43 additions & 0 deletions src/test/ui/break-while-condition.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
error[E0308]: mismatched types
--> $DIR/break-while-condition.rs:19:20
|
LL | let _: ! = { //~ ERROR mismatched types
| ____________________^
LL | | 'a: while break 'a {};
LL | | };
| |_________^ expected !, found ()
|
= note: expected type `!`
found type `()`

error[E0308]: mismatched types
--> $DIR/break-while-condition.rs:26:13
|
LL | fn main() {
| - expected `()` because of default return type
...
LL | / while false { //~ ERROR mismatched types
LL | | break
LL | | }
| |_____________^ expected !, found ()
|
= note: expected type `!`
found type `()`

error[E0308]: mismatched types
--> $DIR/break-while-condition.rs:34:13
|
LL | fn main() {
| - expected `()` because of default return type
...
LL | / while false { //~ ERROR mismatched types
LL | | return
LL | | }
| |_____________^ expected !, found ()
|
= note: expected type `!`
found type `()`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0308`.
18 changes: 10 additions & 8 deletions src/test/ui/codemap_tests/issue-11715.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
error: compilation successful
--> $DIR/issue-11715.rs:97:1
error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/issue-11715.rs:100:13
|
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
LL | | let mut x = "foo";
LL | | let y = &mut x;
LL | | let z = &mut x; //~ ERROR cannot borrow
LL | | }
| |_^
LL | let y = &mut x;
| ------ first mutable borrow occurs here
LL | let z = &mut x; //~ ERROR cannot borrow
| ^^^^^^ second mutable borrow occurs here
LL | z.use_mut();
LL | y.use_mut();
| - borrow later used here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0499`.
5 changes: 5 additions & 0 deletions src/test/ui/codemap_tests/issue-11715.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,9 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
let mut x = "foo";
let y = &mut x;
let z = &mut x; //~ ERROR cannot borrow
z.use_mut();
y.use_mut();
}

trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
impl<T> Fake for T { }
1 change: 1 addition & 0 deletions src/test/ui/codemap_tests/issue-11715.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | let y = &mut x;
| - first mutable borrow occurs here
LL | let z = &mut x; //~ ERROR cannot borrow
| ^ second mutable borrow occurs here
...
LL | }
| - first borrow ends here

Expand Down
Loading

0 comments on commit 5015fa3

Please sign in to comment.