Rollup merge of #46860 - estebank:candidate-def-sp, r=petrochenkov
Use def span for associated function suggestions
This commit is contained in:
commit
2770fdfaaa
@ -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, ¬e_str);
|
||||
err.span_note(self.tcx.sess.codemap().def_span(note_span), ¬e_str);
|
||||
} else {
|
||||
err.note(¬e_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 `{}`",
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user