Skip to content

Commit 3905409

Browse files
committed
Auto merge of #54622 - matthewjasper:more-nll-mode, r=pnkfelix
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
2 parents 1886d5f + 27ea811 commit 3905409

File tree

58 files changed

+458
-142
lines changed

Some content is hidden

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

58 files changed

+458
-142
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable
2+
--> $DIR/borrowck-lend-flow-if.rs:39:16
3+
|
4+
LL | _w = &v;
5+
| -- immutable borrow occurs here
6+
LL | }
7+
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
8+
| ^^^^^^^ mutable borrow occurs here
9+
LL | _w.use_ref();
10+
| -- borrow later used here
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0502`.

src/test/ui/borrowck/borrowck-lend-flow-if.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-compare-mode-nll
12-
1311
// Note: the borrowck analysis is currently flow-insensitive.
1412
// Therefore, some of these errors are marked as spurious and could be
1513
// corrected by a simple change to the analysis. The others are
@@ -32,25 +30,32 @@ fn pre_freeze_cond() {
3230
// In this instance, the freeze is conditional and starts before
3331
// the mut borrow.
3432

33+
let u = box 0;
3534
let mut v: Box<_> = box 3;
36-
let _w;
35+
let mut _w = &u;
3736
if cond() {
3837
_w = &v;
3938
}
4039
borrow_mut(&mut *v); //~ ERROR cannot borrow
40+
_w.use_ref();
4141
}
4242

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

47+
let u = box 0;
4748
let mut v: Box<_> = box 3;
48-
let _w;
49+
let mut _w = &u;
4950
if cond() {
5051
_w = &v;
5152
} else {
5253
borrow_mut(&mut *v);
5354
}
55+
_w.use_ref();
5456
}
5557

5658
fn main() {}
59+
60+
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
61+
impl<T> Fake for T { }

src/test/ui/borrowck/borrowck-lend-flow-if.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable
2-
--> $DIR/borrowck-lend-flow-if.rs:40:21
2+
--> $DIR/borrowck-lend-flow-if.rs:39:21
33
|
44
LL | _w = &v;
55
| - immutable borrow occurs here
66
LL | }
77
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
88
| ^^ mutable borrow occurs here
9+
LL | _w.use_ref();
910
LL | }
1011
| - immutable borrow ends here
1112

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable
2+
--> $DIR/borrowck-lend-flow.rs:34:16
3+
|
4+
LL | let _w = &v;
5+
| -- immutable borrow occurs here
6+
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
7+
| ^^^^^^^ mutable borrow occurs here
8+
LL | _w.use_ref();
9+
| -- borrow later used here
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0502`.

src/test/ui/borrowck/borrowck-lend-flow.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-compare-mode-nll
12-
1311
// Note: the borrowck analysis is currently flow-insensitive.
1412
// Therefore, some of these errors are marked as spurious and could be
1513
// corrected by a simple change to the analysis. The others are
@@ -34,6 +32,7 @@ fn pre_freeze() {
3432
let mut v: Box<_> = box 3;
3533
let _w = &v;
3634
borrow_mut(&mut *v); //~ ERROR cannot borrow
35+
_w.use_ref();
3736
}
3837

3938
fn post_freeze() {
@@ -45,3 +44,6 @@ fn post_freeze() {
4544
}
4645

4746
fn main() {}
47+
48+
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
49+
impl<T> Fake for T { }

src/test/ui/borrowck/borrowck-lend-flow.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable
2-
--> $DIR/borrowck-lend-flow.rs:36:21
2+
--> $DIR/borrowck-lend-flow.rs:34:21
33
|
44
LL | let _w = &v;
55
| - immutable borrow occurs here
66
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
77
| ^^ mutable borrow occurs here
8+
LL | _w.use_ref();
89
LL | }
910
| - immutable borrow ends here
1011

src/test/ui/closure_promotion.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
#![allow(const_err)]
1414

15-
// nll successfully compiles this. It is a bug.
16-
// See https://github.com/rust-lang/rust/issues/52384
15+
// nll successfully compiles this.
1716
fn main() {
1817
let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough
1918
}

src/test/ui/closure_promotion.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0597]: borrowed value does not live long enough
2-
--> $DIR/closure_promotion.rs:18:26
2+
--> $DIR/closure_promotion.rs:17:26
33
|
44
LL | let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough
55
| ^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
error: unsatisfied lifetime constraints
2+
--> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5
3+
|
4+
LL | fn param_not_ok<'a>(x: &'a isize) {
5+
| -- lifetime `'a` defined here
6+
LL | assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
8+
9+
error: unsatisfied lifetime constraints
10+
--> $DIR/regions-bounded-by-trait-requiring-static.rs:36:5
11+
|
12+
LL | fn param_not_ok1<'a>(_: &'a isize) {
13+
| -- lifetime `'a` defined here
14+
LL | assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
16+
17+
error: unsatisfied lifetime constraints
18+
--> $DIR/regions-bounded-by-trait-requiring-static.rs:40:5
19+
|
20+
LL | fn param_not_ok2<'a>(_: &'a isize) {
21+
| -- lifetime `'a` defined here
22+
LL | assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
24+
25+
error: unsatisfied lifetime constraints
26+
--> $DIR/regions-bounded-by-trait-requiring-static.rs:54:5
27+
|
28+
LL | fn box_with_region_not_ok<'a>() {
29+
| -- lifetime `'a` defined here
30+
LL | assert_send::<Box<&'a isize>>(); //~ ERROR does not fulfill the required lifetime
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
32+
33+
error: unsatisfied lifetime constraints
34+
--> $DIR/regions-bounded-by-trait-requiring-static.rs:65:5
35+
|
36+
LL | fn unsafe_ok2<'a>(_: &'a isize) {
37+
| -- lifetime `'a` defined here
38+
LL | assert_send::<*const &'a isize>(); //~ ERROR does not fulfill the required lifetime
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
40+
41+
error: unsatisfied lifetime constraints
42+
--> $DIR/regions-bounded-by-trait-requiring-static.rs:69:5
43+
|
44+
LL | fn unsafe_ok3<'a>(_: &'a isize) {
45+
| -- lifetime `'a` defined here
46+
LL | assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
48+
49+
error: aborting due to 6 previous errors
50+

src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-compare-mode-nll
12-
1311
// Test which of the builtin types are considered sendable. The tests
1412
// in this file all test region bound and lifetime violations that are
1513
// detected during type check.

0 commit comments

Comments
 (0)