Skip to content

Commit 1703f87

Browse files
author
Jonathan Turner
authored
Rollup merge of #35455 - munyari:e0204, r=jonathandturner
Update E0204 to the new error format Part of #35233 Addresses #35381 "r? @jonathandturner
2 parents 236c089 + 54e1e98 commit 1703f87

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/librustc_typeck/coherence/mod.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,14 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> {
311311
match param_env.can_type_implement_copy(tcx, self_type, span) {
312312
Ok(()) => {}
313313
Err(CopyImplementationError::InfrigingField(name)) => {
314-
span_err!(tcx.sess, span, E0204,
315-
"the trait `Copy` may not be \
316-
implemented for this type; field \
317-
`{}` does not implement `Copy`",
318-
name)
314+
struct_span_err!(tcx.sess, span, E0204,
315+
"the trait `Copy` may not be implemented for \
316+
this type")
317+
.span_label(span, &format!(
318+
"field `{}` does not implement `Copy`", name)
319+
)
320+
.emit()
321+
319322
}
320323
Err(CopyImplementationError::InfrigingVariant(name)) => {
321324
span_err!(tcx.sess, span, E0205,

src/test/compile-fail/E0204.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ struct Foo {
1212
foo: Vec<u32>,
1313
}
1414

15-
impl Copy for Foo { } //~ ERROR E0204
15+
impl Copy for Foo { }
16+
//~^ ERROR E0204
17+
//~| NOTE field `foo` does not implement `Copy`
1618

17-
#[derive(Copy)] //~ ERROR E0204
19+
#[derive(Copy)]
20+
//~^ ERROR E0204
21+
//~| NOTE field `ty` does not implement `Copy`
22+
//~| NOTE in this expansion of #[derive(Copy)]
1823
struct Foo2<'a> {
1924
ty: &'a mut bool,
2025
}

src/test/compile-fail/issue-27340.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
struct Foo;
1212
#[derive(Copy, Clone)]
13-
//~^ ERROR the trait `Copy` may not be implemented for this type; field `0` does not implement
13+
//~^ ERROR the trait `Copy` may not be implemented for this type
1414
struct Bar(Foo);
1515

1616
fn main() {}

0 commit comments

Comments
 (0)