Skip to content

Commit f1a7f9a

Browse files
committed
Use revisions for NLL in closures
1 parent eb222bf commit f1a7f9a

6 files changed

+36
-18
lines changed

src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr renamed to src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.base.stderr

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
2-
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:9
2+
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:9
33
|
44
LL | fn foo(x: &()) {
55
| --- this data with an anonymous lifetime `'_`...
66
LL | bar(|| {
77
| _________^
88
LL | |
9+
LL | |
10+
LL | |
911
LL | | let _ = x;
1012
LL | | })
1113
| |_____^ ...is used here...
1214
|
1315
note: ...and is required to live as long as `'static` here
14-
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
16+
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5
1517
|
1618
LL | bar(|| {
1719
| ^^^
1820
note: `'static` lifetime requirement introduced by this bound
19-
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:1:39
21+
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:39
2022
|
2123
LL | fn bar<F>(blk: F) where F: FnOnce() + 'static {
2224
| ^^^^^^^

src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
error[E0521]: borrowed data escapes outside of function
2-
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
2+
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5
33
|
44
LL | fn foo(x: &()) {
55
| - - let's call the lifetime of this reference `'1`
66
| |
77
| `x` is a reference that is only valid in the function body
88
LL | / bar(|| {
99
LL | |
10+
LL | |
11+
LL | |
1012
LL | | let _ = x;
1113
LL | | })
1214
| | ^
@@ -15,19 +17,21 @@ LL | | })
1517
| argument requires that `'1` must outlive `'static`
1618

1719
error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function
18-
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:9
20+
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:9
1921
|
2022
LL | bar(|| {
2123
| ^^ may outlive borrowed value `x`
22-
LL |
24+
...
2325
LL | let _ = x;
2426
| - `x` is borrowed here
2527
|
2628
note: function requires argument type to outlive `'static`
27-
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
29+
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5
2830
|
2931
LL | / bar(|| {
3032
LL | |
33+
LL | |
34+
LL | |
3135
LL | | let _ = x;
3236
LL | | })
3337
| |______^

src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
// ignore-compare-mode-nll
2+
// revisions: base nll
3+
// [nll]compile-flags: -Zborrowck=mir
4+
15
fn bar<F>(blk: F) where F: FnOnce() + 'static {
26
}
37

48
fn foo(x: &()) {
59
bar(|| {
6-
//~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
10+
//[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
11+
//[nll]~^^ ERROR borrowed data escapes
12+
//[nll]~| ERROR closure may outlive
713
let _ = x;
814
})
915
}

src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr renamed to src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.base.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0308]: mismatched types
2-
--> $DIR/expect-region-supply-region-2.rs:14:33
2+
--> $DIR/expect-region-supply-region-2.rs:18:33
33
|
44
LL | closure_expecting_bound(|x: &'x u32| {
55
| ^^^^^^^ lifetime mismatch
66
|
77
= note: expected reference `&u32`
88
found reference `&'x u32`
99
note: the anonymous lifetime #1 defined here...
10-
--> $DIR/expect-region-supply-region-2.rs:14:29
10+
--> $DIR/expect-region-supply-region-2.rs:18:29
1111
|
1212
LL | closure_expecting_bound(|x: &'x u32| {
1313
| _____________________________^
@@ -19,26 +19,26 @@ LL | | f = Some(x);
1919
LL | | });
2020
| |_____^
2121
note: ...does not necessarily outlive the lifetime `'x` as defined here
22-
--> $DIR/expect-region-supply-region-2.rs:9:30
22+
--> $DIR/expect-region-supply-region-2.rs:13:30
2323
|
2424
LL | fn expect_bound_supply_named<'x>() {
2525
| ^^
2626

2727
error[E0308]: mismatched types
28-
--> $DIR/expect-region-supply-region-2.rs:14:33
28+
--> $DIR/expect-region-supply-region-2.rs:18:33
2929
|
3030
LL | closure_expecting_bound(|x: &'x u32| {
3131
| ^^^^^^^ lifetime mismatch
3232
|
3333
= note: expected reference `&u32`
3434
found reference `&'x u32`
3535
note: the lifetime `'x` as defined here...
36-
--> $DIR/expect-region-supply-region-2.rs:9:30
36+
--> $DIR/expect-region-supply-region-2.rs:13:30
3737
|
3838
LL | fn expect_bound_supply_named<'x>() {
3939
| ^^
4040
note: ...does not necessarily outlive the anonymous lifetime #1 defined here
41-
--> $DIR/expect-region-supply-region-2.rs:14:29
41+
--> $DIR/expect-region-supply-region-2.rs:18:29
4242
|
4343
LL | closure_expecting_bound(|x: &'x u32| {
4444
| _____________________________^

src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: lifetime may not live long enough
2-
--> $DIR/expect-region-supply-region-2.rs:14:30
2+
--> $DIR/expect-region-supply-region-2.rs:18:30
33
|
44
LL | fn expect_bound_supply_named<'x>() {
55
| -- lifetime `'x` defined here
@@ -10,7 +10,7 @@ LL | closure_expecting_bound(|x: &'x u32| {
1010
| requires that `'1` must outlive `'x`
1111

1212
error: lifetime may not live long enough
13-
--> $DIR/expect-region-supply-region-2.rs:14:30
13+
--> $DIR/expect-region-supply-region-2.rs:18:30
1414
|
1515
LL | fn expect_bound_supply_named<'x>() {
1616
| -- lifetime `'x` defined here

src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// ignore-compare-mode-nll
2+
// revisions: base nll
3+
// [nll]compile-flags: -Zborrowck=mir
4+
15
#![allow(warnings)]
26

37
fn closure_expecting_bound<F>(_: F)
@@ -12,8 +16,10 @@ fn expect_bound_supply_named<'x>() {
1216
// Here we give a type annotation that `x` should be free. We get
1317
// an error because of that.
1418
closure_expecting_bound(|x: &'x u32| {
15-
//~^ ERROR mismatched types
16-
//~| ERROR mismatched types
19+
//[base]~^ ERROR mismatched types
20+
//[base]~| ERROR mismatched types
21+
//[nll]~^^^ ERROR lifetime may not live long enough
22+
//[nll]~| ERROR lifetime may not live long enough
1723

1824
// Borrowck doesn't get a chance to run, but if it did it should error
1925
// here.

0 commit comments

Comments
 (0)