Skip to content

Commit b169cf1

Browse files
committed
Add primary span label
1 parent 6c7a5ba commit b169cf1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/librustc_typeck/check/method/suggest.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
297297
tcx.sess.diagnostic().struct_dummy()
298298
};
299299

300-
if let Some(def) = actual.ty_adt_def() {
300+
if let Some(def) = actual.ty_adt_def() {
301301
if let Some(full_sp) = tcx.hir.span_if_local(def.did) {
302302
let def_sp = tcx.sess.codemap().def_span(full_sp);
303303
err.span_label(def_sp, format!("{} `{}` not found {}",
@@ -380,6 +380,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
380380
if !static_sources.is_empty() {
381381
err.note("found the following associated functions; to be used as methods, \
382382
functions must have a `self` parameter");
383+
err.span_label(span, "this is an associated function, not a method");
383384
}
384385
if static_sources.len() == 1 {
385386
if let Some(expr) = rcvr_expr {

src/test/ui/span/issue-7575.stderr

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0599]: no method named `f9` found for type `usize` in the current scope
22
--> $DIR/issue-7575.rs:74:18
33
|
44
LL | u.f8(42) + u.f9(342) + m.fff(42)
5-
| ^^
5+
| ^^ this is an associated function, not a method
66
|
77
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
88
note: candidate #1 is defined in the trait `CtxtFn`
@@ -37,7 +37,8 @@ LL | struct Myisize(isize);
3737
...
3838
LL | u.f8(42) + u.f9(342) + m.fff(42)
3939
| --^^^
40-
| |
40+
| | |
41+
| | this is an associated function, not a method
4142
| help: use associated function syntax intead: `Myisize::fff`
4243
|
4344
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
@@ -51,7 +52,7 @@ error[E0599]: no method named `is_str` found for type `T` in the current scope
5152
--> $DIR/issue-7575.rs:82:7
5253
|
5354
LL | t.is_str()
54-
| ^^^^^^
55+
| ^^^^^^ this is an associated function, not a method
5556
|
5657
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
5758
note: the candidate is defined in the trait `ManyImplTrait`

0 commit comments

Comments
 (0)