Skip to content

Commit

Permalink
Updates compiler error E0046 with new format
Browse files Browse the repository at this point in the history
  • Loading branch information
shri3k committed Aug 6, 2016
1 parent 545a3a9 commit 9f09ee5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,11 +1117,16 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
}

if !missing_items.is_empty() {
span_err!(tcx.sess, impl_span, E0046,
struct_span_err!(tcx.sess, impl_span, E0046,
"not all trait items implemented, missing: `{}`",
missing_items.iter()
.map(|name| name.to_string())
.collect::<Vec<_>>().join("`, `"))
.span_label(impl_span, &format!("missing `{}` in implementation",
missing_items.iter()
.map(|name| name.to_string())
.collect::<Vec<_>>().join("`, `"))
).emit();
}

if !invalidated_items.is_empty() {
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0046.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ trait Foo {

struct Bar;

impl Foo for Bar {} //~ ERROR E0046
impl Foo for Bar {}
//~^ ERROR E0046
//~| NOTE missing `foo` in implementation

fn main() {
}
3 changes: 3 additions & 0 deletions src/test/compile-fail/impl-wrong-item-for-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct FooConstForMethod;

impl Foo for FooConstForMethod {
//~^ ERROR E0046
//~| NOTE missing `bar` in implementation
const bar: u64 = 1;
//~^ ERROR E0323
const MY_CONST: u32 = 1;
Expand All @@ -28,6 +29,7 @@ pub struct FooMethodForConst;

impl Foo for FooMethodForConst {
//~^ ERROR E0046
//~| NOTE missing `MY_CONST` in implementation
fn bar(&self) {}
fn MY_CONST() {}
//~^ ERROR E0324
Expand All @@ -37,6 +39,7 @@ pub struct FooTypeForMethod;

impl Foo for FooTypeForMethod {
//~^ ERROR E0046
//~| NOTE missing `bar` in implementation
type bar = u64;
//~^ ERROR E0325
const MY_CONST: u32 = 1;
Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/issue-23729.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ fn main() {
}

impl Iterator for Recurrence {
//~^ ERROR not all trait items implemented, missing: `Item` [E0046]
//~^ ERROR E0046
//~| NOTE missing `Item` in implementation
#[inline]
fn next(&mut self) -> Option<u64> {
if self.pos < 2 {
Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/issue-23827.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ impl<C: Component> FnMut<(C,)> for Prototype {
}

impl<C: Component> FnOnce<(C,)> for Prototype {
//~^ ERROR not all trait items implemented, missing: `Output` [E0046]
//~^ ERROR E0046
//~| NOTE missing `Output` in implementation
extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
Fn::call(&self, (comp,))
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/issue-24356.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ fn main() {

// Causes ICE
impl Deref for Thing {
//~^ ERROR not all trait items implemented, missing: `Target` [E0046]
//~^ ERROR E0046
//~| NOTE missing `Target` in implementation
fn deref(&self) -> i8 { self.0 }
}

Expand Down

0 comments on commit 9f09ee5

Please sign in to comment.