Skip to content

Commit 9aef89e

Browse files
authored
Rollup merge of rust-lang#38065 - estebank:fix-37618, r=jonathandturner
Show `Trait` instead of `<Struct as Trait>` in E0323 For a given file ``` trait Foo { fn bar(&self); } pub struct FooConstForMethod; impl Foo for FooConstForMethod { const bar: u64 = 1; } ``` show ``` error[E0323]: item `bar` is an associated const, which doesn't match its trait `Foo` ``` instead of ``` error[E0323]: item `bar` is an associated const, which doesn't match its trait `<FooConstForMethod as Foo>` ``` Fix rust-lang#37618
2 parents 78c1046 + 4226930 commit 9aef89e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
11011101
} else {
11021102
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0323,
11031103
"item `{}` is an associated const, \
1104-
which doesn't match its trait `{:?}`",
1104+
which doesn't match its trait `{}`",
11051105
ty_impl_item.name,
11061106
impl_trait_ref);
11071107
err.span_label(impl_item.span, &format!("does not match trait"));
@@ -1139,7 +1139,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
11391139
} else {
11401140
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0324,
11411141
"item `{}` is an associated method, \
1142-
which doesn't match its trait `{:?}`",
1142+
which doesn't match its trait `{}`",
11431143
ty_impl_item.name,
11441144
impl_trait_ref);
11451145
err.span_label(impl_item.span, &format!("does not match trait"));
@@ -1157,7 +1157,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
11571157
} else {
11581158
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0325,
11591159
"item `{}` is an associated type, \
1160-
which doesn't match its trait `{:?}`",
1160+
which doesn't match its trait `{}`",
11611161
ty_impl_item.name,
11621162
impl_trait_ref);
11631163
err.span_label(impl_item.span, &format!("does not match trait"));

src/test/ui/span/impl-wrong-item-for-trait.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0323]: item `bar` is an associated const, which doesn't match its trait `<FooConstForMethod as Foo>`
1+
error[E0323]: item `bar` is an associated const, which doesn't match its trait `Foo`
22
--> $DIR/impl-wrong-item-for-trait.rs:25:5
33
|
44
16 | fn bar(&self);
@@ -24,7 +24,7 @@ error[E0046]: not all trait items implemented, missing: `bar`
2424
29 | | }
2525
| |_^ ...ending here: missing `bar` in implementation
2626

27-
error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `<FooMethodForConst as Foo>`
27+
error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `Foo`
2828
--> $DIR/impl-wrong-item-for-trait.rs:37:5
2929
|
3030
17 | const MY_CONST: u32;
@@ -50,7 +50,7 @@ error[E0046]: not all trait items implemented, missing: `MY_CONST`
5050
40 | | }
5151
| |_^ ...ending here: missing `MY_CONST` in implementation
5252

53-
error[E0325]: item `bar` is an associated type, which doesn't match its trait `<FooTypeForMethod as Foo>`
53+
error[E0325]: item `bar` is an associated type, which doesn't match its trait `Foo`
5454
--> $DIR/impl-wrong-item-for-trait.rs:47:5
5555
|
5656
16 | fn bar(&self);

0 commit comments

Comments
 (0)