Skip to content

Commit 94b864c

Browse files
authored
Rollup merge of #46856 - estebank:missing-in-impl-def-span, r=arielb1
Point at def span in "missing in impl" error
2 parents 5efa045 + 3441ffb commit 94b864c

File tree

8 files changed

+26
-56
lines changed

8 files changed

+26
-56
lines changed

src/librustc_typeck/check/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,8 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
12741274
impl_id: DefId,
12751275
impl_trait_ref: ty::TraitRef<'tcx>,
12761276
impl_item_refs: &[hir::ImplItemRef]) {
1277+
let impl_span = tcx.sess.codemap().def_span(impl_span);
1278+
12771279
// If the trait reference itself is erroneous (so the compilation is going
12781280
// to fail), skip checking the items here -- the `impl_item` table in `tcx`
12791281
// isn't populated for such impls.

src/test/ui/impl-trait/trait_type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ error[E0046]: not all trait items implemented, missing: `fmt`
2727
--> $DIR/trait_type.rs:31:1
2828
|
2929
31 | impl std::fmt::Display for MyType4 {}
30-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation
30+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation
3131
|
3232
= note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`
3333

src/test/ui/missing-items/m2.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ error[E0601]: main function not found
33
error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`
44
--> $DIR/m2.rs:19:1
55
|
6-
19 | / impl m1::X for X { //~ ERROR not all trait items implemented
7-
20 | | }
8-
| |_^ missing `CONSTANT`, `Type`, `method` in implementation
6+
19 | impl m1::X for X { //~ ERROR not all trait items implemented
7+
| ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method` in implementation
98
|
109
= note: `CONSTANT` from trait: `const CONSTANT: u32;`
1110
= note: `Type` from trait: `type Type;`

src/test/ui/span/E0046.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ error[E0046]: not all trait items implemented, missing: `foo`
55
| --------- `foo` from trait
66
...
77
17 | impl Foo for Bar {}
8-
| ^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
8+
| ^^^^^^^^^^^^^^^^ missing `foo` in implementation
99

1010
error: aborting due to previous error
1111

src/test/ui/span/impl-wrong-item-for-trait.stderr

+14-31
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@ error[E0323]: item `bar` is an associated const, which doesn't match its trait `
1616
error[E0046]: not all trait items implemented, missing: `bar`
1717
--> $DIR/impl-wrong-item-for-trait.rs:21:1
1818
|
19-
15 | fn bar(&self);
20-
| -------------- `bar` from trait
19+
15 | fn bar(&self);
20+
| -------------- `bar` from trait
2121
...
22-
21 | / impl Foo for FooConstForMethod {
23-
22 | | //~^ ERROR E0046
24-
23 | | const bar: u64 = 1;
25-
24 | | //~^ ERROR E0323
26-
25 | | const MY_CONST: u32 = 1;
27-
26 | | }
28-
| |_^ missing `bar` in implementation
22+
21 | impl Foo for FooConstForMethod {
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `bar` in implementation
2924

3025
error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `Foo`
3126
--> $DIR/impl-wrong-item-for-trait.rs:33:5
@@ -39,16 +34,11 @@ error[E0324]: item `MY_CONST` is an associated method, which doesn't match its t
3934
error[E0046]: not all trait items implemented, missing: `MY_CONST`
4035
--> $DIR/impl-wrong-item-for-trait.rs:30:1
4136
|
42-
16 | const MY_CONST: u32;
43-
| -------------------- `MY_CONST` from trait
37+
16 | const MY_CONST: u32;
38+
| -------------------- `MY_CONST` from trait
4439
...
45-
30 | / impl Foo for FooMethodForConst {
46-
31 | | //~^ ERROR E0046
47-
32 | | fn bar(&self) {}
48-
33 | | fn MY_CONST() {}
49-
34 | | //~^ ERROR E0324
50-
35 | | }
51-
| |_^ missing `MY_CONST` in implementation
40+
30 | impl Foo for FooMethodForConst {
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `MY_CONST` in implementation
5242

5343
error[E0325]: item `bar` is an associated type, which doesn't match its trait `Foo`
5444
--> $DIR/impl-wrong-item-for-trait.rs:41:5
@@ -62,24 +52,17 @@ error[E0325]: item `bar` is an associated type, which doesn't match its trait `F
6252
error[E0046]: not all trait items implemented, missing: `bar`
6353
--> $DIR/impl-wrong-item-for-trait.rs:39:1
6454
|
65-
15 | fn bar(&self);
66-
| -------------- `bar` from trait
55+
15 | fn bar(&self);
56+
| -------------- `bar` from trait
6757
...
68-
39 | / impl Foo for FooTypeForMethod {
69-
40 | | //~^ ERROR E0046
70-
41 | | type bar = u64;
71-
42 | | //~^ ERROR E0325
72-
43 | | //~| ERROR E0437
73-
44 | | const MY_CONST: u32 = 1;
74-
45 | | }
75-
| |_^ missing `bar` in implementation
58+
39 | impl Foo for FooTypeForMethod {
59+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `bar` in implementation
7660

7761
error[E0046]: not all trait items implemented, missing: `fmt`
7862
--> $DIR/impl-wrong-item-for-trait.rs:47:1
7963
|
80-
47 | / impl Debug for FooTypeForMethod {
81-
48 | | }
82-
| |_^ missing `fmt` in implementation
64+
47 | impl Debug for FooTypeForMethod {
65+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation
8366
|
8467
= note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`
8568

src/test/ui/span/issue-23729.stderr

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
error[E0046]: not all trait items implemented, missing: `Item`
22
--> $DIR/issue-23729.rs:20:9
33
|
4-
20 | / impl Iterator for Recurrence {
5-
21 | | //~^ ERROR E0046
6-
22 | | #[inline]
7-
23 | | fn next(&mut self) -> Option<u64> {
8-
... |
9-
34 | | }
10-
35 | | }
11-
| |_________^ missing `Item` in implementation
4+
20 | impl Iterator for Recurrence {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Item` in implementation
126
|
137
= note: `Item` from trait: `type Item;`
148

src/test/ui/span/issue-23827.stderr

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
error[E0046]: not all trait items implemented, missing: `Output`
22
--> $DIR/issue-23827.rs:36:1
33
|
4-
36 | / impl<C: Component> FnOnce<(C,)> for Prototype {
5-
37 | | //~^ ERROR E0046
6-
38 | | extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
7-
39 | | Fn::call(&self, (comp,))
8-
40 | | }
9-
41 | | }
10-
| |_^ missing `Output` in implementation
4+
36 | impl<C: Component> FnOnce<(C,)> for Prototype {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Output` in implementation
116
|
127
= note: `Output` from trait: `type Output;`
138

src/test/ui/span/issue-24356.stderr

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
error[E0046]: not all trait items implemented, missing: `Target`
22
--> $DIR/issue-24356.rs:30:9
33
|
4-
30 | / impl Deref for Thing {
5-
31 | | //~^ ERROR E0046
6-
32 | | fn deref(&self) -> i8 { self.0 }
7-
33 | | }
8-
| |_________^ missing `Target` in implementation
4+
30 | impl Deref for Thing {
5+
| ^^^^^^^^^^^^^^^^^^^^ missing `Target` in implementation
96
|
107
= note: `Target` from trait: `type Target;`
118

0 commit comments

Comments
 (0)