Skip to content

Commit

Permalink
Show Trait instead of <Struct as Trait> in E0323
Browse files Browse the repository at this point in the history
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>`
```
  • Loading branch information
estebank committed Nov 29, 2016
1 parent 39c267a commit 4226930
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
} else {
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0323,
"item `{}` is an associated const, \
which doesn't match its trait `{:?}`",
which doesn't match its trait `{}`",
ty_impl_item.name,
impl_trait_ref);
err.span_label(impl_item.span, &format!("does not match trait"));
Expand Down Expand Up @@ -1128,7 +1128,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
} else {
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0324,
"item `{}` is an associated method, \
which doesn't match its trait `{:?}`",
which doesn't match its trait `{}`",
ty_impl_item.name,
impl_trait_ref);
err.span_label(impl_item.span, &format!("does not match trait"));
Expand All @@ -1146,7 +1146,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
} else {
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0325,
"item `{}` is an associated type, \
which doesn't match its trait `{:?}`",
which doesn't match its trait `{}`",
ty_impl_item.name,
impl_trait_ref);
err.span_label(impl_item.span, &format!("does not match trait"));
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/span/impl-wrong-item-for-trait.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0323]: item `bar` is an associated const, which doesn't match its trait `<FooConstForMethod as Foo>`
error[E0323]: item `bar` is an associated const, which doesn't match its trait `Foo`
--> $DIR/impl-wrong-item-for-trait.rs:25:5
|
16 | fn bar(&self);
Expand All @@ -16,7 +16,7 @@ error[E0046]: not all trait items implemented, missing: `bar`
22 | impl Foo for FooConstForMethod {
| ^ missing `bar` in implementation

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

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

0 comments on commit 4226930

Please sign in to comment.