Skip to content

Commit 9c97d73

Browse files
committed
Tweak move error due to non-Copy
1 parent 9a59541 commit 9c97d73

File tree

10 files changed

+31
-175
lines changed

10 files changed

+31
-175
lines changed

src/librustc_mir/borrow_check/move_errors.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
555555
err: &mut DiagnosticBuilder<'a>,
556556
binds_to: &[Local],
557557
) {
558-
let mut noncopy_var_spans = Vec::new();
559558
for (j, local) in binds_to.into_iter().enumerate() {
560559
let bind_to = &self.body.local_decls[*local];
561560
let binding_span = bind_to.source_info.span;
@@ -573,16 +572,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
573572
bind_to.ty,
574573
Some(binding_span)
575574
);
576-
} else {
577-
noncopy_var_spans.push(binding_span);
578575
}
579576
}
580577

581578
if binds_to.len() > 1 {
582-
err.span_note(
583-
noncopy_var_spans,
584-
"move occurs because these variables have types that \
585-
don't implement the `Copy` trait",
579+
err.note("move occurs because these variables have types that \
580+
don't implement the `Copy` trait",
586581
);
587582
}
588583
}

src/test/ui/borrowck/borrowck-move-error-with-note.stderr

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@ LL | num2) => (),
1010
LL | Foo::Foo2(num) => (),
1111
| --- ...and here
1212
|
13-
note: move occurs because these variables have types that don't implement the `Copy` trait
14-
--> $DIR/borrowck-move-error-with-note.rs:12:19
15-
|
16-
LL | Foo::Foo1(num1,
17-
| ^^^^
18-
LL | num2) => (),
19-
| ^^^^
20-
LL | Foo::Foo2(num) => (),
21-
| ^^^
13+
= note: move occurs because these variables have types that don't implement the `Copy` trait
2214

2315
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
2416
--> $DIR/borrowck-move-error-with-note.rs:28:11
@@ -31,13 +23,7 @@ LL | f: _s,
3123
LL | g: _t
3224
| -- ...and here
3325
|
34-
note: move occurs because these variables have types that don't implement the `Copy` trait
35-
--> $DIR/borrowck-move-error-with-note.rs:31:16
36-
|
37-
LL | f: _s,
38-
| ^^
39-
LL | g: _t
40-
| ^^
26+
= note: move occurs because these variables have types that don't implement the `Copy` trait
4127

4228
error[E0507]: cannot move out of `a.a` which is behind a shared reference
4329
--> $DIR/borrowck-move-error-with-note.rs:46:11

src/test/ui/borrowck/borrowck-move-out-of-vec-tail.stderr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ LL | &[Foo { string: a },
99
LL | Foo { string: b }] => {
1010
| - ...and here
1111
|
12-
note: move occurs because these variables have types that don't implement the `Copy` trait
13-
--> $DIR/borrowck-move-out-of-vec-tail.rs:21:33
14-
|
15-
LL | &[Foo { string: a },
16-
| ^
17-
LL | Foo { string: b }] => {
18-
| ^
12+
= note: move occurs because these variables have types that don't implement the `Copy` trait
1913
help: consider removing the `&`
2014
|
2115
LL | [Foo { string: a },

src/test/ui/borrowck/borrowck-vec-pattern-nesting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ fn e() {
7575
match vec {
7676
//~^ ERROR cannot move out
7777
//~| NOTE cannot move out
78+
//~| NOTE move occurs because these variables have types
7879
&mut [_a, _b, _c] => {}
7980
//~^ NOTE data moved here
8081
//~| NOTE and here
8182
//~| NOTE and here
8283
//~| HELP consider removing the `&mut`
83-
//~| NOTE move occurs because these variables have types
8484
_ => {}
8585
}
8686
let a = vec[0]; //~ ERROR cannot move out

src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,7 @@ LL | &mut [_a, _b, _c] => {}
9797
| | data moved here
9898
| help: consider removing the `&mut`: `[_a, _b, _c]`
9999
|
100-
note: move occurs because these variables have types that don't implement the `Copy` trait
101-
--> $DIR/borrowck-vec-pattern-nesting.rs:78:15
102-
|
103-
LL | &mut [_a, _b, _c] => {}
104-
| ^^ ^^ ^^
100+
= note: move occurs because these variables have types that don't implement the `Copy` trait
105101

106102
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
107103
--> $DIR/borrowck-vec-pattern-nesting.rs:86:13

src/test/ui/issues/issue-12567.stderr

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@ LL | => println!("one empty"),
1010
LL | (&[hd1, ..], &[hd2, ..])
1111
| --- ...and here
1212
|
13-
note: move occurs because these variables have types that don't implement the `Copy` trait
14-
--> $DIR/issue-12567.rs:8:17
15-
|
16-
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
17-
| ^^
18-
LL | => println!("one empty"),
19-
LL | (&[hd1, ..], &[hd2, ..])
20-
| ^^^
13+
= note: move occurs because these variables have types that don't implement the `Copy` trait
2114

2215
error[E0508]: cannot move out of type `[T]`, a non-copy slice
2316
--> $DIR/issue-12567.rs:4:11
@@ -31,14 +24,7 @@ LL | => println!("one empty"),
3124
LL | (&[hd1, ..], &[hd2, ..])
3225
| --- ...and here
3326
|
34-
note: move occurs because these variables have types that don't implement the `Copy` trait
35-
--> $DIR/issue-12567.rs:8:17
36-
|
37-
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
38-
| ^^
39-
LL | => println!("one empty"),
40-
LL | (&[hd1, ..], &[hd2, ..])
41-
| ^^^
27+
= note: move occurs because these variables have types that don't implement the `Copy` trait
4228

4329
error: aborting due to 2 previous errors
4430

src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.stderr

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ LL | let (a, b) = x[0];
77
| | ...and here
88
| data moved here
99
|
10-
note: move occurs because these variables have types that don't implement the `Copy` trait
11-
--> $DIR/issue-40402-2.rs:5:10
12-
|
13-
LL | let (a, b) = x[0];
14-
| ^ ^
10+
= note: move occurs because these variables have types that don't implement the `Copy` trait
1511

1612
error: aborting due to previous error
1713

src/test/ui/nll/move-errors.stderr

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,7 @@ LL | B::U(d) => (),
8383
LL | B::V(s) => (),
8484
| - ...and here
8585
|
86-
note: move occurs because these variables have types that don't implement the `Copy` trait
87-
--> $DIR/move-errors.rs:76:14
88-
|
89-
LL | B::U(d) => (),
90-
| ^
91-
LL | B::V(s) => (),
92-
| ^
86+
= note: move occurs because these variables have types that don't implement the `Copy` trait
9387

9488
error[E0509]: cannot move out of type `D`, which implements the `Drop` trait
9589
--> $DIR/move-errors.rs:83:11
@@ -138,11 +132,7 @@ LL | F(s, mut t) => (),
138132
| |
139133
| data moved here
140134
|
141-
note: move occurs because these variables have types that don't implement the `Copy` trait
142-
--> $DIR/move-errors.rs:104:11
143-
|
144-
LL | F(s, mut t) => (),
145-
| ^ ^^^^^
135+
= note: move occurs because these variables have types that don't implement the `Copy` trait
146136

147137
error[E0507]: cannot move out of `x.0` which is behind a shared reference
148138
--> $DIR/move-errors.rs:110:11

0 commit comments

Comments
 (0)