From ed72c65f7291c893856d9bf220ab9b585939e724 Mon Sep 17 00:00:00 2001 From: Yojan Shrestha Date: Thu, 4 Aug 2016 23:21:24 -0500 Subject: [PATCH] Updates compiler error E0046 with new format --- src/librustc_typeck/check/mod.rs | 7 ++++++- src/test/compile-fail/E0046.rs | 4 +++- src/test/compile-fail/impl-wrong-item-for-trait.rs | 3 +++ src/test/compile-fail/issue-23729.rs | 3 ++- src/test/compile-fail/issue-23827.rs | 3 ++- src/test/compile-fail/issue-24356.rs | 3 ++- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 6062bd048b3..2645b78db6c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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::>().join("`, `")) + .span_label(impl_span, &format!("missing `{}` in implementation", + missing_items.iter() + .map(|name| name.to_string()) + .collect::>().join("`, `")) + ).emit(); } if !invalidated_items.is_empty() { diff --git a/src/test/compile-fail/E0046.rs b/src/test/compile-fail/E0046.rs index 63bd0a5ca28..a8b56b2b9ab 100644 --- a/src/test/compile-fail/E0046.rs +++ b/src/test/compile-fail/E0046.rs @@ -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() { } diff --git a/src/test/compile-fail/impl-wrong-item-for-trait.rs b/src/test/compile-fail/impl-wrong-item-for-trait.rs index 9b3e28cbc01..348c6765c1a 100644 --- a/src/test/compile-fail/impl-wrong-item-for-trait.rs +++ b/src/test/compile-fail/impl-wrong-item-for-trait.rs @@ -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; @@ -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 @@ -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; diff --git a/src/test/compile-fail/issue-23729.rs b/src/test/compile-fail/issue-23729.rs index f98cf6575d6..b1047ce18cc 100644 --- a/src/test/compile-fail/issue-23729.rs +++ b/src/test/compile-fail/issue-23729.rs @@ -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 { if self.pos < 2 { diff --git a/src/test/compile-fail/issue-23827.rs b/src/test/compile-fail/issue-23827.rs index 6c42c88bee6..2062e237312 100644 --- a/src/test/compile-fail/issue-23827.rs +++ b/src/test/compile-fail/issue-23827.rs @@ -34,7 +34,8 @@ impl FnMut<(C,)> for Prototype { } impl 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,)) } diff --git a/src/test/compile-fail/issue-24356.rs b/src/test/compile-fail/issue-24356.rs index ede81bea32a..d39fd539dce 100644 --- a/src/test/compile-fail/issue-24356.rs +++ b/src/test/compile-fail/issue-24356.rs @@ -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 } }