Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point at def span in "missing in impl" error #46856

Merged
merged 1 commit into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,8 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_id: DefId,
impl_trait_ref: ty::TraitRef<'tcx>,
impl_item_refs: &[hir::ImplItemRef]) {
let impl_span = tcx.sess.codemap().def_span(impl_span);

// If the trait reference itself is erroneous (so the compilation is going
// to fail), skip checking the items here -- the `impl_item` table in `tcx`
// isn't populated for such impls.
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/impl-trait/trait_type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ error[E0046]: not all trait items implemented, missing: `fmt`
--> $DIR/trait_type.rs:31:1
|
31 | impl std::fmt::Display for MyType4 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation
|
= note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`

Expand Down
5 changes: 2 additions & 3 deletions src/test/ui/missing-items/m2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ error[E0601]: main function not found
error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`
--> $DIR/m2.rs:19:1
|
19 | / impl m1::X for X { //~ ERROR not all trait items implemented
20 | | }
| |_^ missing `CONSTANT`, `Type`, `method` in implementation
19 | impl m1::X for X { //~ ERROR not all trait items implemented
| ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method` in implementation
|
= note: `CONSTANT` from trait: `const CONSTANT: u32;`
= note: `Type` from trait: `type Type;`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/span/E0046.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ error[E0046]: not all trait items implemented, missing: `foo`
| --------- `foo` from trait
...
17 | impl Foo for Bar {}
| ^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
| ^^^^^^^^^^^^^^^^ missing `foo` in implementation

error: aborting due to previous error

45 changes: 14 additions & 31 deletions src/test/ui/span/impl-wrong-item-for-trait.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ error[E0323]: item `bar` is an associated const, which doesn't match its trait `
error[E0046]: not all trait items implemented, missing: `bar`
--> $DIR/impl-wrong-item-for-trait.rs:21:1
|
15 | fn bar(&self);
| -------------- `bar` from trait
15 | fn bar(&self);
| -------------- `bar` from trait
...
21 | / impl Foo for FooConstForMethod {
22 | | //~^ ERROR E0046
23 | | const bar: u64 = 1;
24 | | //~^ ERROR E0323
25 | | const MY_CONST: u32 = 1;
26 | | }
| |_^ missing `bar` in implementation
21 | impl Foo for FooConstForMethod {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `bar` in implementation

error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `Foo`
--> $DIR/impl-wrong-item-for-trait.rs:33:5
Expand All @@ -39,16 +34,11 @@ error[E0324]: item `MY_CONST` is an associated method, which doesn't match its t
error[E0046]: not all trait items implemented, missing: `MY_CONST`
--> $DIR/impl-wrong-item-for-trait.rs:30:1
|
16 | const MY_CONST: u32;
| -------------------- `MY_CONST` from trait
16 | const MY_CONST: u32;
| -------------------- `MY_CONST` from trait
...
30 | / impl Foo for FooMethodForConst {
31 | | //~^ ERROR E0046
32 | | fn bar(&self) {}
33 | | fn MY_CONST() {}
34 | | //~^ ERROR E0324
35 | | }
| |_^ missing `MY_CONST` in implementation
30 | impl Foo for FooMethodForConst {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `MY_CONST` in implementation

error[E0325]: item `bar` is an associated type, which doesn't match its trait `Foo`
--> $DIR/impl-wrong-item-for-trait.rs:41:5
Expand All @@ -62,24 +52,17 @@ error[E0325]: item `bar` is an associated type, which doesn't match its trait `F
error[E0046]: not all trait items implemented, missing: `bar`
--> $DIR/impl-wrong-item-for-trait.rs:39:1
|
15 | fn bar(&self);
| -------------- `bar` from trait
15 | fn bar(&self);
| -------------- `bar` from trait
...
39 | / impl Foo for FooTypeForMethod {
40 | | //~^ ERROR E0046
41 | | type bar = u64;
42 | | //~^ ERROR E0325
43 | | //~| ERROR E0437
44 | | const MY_CONST: u32 = 1;
45 | | }
| |_^ missing `bar` in implementation
39 | impl Foo for FooTypeForMethod {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `bar` in implementation

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

Expand Down
10 changes: 2 additions & 8 deletions src/test/ui/span/issue-23729.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
error[E0046]: not all trait items implemented, missing: `Item`
--> $DIR/issue-23729.rs:20:9
|
20 | / impl Iterator for Recurrence {
21 | | //~^ ERROR E0046
22 | | #[inline]
23 | | fn next(&mut self) -> Option<u64> {
... |
34 | | }
35 | | }
| |_________^ missing `Item` in implementation
20 | impl Iterator for Recurrence {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Item` in implementation
|
= note: `Item` from trait: `type Item;`

Expand Down
9 changes: 2 additions & 7 deletions src/test/ui/span/issue-23827.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
error[E0046]: not all trait items implemented, missing: `Output`
--> $DIR/issue-23827.rs:36:1
|
36 | / impl<C: Component> FnOnce<(C,)> for Prototype {
37 | | //~^ ERROR E0046
38 | | extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
39 | | Fn::call(&self, (comp,))
40 | | }
41 | | }
| |_^ missing `Output` in implementation
36 | impl<C: Component> FnOnce<(C,)> for Prototype {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Output` in implementation
|
= note: `Output` from trait: `type Output;`

Expand Down
7 changes: 2 additions & 5 deletions src/test/ui/span/issue-24356.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
error[E0046]: not all trait items implemented, missing: `Target`
--> $DIR/issue-24356.rs:30:9
|
30 | / impl Deref for Thing {
31 | | //~^ ERROR E0046
32 | | fn deref(&self) -> i8 { self.0 }
33 | | }
| |_________^ missing `Target` in implementation
30 | impl Deref for Thing {
| ^^^^^^^^^^^^^^^^^^^^ missing `Target` in implementation
|
= note: `Target` from trait: `type Target;`

Expand Down