Skip to content

Commit e55d82c

Browse files
qnighycrlf0710
authored andcommitted
Fix expectations on some ui tests involving FnOnce.
1 parent 219097e commit e55d82c

7 files changed

+42
-72
lines changed

src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | f(f(10));
77
| first mutable borrow occurs here
88
| first borrow later used by call
99

10-
error[E0382]: use of moved value: `*f`
10+
error[E0382]: use of moved value: `f`
1111
--> $DIR/two-phase-nonrecv-autoref.rs:69:11
1212
|
1313
LL | fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
@@ -17,7 +17,7 @@ LL | f(f(10));
1717
| |
1818
| value moved here
1919
|
20-
= note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait
20+
= note: move occurs because `f` has type `std::boxed::Box<F>`, which does not implement the `Copy` trait
2121

2222
error[E0499]: cannot borrow `*f` as mutable more than once at a time
2323
--> $DIR/two-phase-nonrecv-autoref.rs:76:11
@@ -28,30 +28,18 @@ LL | f(f(10));
2828
| first mutable borrow occurs here
2929
| first borrow later used by call
3030

31-
error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined
32-
--> $DIR/two-phase-nonrecv-autoref.rs:85:9
33-
|
34-
LL | f(f(10));
35-
| ^
36-
37-
error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined
38-
--> $DIR/two-phase-nonrecv-autoref.rs:85:11
39-
|
40-
LL | f(f(10));
41-
| ^
42-
43-
error[E0382]: use of moved value: `*f`
31+
error[E0382]: use of moved value: `f`
4432
--> $DIR/two-phase-nonrecv-autoref.rs:85:11
4533
|
4634
LL | f(f(10));
4735
| - ^ value used here after move
4836
| |
4937
| value moved here
5038
|
51-
= note: move occurs because `*f` has type `dyn std::ops::FnOnce(i32) -> i32`, which does not implement the `Copy` trait
39+
= note: move occurs because `f` has type `std::boxed::Box<dyn std::ops::FnOnce(i32) -> i32>`, which does not implement the `Copy` trait
5240

5341
error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
54-
--> $DIR/two-phase-nonrecv-autoref.rs:129:27
42+
--> $DIR/two-phase-nonrecv-autoref.rs:125:27
5543
|
5644
LL | double_access(&mut a, &a);
5745
| ------------- ------ ^^ immutable borrow occurs here
@@ -60,7 +48,7 @@ LL | double_access(&mut a, &a);
6048
| mutable borrow later used by call
6149

6250
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
63-
--> $DIR/two-phase-nonrecv-autoref.rs:157:7
51+
--> $DIR/two-phase-nonrecv-autoref.rs:153:7
6452
|
6553
LL | i[i[3]] = 4;
6654
| --^----
@@ -70,7 +58,7 @@ LL | i[i[3]] = 4;
7058
| mutable borrow later used here
7159

7260
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
73-
--> $DIR/two-phase-nonrecv-autoref.rs:163:7
61+
--> $DIR/two-phase-nonrecv-autoref.rs:159:7
7462
|
7563
LL | i[i[3]] = i[4];
7664
| --^----
@@ -79,7 +67,7 @@ LL | i[i[3]] = i[4];
7967
| mutable borrow occurs here
8068
| mutable borrow later used here
8169

82-
error: aborting due to 9 previous errors
70+
error: aborting due to 7 previous errors
8371

84-
Some errors occurred: E0161, E0382, E0499, E0502.
85-
For more information about an error, try `rustc --explain E0161`.
72+
Some errors occurred: E0382, E0499, E0502.
73+
For more information about an error, try `rustc --explain E0382`.

src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.stderr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ LL | f(f(10));
1515
| | second mutable borrow occurs here
1616
| first mutable borrow occurs here
1717

18-
error[E0382]: use of moved value: `*f`
18+
error[E0382]: use of moved value: `f`
1919
--> $DIR/two-phase-nonrecv-autoref.rs:69:11
2020
|
2121
LL | f(f(10));
2222
| - ^ value used here after move
2323
| |
2424
| value moved here
2525
|
26-
= note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait
26+
= note: move occurs because `f` has type `std::boxed::Box<F>`, which does not implement the `Copy` trait
2727

2828
error[E0499]: cannot borrow `*f` as mutable more than once at a time
2929
--> $DIR/two-phase-nonrecv-autoref.rs:76:11
@@ -34,18 +34,18 @@ LL | f(f(10));
3434
| | second mutable borrow occurs here
3535
| first mutable borrow occurs here
3636

37-
error[E0382]: use of moved value: `*f`
37+
error[E0382]: use of moved value: `f`
3838
--> $DIR/two-phase-nonrecv-autoref.rs:85:11
3939
|
4040
LL | f(f(10));
4141
| - ^ value used here after move
4242
| |
4343
| value moved here
4444
|
45-
= note: move occurs because `*f` has type `(dyn std::ops::FnOnce(i32) -> i32 + 'static)`, which does not implement the `Copy` trait
45+
= note: move occurs because `f` has type `std::boxed::Box<(dyn std::ops::FnOnce(i32) -> i32 + 'static)>`, which does not implement the `Copy` trait
4646

4747
error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
48-
--> $DIR/two-phase-nonrecv-autoref.rs:129:28
48+
--> $DIR/two-phase-nonrecv-autoref.rs:125:28
4949
|
5050
LL | double_access(&mut a, &a);
5151
| - ^- mutable borrow ends here
@@ -54,7 +54,7 @@ LL | double_access(&mut a, &a);
5454
| mutable borrow occurs here
5555

5656
error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
57-
--> $DIR/two-phase-nonrecv-autoref.rs:135:9
57+
--> $DIR/two-phase-nonrecv-autoref.rs:131:9
5858
|
5959
LL | a.m(a.i(10));
6060
| - ^ - mutable borrow ends here
@@ -63,7 +63,7 @@ LL | a.m(a.i(10));
6363
| mutable borrow occurs here
6464

6565
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
66-
--> $DIR/two-phase-nonrecv-autoref.rs:157:7
66+
--> $DIR/two-phase-nonrecv-autoref.rs:153:7
6767
|
6868
LL | i[i[3]] = 4;
6969
| - ^ - mutable borrow ends here
@@ -72,7 +72,7 @@ LL | i[i[3]] = 4;
7272
| mutable borrow occurs here
7373

7474
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
75-
--> $DIR/two-phase-nonrecv-autoref.rs:163:7
75+
--> $DIR/two-phase-nonrecv-autoref.rs:159:7
7676
|
7777
LL | i[i[3]] = i[4];
7878
| - ^ - mutable borrow ends here
@@ -81,7 +81,7 @@ LL | i[i[3]] = i[4];
8181
| mutable borrow occurs here
8282

8383
error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable
84-
--> $DIR/two-phase-nonrecv-autoref.rs:172:12
84+
--> $DIR/two-phase-nonrecv-autoref.rs:168:12
8585
|
8686
LL | v.push(v.len());
8787
| - ^ - mutable borrow ends here
@@ -90,7 +90,7 @@ LL | v.push(v.len());
9090
| mutable borrow occurs here
9191

9292
error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable
93-
--> $DIR/two-phase-nonrecv-autoref.rs:183:9
93+
--> $DIR/two-phase-nonrecv-autoref.rs:179:9
9494
|
9595
LL | s.m(s.i(10));
9696
| - ^ - mutable borrow ends here
@@ -99,7 +99,7 @@ LL | s.m(s.i(10));
9999
| mutable borrow occurs here
100100

101101
error[E0502]: cannot borrow `t` as immutable because it is also borrowed as mutable
102-
--> $DIR/two-phase-nonrecv-autoref.rs:188:9
102+
--> $DIR/two-phase-nonrecv-autoref.rs:184:9
103103
|
104104
LL | t.m(t.i(10));
105105
| - ^ - mutable borrow ends here

src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ LL | f(f(10));
77
| first mutable borrow occurs here
88
| first borrow later used by call
99

10-
error[E0382]: use of moved value: `*f`
10+
error[E0382]: use of moved value: `f`
1111
--> $DIR/two-phase-nonrecv-autoref.rs:69:11
1212
|
1313
LL | fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
14-
| - consider adding a `Copy` constraint to this type argument
14+
| - move occurs because `f` has type `std::boxed::Box<F>`, which does not implement the `Copy` trait
1515
LL | f(f(10));
1616
| - ^ value used here after move
1717
| |
1818
| value moved here
19-
|
20-
= note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait
2119

2220
error[E0499]: cannot borrow `*f` as mutable more than once at a time
2321
--> $DIR/two-phase-nonrecv-autoref.rs:76:11
@@ -28,30 +26,18 @@ LL | f(f(10));
2826
| first mutable borrow occurs here
2927
| first borrow later used by call
3028

31-
error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined
32-
--> $DIR/two-phase-nonrecv-autoref.rs:85:9
33-
|
34-
LL | f(f(10));
35-
| ^
36-
37-
error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined
38-
--> $DIR/two-phase-nonrecv-autoref.rs:85:11
39-
|
40-
LL | f(f(10));
41-
| ^
42-
43-
error[E0382]: use of moved value: `*f`
29+
error[E0382]: use of moved value: `f`
4430
--> $DIR/two-phase-nonrecv-autoref.rs:85:11
4531
|
32+
LL | fn twice_ten_oo(f: Box<FnOnce(i32) -> i32>) {
33+
| - move occurs because `f` has type `std::boxed::Box<dyn std::ops::FnOnce(i32) -> i32>`, which does not implement the `Copy` trait
4634
LL | f(f(10));
4735
| - ^ value used here after move
4836
| |
4937
| value moved here
50-
|
51-
= note: move occurs because `*f` has type `dyn std::ops::FnOnce(i32) -> i32`, which does not implement the `Copy` trait
5238

5339
error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
54-
--> $DIR/two-phase-nonrecv-autoref.rs:129:27
40+
--> $DIR/two-phase-nonrecv-autoref.rs:125:27
5541
|
5642
LL | double_access(&mut a, &a);
5743
| ------------- ------ ^^ immutable borrow occurs here
@@ -60,7 +46,7 @@ LL | double_access(&mut a, &a);
6046
| mutable borrow later used by call
6147

6248
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
63-
--> $DIR/two-phase-nonrecv-autoref.rs:157:7
49+
--> $DIR/two-phase-nonrecv-autoref.rs:153:7
6450
|
6551
LL | i[i[3]] = 4;
6652
| --^----
@@ -70,7 +56,7 @@ LL | i[i[3]] = 4;
7056
| mutable borrow later used here
7157

7258
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
73-
--> $DIR/two-phase-nonrecv-autoref.rs:163:7
59+
--> $DIR/two-phase-nonrecv-autoref.rs:159:7
7460
|
7561
LL | i[i[3]] = i[4];
7662
| --^----
@@ -79,7 +65,7 @@ LL | i[i[3]] = i[4];
7965
| mutable borrow occurs here
8066
| mutable borrow later used here
8167

82-
error: aborting due to 9 previous errors
68+
error: aborting due to 7 previous errors
8369

84-
Some errors occurred: E0161, E0382, E0499, E0502.
85-
For more information about an error, try `rustc --explain E0161`.
70+
Some errors occurred: E0382, E0499, E0502.
71+
For more information about an error, try `rustc --explain E0382`.

src/test/ui/borrowck/two-phase-nonrecv-autoref.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ fn overloaded_call_traits() {
6767
}
6868
fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
6969
f(f(10));
70-
//[nll]~^ ERROR use of moved value: `*f`
71-
//[g2p]~^^ ERROR use of moved value: `*f`
72-
//[ast]~^^^ ERROR use of moved value: `*f`
70+
//[nll]~^ ERROR use of moved value: `f`
71+
//[g2p]~^^ ERROR use of moved value: `f`
72+
//[ast]~^^^ ERROR use of moved value: `f`
7373
}
7474

7575
fn twice_ten_om(f: &mut FnMut(i32) -> i32) {
@@ -83,13 +83,9 @@ fn overloaded_call_traits() {
8383
}
8484
fn twice_ten_oo(f: Box<FnOnce(i32) -> i32>) {
8585
f(f(10));
86-
//[nll]~^ ERROR cannot move a value of type
87-
//[nll]~^^ ERROR cannot move a value of type
88-
//[nll]~^^^ ERROR use of moved value: `*f`
89-
//[g2p]~^^^^ ERROR cannot move a value of type
90-
//[g2p]~^^^^^ ERROR cannot move a value of type
91-
//[g2p]~^^^^^^ ERROR use of moved value: `*f`
92-
//[ast]~^^^^^^^ ERROR use of moved value: `*f`
86+
//[nll]~^ ERROR use of moved value: `f`
87+
//[g2p]~^^ ERROR use of moved value: `f`
88+
//[ast]~^^^ ERROR use of moved value: `f`
9389
}
9490

9591
twice_ten_sm(&mut |x| x + 1);

src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LL | fn test2<F>(f: &F) where F: FnMut() {
1818
LL | (*f)();
1919
| ^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable
2020

21-
error[E0596]: cannot borrow `*f.f` as mutable, as it is behind a `&` reference
21+
error[E0596]: cannot borrow `f.f` as mutable, as it is behind a `&` reference
2222
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5
2323
|
2424
LL | fn test4(f: &Test) {

src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn test3<F>(f: &mut F) where F: FnMut() {
3232

3333
fn test4(f: &Test) {
3434
f.f.call_mut(())
35-
//~^ ERROR: cannot borrow `Box` content `*f.f` of immutable binding as mutable
35+
//~^ ERROR: cannot borrow field `f.f` of immutable binding as mutable
3636
}
3737

3838
fn test5(f: &mut Test) {

src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ LL | fn test2<F>(f: &F) where F: FnMut() {
1919
LL | (*f)();
2020
| ^^^^ cannot borrow as mutable
2121

22-
error[E0596]: cannot borrow `Box` content `*f.f` of immutable binding as mutable
22+
error[E0596]: cannot borrow field `f.f` of immutable binding as mutable
2323
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5
2424
|
2525
LL | fn test4(f: &Test) {
2626
| ----- use `&mut Test` here to make mutable
2727
LL | f.f.call_mut(())
28-
| ^^^ cannot borrow as mutable
28+
| ^^^ cannot mutably borrow field of immutable binding
2929

3030
error[E0504]: cannot move `f` into closure because it is borrowed
3131
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:56:13

0 commit comments

Comments
 (0)