Skip to content

Commit ed72c65

Browse files
committed
Updates compiler error E0046 with new format
1 parent 545a3a9 commit ed72c65

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

src/librustc_typeck/check/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1117,11 +1117,16 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
11171117
}
11181118

11191119
if !missing_items.is_empty() {
1120-
span_err!(tcx.sess, impl_span, E0046,
1120+
struct_span_err!(tcx.sess, impl_span, E0046,
11211121
"not all trait items implemented, missing: `{}`",
11221122
missing_items.iter()
11231123
.map(|name| name.to_string())
11241124
.collect::<Vec<_>>().join("`, `"))
1125+
.span_label(impl_span, &format!("missing `{}` in implementation",
1126+
missing_items.iter()
1127+
.map(|name| name.to_string())
1128+
.collect::<Vec<_>>().join("`, `"))
1129+
).emit();
11251130
}
11261131

11271132
if !invalidated_items.is_empty() {

src/test/compile-fail/E0046.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ trait Foo {
1414

1515
struct Bar;
1616

17-
impl Foo for Bar {} //~ ERROR E0046
17+
impl Foo for Bar {}
18+
//~^ ERROR E0046
19+
//~| NOTE missing `foo` in implementation
1820

1921
fn main() {
2022
}

src/test/compile-fail/impl-wrong-item-for-trait.rs

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub struct FooConstForMethod;
1919

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

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

3840
impl Foo for FooTypeForMethod {
3941
//~^ ERROR E0046
42+
//~| NOTE missing `bar` in implementation
4043
type bar = u64;
4144
//~^ ERROR E0325
4245
const MY_CONST: u32 = 1;

src/test/compile-fail/issue-23729.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ fn main() {
1818
}
1919

2020
impl Iterator for Recurrence {
21-
//~^ ERROR not all trait items implemented, missing: `Item` [E0046]
21+
//~^ ERROR E0046
22+
//~| NOTE missing `Item` in implementation
2223
#[inline]
2324
fn next(&mut self) -> Option<u64> {
2425
if self.pos < 2 {

src/test/compile-fail/issue-23827.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ impl<C: Component> FnMut<(C,)> for Prototype {
3434
}
3535

3636
impl<C: Component> FnOnce<(C,)> for Prototype {
37-
//~^ ERROR not all trait items implemented, missing: `Output` [E0046]
37+
//~^ ERROR E0046
38+
//~| NOTE missing `Output` in implementation
3839
extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
3940
Fn::call(&self, (comp,))
4041
}

src/test/compile-fail/issue-24356.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ fn main() {
2828

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

0 commit comments

Comments
 (0)