diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2018-05-28 10:29:49 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2018-05-28 10:29:49 -0700 |
| commit | b169cf112807024e811154b15e622662ea8eea23 (patch) | |
| tree | e2d236cd0826f5b681042c360a9ca0704de9fcfd /src | |
| parent | 6c7a5ba02043324580f5c75c6386e84812e83940 (diff) | |
| download | rust-b169cf112807024e811154b15e622662ea8eea23.tar.gz rust-b169cf112807024e811154b15e622662ea8eea23.zip | |
Add primary span label
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/check/method/suggest.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/span/issue-7575.stderr | 7 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 2fc4b3bea58..4d4e9191378 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -297,7 +297,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { tcx.sess.diagnostic().struct_dummy() }; - if let Some(def) = actual.ty_adt_def() { + if let Some(def) = actual.ty_adt_def() { if let Some(full_sp) = tcx.hir.span_if_local(def.did) { let def_sp = tcx.sess.codemap().def_span(full_sp); err.span_label(def_sp, format!("{} `{}` not found {}", @@ -380,6 +380,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if !static_sources.is_empty() { err.note("found the following associated functions; to be used as methods, \ functions must have a `self` parameter"); + err.span_label(span, "this is an associated function, not a method"); } if static_sources.len() == 1 { if let Some(expr) = rcvr_expr { diff --git a/src/test/ui/span/issue-7575.stderr b/src/test/ui/span/issue-7575.stderr index 3ae784b32a4..1061a8d9681 100644 --- a/src/test/ui/span/issue-7575.stderr +++ b/src/test/ui/span/issue-7575.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `f9` found for type `usize` in the current scope --> $DIR/issue-7575.rs:74:18 | LL | u.f8(42) + u.f9(342) + m.fff(42) - | ^^ + | ^^ this is an associated function, not a method | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter note: candidate #1 is defined in the trait `CtxtFn` @@ -37,7 +37,8 @@ LL | struct Myisize(isize); ... LL | u.f8(42) + u.f9(342) + m.fff(42) | --^^^ - | | + | | | + | | this is an associated function, not a method | help: use associated function syntax intead: `Myisize::fff` | = 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 --> $DIR/issue-7575.rs:82:7 | LL | t.is_str() - | ^^^^^^ + | ^^^^^^ this is an associated function, not a method | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter note: the candidate is defined in the trait `ManyImplTrait` |
