about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2017-12-19 15:36:04 -0800
committerEsteban Küber <esteban@kuber.com.ar>2017-12-19 15:36:04 -0800
commite70d888103eddbcecc03e2f04b3008ac68c67c71 (patch)
treec232eb8a0378da15120009bb781130a176296fb9 /src
parentb39c4bc12358078f77ddd01288b24252f757f37d (diff)
downloadrust-e70d888103eddbcecc03e2f04b3008ac68c67c71.tar.gz
rust-e70d888103eddbcecc03e2f04b3008ac68c67c71.zip
Use def span for associated function suggestions
Diffstat (limited to 'src')
-rw-r--r--src/librustc_typeck/check/method/suggest.rs5
-rw-r--r--src/test/ui/span/issue-37767.stderr12
-rw-r--r--src/test/ui/span/issue-7575.stderr12
3 files changed, 13 insertions, 16 deletions
diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs
index b3a7c32140b..f29009c1973 100644
--- a/src/librustc_typeck/check/method/suggest.rs
+++ b/src/librustc_typeck/check/method/suggest.rs
@@ -122,7 +122,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                                                impl_ty);
                         if let Some(note_span) = note_span {
                             // We have a span pointing to the method. Show note with snippet.
-                            err.span_note(note_span, &note_str);
+                            err.span_note(self.tcx.sess.codemap().def_span(note_span), &note_str);
                         } else {
                             err.note(&note_str);
                         }
@@ -131,7 +131,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                         let item = self
                             .associated_item(trait_did, item_name, Namespace::Value)
                             .unwrap();
-                        let item_span = self.tcx.def_span(item.def_id);
+                        let item_span = self.tcx.sess.codemap()
+                            .def_span(self.tcx.def_span(item.def_id));
                         span_note!(err,
                                    item_span,
                                    "candidate #{} is defined in the trait `{}`",
diff --git a/src/test/ui/span/issue-37767.stderr b/src/test/ui/span/issue-37767.stderr
index 8babcc74ed5..e9a1fe82f14 100644
--- a/src/test/ui/span/issue-37767.stderr
+++ b/src/test/ui/span/issue-37767.stderr
@@ -8,13 +8,13 @@ note: candidate #1 is defined in the trait `A`
   --> $DIR/issue-37767.rs:12:5
    |
 12 |     fn foo(&mut self) {}
-   |     ^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^^
    = help: to disambiguate the method call, write `A::foo(&a)` instead
 note: candidate #2 is defined in the trait `B`
   --> $DIR/issue-37767.rs:16:5
    |
 16 |     fn foo(&mut self) {}
-   |     ^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^^
    = help: to disambiguate the method call, write `B::foo(&a)` instead
 
 error[E0034]: multiple applicable items in scope
@@ -27,13 +27,13 @@ note: candidate #1 is defined in the trait `C`
   --> $DIR/issue-37767.rs:24:5
    |
 24 |     fn foo(&self) {}
-   |     ^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^
    = help: to disambiguate the method call, write `C::foo(&a)` instead
 note: candidate #2 is defined in the trait `D`
   --> $DIR/issue-37767.rs:28:5
    |
 28 |     fn foo(&self) {}
-   |     ^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^
    = help: to disambiguate the method call, write `D::foo(&a)` instead
 
 error[E0034]: multiple applicable items in scope
@@ -46,13 +46,13 @@ note: candidate #1 is defined in the trait `E`
   --> $DIR/issue-37767.rs:36:5
    |
 36 |     fn foo(self) {}
-   |     ^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^
    = help: to disambiguate the method call, write `E::foo(a)` instead
 note: candidate #2 is defined in the trait `F`
   --> $DIR/issue-37767.rs:40:5
    |
 40 |     fn foo(self) {}
-   |     ^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^
    = help: to disambiguate the method call, write `F::foo(a)` instead
 
 error: aborting due to 3 previous errors
diff --git a/src/test/ui/span/issue-7575.stderr b/src/test/ui/span/issue-7575.stderr
index 57c4d25b7d0..aeb98e4cabc 100644
--- a/src/test/ui/span/issue-7575.stderr
+++ b/src/test/ui/span/issue-7575.stderr
@@ -44,10 +44,8 @@ error[E0599]: no method named `fff` found for type `Myisize` in the current scop
 note: candidate #1 is defined in an impl for the type `Myisize`
   --> $DIR/issue-7575.rs:51:5
    |
-51 | /     fn fff(i: isize) -> isize {
-52 | |         i
-53 | |     }
-   | |_____^
+51 |     fn fff(i: isize) -> isize {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0599]: no method named `is_str` found for type `T` in the current scope
   --> $DIR/issue-7575.rs:82:7
@@ -60,10 +58,8 @@ error[E0599]: no method named `is_str` found for type `T` in the current scope
 note: candidate #1 is defined in the trait `ManyImplTrait`
   --> $DIR/issue-7575.rs:57:5
    |
-57 | /     fn is_str() -> bool {
-58 | |         false
-59 | |     }
-   | |_____^
+57 |     fn is_str() -> bool {
+   |     ^^^^^^^^^^^^^^^^^^^
    = help: to disambiguate the method call, write `ManyImplTrait::is_str(t)` instead
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `is_str`, perhaps you need to implement it: