Skip to content

Commit

Permalink
Auto merge of #54622 - matthewjasper:more-nll-mode, r=pnkfelix
Browse files Browse the repository at this point in the history
Enable NLL compare mode for more tests

Most of these tests were disabled due to NLL bugs that have since been fixed. A few needed updating for NLL.

r? @nikomatsakis
  • Loading branch information
bors committed Sep 30, 2018
2 parents 1886d5f + 27ea811 commit 3905409
Show file tree
Hide file tree
Showing 58 changed files with 458 additions and 142 deletions.
14 changes: 14 additions & 0 deletions src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-lend-flow-if.rs:39:16
|
LL | _w = &v;
| -- immutable borrow occurs here
LL | }
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
| ^^^^^^^ mutable borrow occurs here
LL | _w.use_ref();
| -- borrow later used here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0502`.
13 changes: 9 additions & 4 deletions src/test/ui/borrowck/borrowck-lend-flow-if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-compare-mode-nll

// Note: the borrowck analysis is currently flow-insensitive.
// Therefore, some of these errors are marked as spurious and could be
// corrected by a simple change to the analysis. The others are
Expand All @@ -32,25 +30,32 @@ fn pre_freeze_cond() {
// In this instance, the freeze is conditional and starts before
// the mut borrow.

let u = box 0;
let mut v: Box<_> = box 3;
let _w;
let mut _w = &u;
if cond() {
_w = &v;
}
borrow_mut(&mut *v); //~ ERROR cannot borrow
_w.use_ref();
}

fn pre_freeze_else() {
// In this instance, the freeze and mut borrow are on separate sides
// of the if.

let u = box 0;
let mut v: Box<_> = box 3;
let _w;
let mut _w = &u;
if cond() {
_w = &v;
} else {
borrow_mut(&mut *v);
}
_w.use_ref();
}

fn main() {}

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/borrowck-lend-flow-if.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable
--> $DIR/borrowck-lend-flow-if.rs:40:21
--> $DIR/borrowck-lend-flow-if.rs:39:21
|
LL | _w = &v;
| - immutable borrow occurs here
LL | }
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
| ^^ mutable borrow occurs here
LL | _w.use_ref();
LL | }
| - immutable borrow ends here

Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/borrowck/borrowck-lend-flow.nll.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-lend-flow.rs:34:16
|
LL | let _w = &v;
| -- immutable borrow occurs here
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
| ^^^^^^^ mutable borrow occurs here
LL | _w.use_ref();
| -- borrow later used here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0502`.
6 changes: 4 additions & 2 deletions src/test/ui/borrowck/borrowck-lend-flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-compare-mode-nll

// Note: the borrowck analysis is currently flow-insensitive.
// Therefore, some of these errors are marked as spurious and could be
// corrected by a simple change to the analysis. The others are
Expand All @@ -34,6 +32,7 @@ fn pre_freeze() {
let mut v: Box<_> = box 3;
let _w = &v;
borrow_mut(&mut *v); //~ ERROR cannot borrow
_w.use_ref();
}

fn post_freeze() {
Expand All @@ -45,3 +44,6 @@ fn post_freeze() {
}

fn main() {}

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/borrowck-lend-flow.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable
--> $DIR/borrowck-lend-flow.rs:36:21
--> $DIR/borrowck-lend-flow.rs:34:21
|
LL | let _w = &v;
| - immutable borrow occurs here
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
| ^^ mutable borrow occurs here
LL | _w.use_ref();
LL | }
| - immutable borrow ends here

Expand Down
3 changes: 1 addition & 2 deletions src/test/ui/closure_promotion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

#![allow(const_err)]

// nll successfully compiles this. It is a bug.
// See https://github.com/rust-lang/rust/issues/52384
// nll successfully compiles this.
fn main() {
let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough
}
2 changes: 1 addition & 1 deletion src/test/ui/closure_promotion.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0597]: borrowed value does not live long enough
--> $DIR/closure_promotion.rs:18:26
--> $DIR/closure_promotion.rs:17:26
|
LL | let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough
| ^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
error: unsatisfied lifetime constraints
--> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5
|
LL | fn param_not_ok<'a>(x: &'a isize) {
| -- lifetime `'a` defined here
LL | assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`

error: unsatisfied lifetime constraints
--> $DIR/regions-bounded-by-trait-requiring-static.rs:36:5
|
LL | fn param_not_ok1<'a>(_: &'a isize) {
| -- lifetime `'a` defined here
LL | assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`

error: unsatisfied lifetime constraints
--> $DIR/regions-bounded-by-trait-requiring-static.rs:40:5
|
LL | fn param_not_ok2<'a>(_: &'a isize) {
| -- lifetime `'a` defined here
LL | assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`

error: unsatisfied lifetime constraints
--> $DIR/regions-bounded-by-trait-requiring-static.rs:54:5
|
LL | fn box_with_region_not_ok<'a>() {
| -- lifetime `'a` defined here
LL | assert_send::<Box<&'a isize>>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`

error: unsatisfied lifetime constraints
--> $DIR/regions-bounded-by-trait-requiring-static.rs:65:5
|
LL | fn unsafe_ok2<'a>(_: &'a isize) {
| -- lifetime `'a` defined here
LL | assert_send::<*const &'a isize>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`

error: unsatisfied lifetime constraints
--> $DIR/regions-bounded-by-trait-requiring-static.rs:69:5
|
LL | fn unsafe_ok3<'a>(_: &'a isize) {
| -- lifetime `'a` defined here
LL | assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`

error: aborting due to 6 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-compare-mode-nll

// Test which of the builtin types are considered sendable. The tests
// in this file all test region bound and lifetime violations that are
// detected during type check.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
error[E0477]: the type `&'a isize` does not fulfill the required lifetime
--> $DIR/regions-bounded-by-trait-requiring-static.rs:34:5
--> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5
|
LL | assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime

error[E0477]: the type `&'a str` does not fulfill the required lifetime
--> $DIR/regions-bounded-by-trait-requiring-static.rs:38:5
--> $DIR/regions-bounded-by-trait-requiring-static.rs:36:5
|
LL | assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime

error[E0477]: the type `&'a [isize]` does not fulfill the required lifetime
--> $DIR/regions-bounded-by-trait-requiring-static.rs:42:5
--> $DIR/regions-bounded-by-trait-requiring-static.rs:40:5
|
LL | assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime

error[E0477]: the type `std::boxed::Box<&'a isize>` does not fulfill the required lifetime
--> $DIR/regions-bounded-by-trait-requiring-static.rs:56:5
--> $DIR/regions-bounded-by-trait-requiring-static.rs:54:5
|
LL | assert_send::<Box<&'a isize>>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime

error[E0477]: the type `*const &'a isize` does not fulfill the required lifetime
--> $DIR/regions-bounded-by-trait-requiring-static.rs:67:5
--> $DIR/regions-bounded-by-trait-requiring-static.rs:65:5
|
LL | assert_send::<*const &'a isize>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime

error[E0477]: the type `*mut &'a isize` does not fulfill the required lifetime
--> $DIR/regions-bounded-by-trait-requiring-static.rs:71:5
--> $DIR/regions-bounded-by-trait-requiring-static.rs:69:5
|
LL | assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/regions-bounded-method-type-parameters.rs:22:5
|
LL | fn caller<'a>(x: &isize) {
| ------ help: add explicit lifetime `'a` to the type of `x`: `&'a isize`
LL | Foo.some_method::<&'a isize>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required

error: unsatisfied lifetime constraints
--> $DIR/regions-bounded-method-type-parameters.rs:22:5
|
LL | fn caller<'a>(x: &isize) {
| -- lifetime `'a` defined here
LL | Foo.some_method::<&'a isize>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0621`.
2 changes: 0 additions & 2 deletions src/test/ui/regions/regions-bounded-method-type-parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-compare-mode-nll

// Check that explicit region bounds are allowed on the various
// nominal types (but not on other types) and that they are type
// checked.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0477]: the type `&'a isize` does not fulfill the required lifetime
--> $DIR/regions-bounded-method-type-parameters.rs:24:9
--> $DIR/regions-bounded-method-type-parameters.rs:22:9
|
LL | Foo.some_method::<&'a isize>();
| ^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: unsatisfied lifetime constraints
--> $DIR/regions-infer-contravariance-due-to-decl.rs:35:9
|
LL | fn use_<'short,'long>(c: Contravariant<'short>,
| ------ ----- lifetime `'long` defined here
| |
| lifetime `'short` defined here
...
LL | let _: Contravariant<'long> = c; //~ ERROR E0623
| ^ type annotation requires that `'short` must outlive `'long`

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-compare-mode-nll

// Test that a type which is contravariant with respect to its region
// parameter yields an error when used in a covariant way.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/regions-infer-contravariance-due-to-decl.rs:37:35
--> $DIR/regions-infer-contravariance-due-to-decl.rs:35:35
|
LL | fn use_<'short,'long>(c: Contravariant<'short>,
| --------------------- these two types are declared with different lifetimes...
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: unsatisfied lifetime constraints
--> $DIR/regions-infer-covariance-due-to-decl.rs:32:9
|
LL | fn use_<'short,'long>(c: Covariant<'long>,
| ------ ----- lifetime `'long` defined here
| |
| lifetime `'short` defined here
...
LL | let _: Covariant<'short> = c; //~ ERROR E0623
| ^ type annotation requires that `'short` must outlive `'long`

error: aborting due to previous error

2 changes: 0 additions & 2 deletions src/test/ui/regions/regions-infer-covariance-due-to-decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-compare-mode-nll

// Test that a type which is covariant with respect to its region
// parameter yields an error when used in a contravariant way.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/regions-infer-covariance-due-to-decl.rs:34:32
--> $DIR/regions-infer-covariance-due-to-decl.rs:32:32
|
LL | fn use_<'short,'long>(c: Covariant<'long>,
| ----------------
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/regions/regions-outlives-projection-container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// type of a bound that appears in the where clause on a struct must
// outlive the location in which the type appears. Issue #22246.

// ignore-compare-mode-nll

#![allow(dead_code)]
#![feature(rustc_attrs)]

Expand Down
Loading

0 comments on commit 3905409

Please sign in to comment.