Skip to content

Commit 4226930

Browse files
committed
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>` ```
1 parent 39c267a commit 4226930

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/librustc_typeck/check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
10901090
} else {
10911091
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0323,
10921092
"item `{}` is an associated const, \
1093-
which doesn't match its trait `{:?}`",
1093+
which doesn't match its trait `{}`",
10941094
ty_impl_item.name,
10951095
impl_trait_ref);
10961096
err.span_label(impl_item.span, &format!("does not match trait"));
@@ -1128,7 +1128,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
11281128
} else {
11291129
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0324,
11301130
"item `{}` is an associated method, \
1131-
which doesn't match its trait `{:?}`",
1131+
which doesn't match its trait `{}`",
11321132
ty_impl_item.name,
11331133
impl_trait_ref);
11341134
err.span_label(impl_item.span, &format!("does not match trait"));
@@ -1146,7 +1146,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
11461146
} else {
11471147
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0325,
11481148
"item `{}` is an associated type, \
1149-
which doesn't match its trait `{:?}`",
1149+
which doesn't match its trait `{}`",
11501150
ty_impl_item.name,
11511151
impl_trait_ref);
11521152
err.span_label(impl_item.span, &format!("does not match trait"));

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

+3-3
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);
@@ -16,7 +16,7 @@ error[E0046]: not all trait items implemented, missing: `bar`
1616
22 | impl Foo for FooConstForMethod {
1717
| ^ missing `bar` in implementation
1818

19-
error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `<FooMethodForConst as Foo>`
19+
error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `Foo`
2020
--> $DIR/impl-wrong-item-for-trait.rs:37:5
2121
|
2222
17 | const MY_CONST: u32;
@@ -34,7 +34,7 @@ error[E0046]: not all trait items implemented, missing: `MY_CONST`
3434
33 | impl Foo for FooMethodForConst {
3535
| ^ missing `MY_CONST` in implementation
3636

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

0 commit comments

Comments
 (0)