Skip to content

Commit 31f0204

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35355 - shri3k:E0046, r=jonathandturner
Updates compiler error E0046 with new format Addresses rust-lang#35209 as part of rust-lang#35233. r? @jonathandturner I've repeated the following in my code. If this is something not desirable then let me know if there's any process to make this any cleaner. Thank you. ```rust missing_items.iter() .map(|name| name.to_string()) .collect::<Vec<_>>().join("`, `")) ```
2 parents ddf92ff + 9f09ee5 commit 31f0204

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,11 +1136,16 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
11361136
}
11371137

11381138
if !missing_items.is_empty() {
1139-
span_err!(tcx.sess, impl_span, E0046,
1139+
struct_span_err!(tcx.sess, impl_span, E0046,
11401140
"not all trait items implemented, missing: `{}`",
11411141
missing_items.iter()
11421142
.map(|name| name.to_string())
11431143
.collect::<Vec<_>>().join("`, `"))
1144+
.span_label(impl_span, &format!("missing `{}` in implementation",
1145+
missing_items.iter()
1146+
.map(|name| name.to_string())
1147+
.collect::<Vec<_>>().join("`, `"))
1148+
).emit();
11441149
}
11451150

11461151
if !invalidated_items.is_empty() {

src/test/compile-fail/E0046.rs

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct FooConstForMethod;
2121

2222
impl Foo for FooConstForMethod {
2323
//~^ ERROR E0046
24+
//~| NOTE missing `bar` in implementation
2425
const bar: u64 = 1;
2526
//~^ ERROR E0323
2627
//~| NOTE does not match trait
@@ -31,6 +32,7 @@ pub struct FooMethodForConst;
3132

3233
impl Foo for FooMethodForConst {
3334
//~^ ERROR E0046
35+
//~| NOTE missing `MY_CONST` in implementation
3436
fn bar(&self) {}
3537
fn MY_CONST() {}
3638
//~^ ERROR E0324
@@ -41,6 +43,7 @@ pub struct FooTypeForMethod;
4143

4244
impl Foo for FooTypeForMethod {
4345
//~^ ERROR E0046
46+
//~| NOTE missing `bar` in implementation
4447
type bar = u64;
4548
//~^ ERROR E0325
4649
//~| NOTE does not match trait

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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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)