Skip to content

Commit 27ea811

Browse files
committed
Enable NLL compare mode for more tests
These tests were disabled due to NLL bugs that have since been fixed.
1 parent c9865b1 commit 27ea811

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
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

+9-4
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

+2-1
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

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

+4-2
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

+2-1
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

+1-2
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

+1-1
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
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

-2
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.

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
error[E0477]: the type `&'a isize` does not fulfill the required lifetime
2-
--> $DIR/regions-bounded-by-trait-requiring-static.rs:34:5
2+
--> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5
33
|
44
LL | assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime
55
| ^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: type must satisfy the static lifetime
88

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

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

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

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

4141
error[E0477]: the type `*mut &'a isize` does not fulfill the required lifetime
42-
--> $DIR/regions-bounded-by-trait-requiring-static.rs:71:5
42+
--> $DIR/regions-bounded-by-trait-requiring-static.rs:69:5
4343
|
4444
LL | assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime
4545
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0621]: explicit lifetime required in the type of `x`
2+
--> $DIR/regions-bounded-method-type-parameters.rs:22:5
3+
|
4+
LL | fn caller<'a>(x: &isize) {
5+
| ------ help: add explicit lifetime `'a` to the type of `x`: `&'a isize`
6+
LL | Foo.some_method::<&'a isize>();
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
8+
9+
error: unsatisfied lifetime constraints
10+
--> $DIR/regions-bounded-method-type-parameters.rs:22:5
11+
|
12+
LL | fn caller<'a>(x: &isize) {
13+
| -- lifetime `'a` defined here
14+
LL | Foo.some_method::<&'a isize>();
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
16+
17+
error: aborting due to 2 previous errors
18+
19+
For more information about this error, try `rustc --explain E0621`.

src/test/ui/regions/regions-bounded-method-type-parameters.rs

-2
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
// Check that explicit region bounds are allowed on the various
1412
// nominal types (but not on other types) and that they are type
1513
// checked.

src/test/ui/regions/regions-bounded-method-type-parameters.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0477]: the type `&'a isize` does not fulfill the required lifetime
2-
--> $DIR/regions-bounded-method-type-parameters.rs:24:9
2+
--> $DIR/regions-bounded-method-type-parameters.rs:22:9
33
|
44
LL | Foo.some_method::<&'a isize>();
55
| ^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error: unsatisfied lifetime constraints
2+
--> $DIR/regions-infer-contravariance-due-to-decl.rs:35:9
3+
|
4+
LL | fn use_<'short,'long>(c: Contravariant<'short>,
5+
| ------ ----- lifetime `'long` defined here
6+
| |
7+
| lifetime `'short` defined here
8+
...
9+
LL | let _: Contravariant<'long> = c; //~ ERROR E0623
10+
| ^ type annotation requires that `'short` must outlive `'long`
11+
12+
error: aborting due to previous error
13+

src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs

-2
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 that a type which is contravariant with respect to its region
1412
// parameter yields an error when used in a covariant way.
1513
//

src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/regions-infer-contravariance-due-to-decl.rs:37:35
2+
--> $DIR/regions-infer-contravariance-due-to-decl.rs:35:35
33
|
44
LL | fn use_<'short,'long>(c: Contravariant<'short>,
55
| --------------------- these two types are declared with different lifetimes...
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error: unsatisfied lifetime constraints
2+
--> $DIR/regions-infer-covariance-due-to-decl.rs:32:9
3+
|
4+
LL | fn use_<'short,'long>(c: Covariant<'long>,
5+
| ------ ----- lifetime `'long` defined here
6+
| |
7+
| lifetime `'short` defined here
8+
...
9+
LL | let _: Covariant<'short> = c; //~ ERROR E0623
10+
| ^ type annotation requires that `'short` must outlive `'long`
11+
12+
error: aborting due to previous error
13+

src/test/ui/regions/regions-infer-covariance-due-to-decl.rs

-2
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 that a type which is covariant with respect to its region
1412
// parameter yields an error when used in a contravariant way.
1513
//

src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/regions-infer-covariance-due-to-decl.rs:34:32
2+
--> $DIR/regions-infer-covariance-due-to-decl.rs:32:32
33
|
44
LL | fn use_<'short,'long>(c: Covariant<'long>,
55
| ----------------

src/test/ui/regions/regions-outlives-projection-container.rs

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
// type of a bound that appears in the where clause on a struct must
1515
// outlive the location in which the type appears. Issue #22246.
1616

17-
// ignore-compare-mode-nll
18-
1917
#![allow(dead_code)]
2018
#![feature(rustc_attrs)]
2119

0 commit comments

Comments
 (0)