]> git.lizzy.rs Git - rust.git/commitdiff
Point at def span in "missing in impl" error
authorEsteban Küber <esteban@kuber.com.ar>
Tue, 19 Dec 2017 22:41:03 +0000 (14:41 -0800)
committerEsteban Küber <esteban@kuber.com.ar>
Tue, 19 Dec 2017 22:41:03 +0000 (14:41 -0800)
src/librustc_typeck/check/mod.rs
src/test/ui/impl-trait/trait_type.stderr
src/test/ui/missing-items/m2.stderr
src/test/ui/span/E0046.stderr
src/test/ui/span/impl-wrong-item-for-trait.stderr
src/test/ui/span/issue-23729.stderr
src/test/ui/span/issue-23827.stderr
src/test/ui/span/issue-24356.stderr

index baa389319ca723483c416c35575b3eb7f0dc2900..7ebdb876ed02f54ce20de59cfead13cc0b26a893 100644 (file)
@@ -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.
index 42e1dcdb1c42ab0400b7341a11718300c69d96e8..7a0d01a8ec2156234c3ed4b82aa90af25830d8a3 100644 (file)
@@ -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>`
 
index 47164a5304abbaa4d245f39d5d604dd54daedc00..8c57214ec771f91a7472905104caf735a6b4e66c 100644 (file)
@@ -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;`
index cd963de441b5f2c2d1b1d1d7b684162d9798271d..fb13f21fe00f70ecdfbdd4c5c7c7f0faa6ef653f 100644 (file)
@@ -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
 
index 92993e192650e0a5652eaf9f845ce9a6e0362691..6473b24dec5b32dc1c3e021e6a30863c7b3733cf 100644 (file)
@@ -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
@@ -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
@@ -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>`
 
index 0124d33635c4755be33858dba89c5db5f407d67e..60bf804ff30c4d2dcdcff8fede42303e405cd7c6 100644 (file)
@@ -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;`
 
index acf499e4c8ddedf6e82cbb45a49f56e3ac8ca622..d06d6c03616e31455722ece5f395b283c615f284 100644 (file)
@@ -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;`
 
index c526a4bc521c433a5cfaa30e51d071f504d74f90..58fb943fef827a249feedf12c8786bc5d40bd6d3 100644 (file)
@@ -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;`