about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2017-12-20 21:22:04 +0800
committerGitHub <noreply@github.com>2017-12-20 21:22:04 +0800
commit94b864ccd0679e5e1205c924b46b79cfa714265a (patch)
treeae4d8452d7a2496327a68eae7c5f9a74c93a3ee3 /src
parent5efa045bbea9ff456d385f1850bede03b2677f77 (diff)
parent3441ffb15eb1869425a2513b945e58bb762a5267 (diff)
downloadrust-94b864ccd0679e5e1205c924b46b79cfa714265a.tar.gz
rust-94b864ccd0679e5e1205c924b46b79cfa714265a.zip
Rollup merge of #46856 - estebank:missing-in-impl-def-span, r=arielb1
Point at def span in "missing in impl" error
Diffstat (limited to 'src')
-rw-r--r--src/librustc_typeck/check/mod.rs2
-rw-r--r--src/test/ui/impl-trait/trait_type.stderr2
-rw-r--r--src/test/ui/missing-items/m2.stderr5
-rw-r--r--src/test/ui/span/E0046.stderr2
-rw-r--r--src/test/ui/span/impl-wrong-item-for-trait.stderr45
-rw-r--r--src/test/ui/span/issue-23729.stderr10
-rw-r--r--src/test/ui/span/issue-23827.stderr9
-rw-r--r--src/test/ui/span/issue-24356.stderr7
8 files changed, 26 insertions, 56 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index baa389319ca..7ebdb876ed0 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -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.
diff --git a/src/test/ui/impl-trait/trait_type.stderr b/src/test/ui/impl-trait/trait_type.stderr
index 42e1dcdb1c4..7a0d01a8ec2 100644
--- a/src/test/ui/impl-trait/trait_type.stderr
+++ b/src/test/ui/impl-trait/trait_type.stderr
@@ -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>`
 
diff --git a/src/test/ui/missing-items/m2.stderr b/src/test/ui/missing-items/m2.stderr
index 47164a5304a..8c57214ec77 100644
--- a/src/test/ui/missing-items/m2.stderr
+++ b/src/test/ui/missing-items/m2.stderr
@@ -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;`
diff --git a/src/test/ui/span/E0046.stderr b/src/test/ui/span/E0046.stderr
index cd963de441b..fb13f21fe00 100644
--- a/src/test/ui/span/E0046.stderr
+++ b/src/test/ui/span/E0046.stderr
@@ -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
 
diff --git a/src/test/ui/span/impl-wrong-item-for-trait.stderr b/src/test/ui/span/impl-wrong-item-for-trait.stderr
index 92993e19265..6473b24dec5 100644
--- a/src/test/ui/span/impl-wrong-item-for-trait.stderr
+++ b/src/test/ui/span/impl-wrong-item-for-trait.stderr
@@ -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>`
 
diff --git a/src/test/ui/span/issue-23729.stderr b/src/test/ui/span/issue-23729.stderr
index 0124d33635c..60bf804ff30 100644
--- a/src/test/ui/span/issue-23729.stderr
+++ b/src/test/ui/span/issue-23729.stderr
@@ -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;`
 
diff --git a/src/test/ui/span/issue-23827.stderr b/src/test/ui/span/issue-23827.stderr
index acf499e4c8d..d06d6c03616 100644
--- a/src/test/ui/span/issue-23827.stderr
+++ b/src/test/ui/span/issue-23827.stderr
@@ -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;`
 
diff --git a/src/test/ui/span/issue-24356.stderr b/src/test/ui/span/issue-24356.stderr
index c526a4bc521..58fb943fef8 100644
--- a/src/test/ui/span/issue-24356.stderr
+++ b/src/test/ui/span/issue-24356.stderr
@@ -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;`