Skip to content

Commit 3deb757

Browse files
committed
Merge all "Copy not implemented" errors
1 parent 804bcf7 commit 3deb757

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

src/librustc_typeck/coherence/builtin.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,14 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
121121
span
122122
};
123123

124-
for field in fields {
125-
struct_span_err!(tcx.sess,
126-
span,
127-
E0204,
128-
"the trait `Copy` may not be implemented for this type")
129-
.span_label(
130-
tcx.def_span(field.did),
131-
"this field does not implement `Copy`")
132-
.emit()
124+
let mut err = struct_span_err!(tcx.sess,
125+
span,
126+
E0204,
127+
"the trait `Copy` may not be implemented for this type");
128+
for span in fields.iter().map(|f| tcx.def_span(f.did)) {
129+
err.span_label(span, "this field does not implement `Copy`");
133130
}
131+
err.emit()
134132
}
135133
Err(CopyImplementationError::NotAnAdt) => {
136134
let item = tcx.hir.expect_item(impl_node_id);

src/test/ui/issue-50480.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#[derive(Clone, Copy)]
1212
//~^ ERROR the trait `Copy` may not be implemented for this type
13-
//~| ERROR the trait `Copy` may not be implemented for this type
1413
struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
1514
//~^ ERROR cannot find type `NotDefined` in this scope
1615
//~| ERROR the trait bound `i32: std::iter::Iterator` is not satisfied

src/test/ui/issue-50480.stderr

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0412]: cannot find type `NotDefined` in this scope
2-
--> $DIR/issue-50480.rs:14:12
2+
--> $DIR/issue-50480.rs:13:12
33
|
44
LL | struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
55
| ^^^^^^^^^^ not found in this scope
66

77
error[E0277]: the trait bound `i32: std::iter::Iterator` is not satisfied
8-
--> $DIR/issue-50480.rs:14:24
8+
--> $DIR/issue-50480.rs:13:24
99
|
1010
LL | struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator; maybe try calling `.iter()` or a similar method
@@ -17,20 +17,13 @@ error[E0204]: the trait `Copy` may not be implemented for this type
1717
|
1818
LL | #[derive(Clone, Copy)]
1919
| ^^^^
20-
...
20+
LL | //~^ ERROR the trait `Copy` may not be implemented for this type
2121
LL | struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
22-
| --------- this field does not implement `Copy`
22+
| --------- ------- this field does not implement `Copy`
23+
| |
24+
| this field does not implement `Copy`
2325

24-
error[E0204]: the trait `Copy` may not be implemented for this type
25-
--> $DIR/issue-50480.rs:11:17
26-
|
27-
LL | #[derive(Clone, Copy)]
28-
| ^^^^
29-
...
30-
LL | struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
31-
| ------- this field does not implement `Copy`
32-
33-
error: aborting due to 4 previous errors
26+
error: aborting due to 3 previous errors
3427

3528
Some errors occurred: E0204, E0277, E0412.
3629
For more information about an error, try `rustc --explain E0204`.

0 commit comments

Comments
 (0)