about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-06-03 22:49:11 +0000
committerbors <bors@rust-lang.org>2017-06-03 22:49:11 +0000
commit8f66fafebd13d46ffc0982f1ca336055dc657043 (patch)
treee25ef0e9a5e41042237836f1b872e31b0a81f225
parent6684d176c78647c467870c75e276f5d37ffd3e3c (diff)
parentf113f54bacff1d670b8f935b84cbaf2620bb8e2f (diff)
downloadrust-8f66fafebd13d46ffc0982f1ca336055dc657043.tar.gz
rust-8f66fafebd13d46ffc0982f1ca336055dc657043.zip
Auto merge of #42391 - photoszzt:master, r=Manishearth
Better suggestion for unknown method

r? @Manishearth

fixes #42386
-rw-r--r--src/librustc_typeck/check/method/suggest.rs13
-rw-r--r--src/test/compile-fail/bogus-tag.rs2
-rw-r--r--src/test/compile-fail/issue-28344.rs6
-rw-r--r--src/test/compile-fail/issue-30123.rs2
-rw-r--r--src/test/compile-fail/issue-39559.rs2
-rw-r--r--src/test/compile-fail/issue-3973.rs2
-rw-r--r--src/test/compile-fail/issue-7950.rs3
-rw-r--r--src/test/compile-fail/lexical-scopes.rs2
-rw-r--r--src/test/compile-fail/trait-item-privacy.rs6
-rw-r--r--src/test/compile-fail/unspecified-self-in-trait-ref.rs8
10 files changed, 30 insertions, 16 deletions
diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs
index c496053a154..3ac5994cd1a 100644
--- a/src/librustc_typeck/check/method/suggest.rs
+++ b/src/librustc_typeck/check/method/suggest.rs
@@ -176,7 +176,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                                      if mode == Mode::MethodCall {
                                          "method"
                                      } else {
-                                         "associated item"
+                                         match item_name.as_str().chars().next() {
+                                             Some(name) => {
+                                                 if name.is_lowercase() {
+                                                     "function or associated item"
+                                                 } else {
+                                                     "associated item"
+                                                 }
+                                             },
+                                             None => {
+                                                 ""
+                                             },
+                                         }
                                      },
                                      item_name,
                                      self.ty_to_string(actual))
diff --git a/src/test/compile-fail/bogus-tag.rs b/src/test/compile-fail/bogus-tag.rs
index a1021500be3..c388d47da6e 100644
--- a/src/test/compile-fail/bogus-tag.rs
+++ b/src/test/compile-fail/bogus-tag.rs
@@ -15,6 +15,6 @@ fn main() {
     let red: color = color::rgb(255, 0, 0);
     match red {
       color::rgb(r, g, b) => { println!("rgb"); }
-      color::hsl(h, s, l) => { println!("hsl"); }  //~ ERROR no associated
+      color::hsl(h, s, l) => { println!("hsl"); }  //~ ERROR no function
     }
 }
diff --git a/src/test/compile-fail/issue-28344.rs b/src/test/compile-fail/issue-28344.rs
index 751a42826d2..d28c3146404 100644
--- a/src/test/compile-fail/issue-28344.rs
+++ b/src/test/compile-fail/issue-28344.rs
@@ -13,9 +13,9 @@ use std::ops::BitXor;
 fn main() {
     let x: u8 = BitXor::bitor(0 as u8, 0 as u8);
     //~^ ERROR must be specified
-    //~| no associated item named
+    //~| no function or associated item named
 
     let g = BitXor::bitor;
     //~^ ERROR must be specified
-    //~| no associated item named
-}
\ No newline at end of file
+    //~| no function or associated item named
+}
diff --git a/src/test/compile-fail/issue-30123.rs b/src/test/compile-fail/issue-30123.rs
index ae1320c821f..653097ad69f 100644
--- a/src/test/compile-fail/issue-30123.rs
+++ b/src/test/compile-fail/issue-30123.rs
@@ -15,5 +15,5 @@ use issue_30123_aux::*;
 
 fn main() {
     let ug = Graph::<i32, i32>::new_undirected();
-    //~^ ERROR no associated item named `new_undirected` found for type
+    //~^ ERROR no function or associated item named `new_undirected` found for type
 }
diff --git a/src/test/compile-fail/issue-39559.rs b/src/test/compile-fail/issue-39559.rs
index 871ecf269ce..8bc1cc7bd1a 100644
--- a/src/test/compile-fail/issue-39559.rs
+++ b/src/test/compile-fail/issue-39559.rs
@@ -22,7 +22,7 @@ impl Dim for Dim3 {
 
 pub struct Vector<T, D: Dim> {
     entries: [T; D::dim()]
-    //~^ ERROR no associated item named `dim` found for type `D` in the current scope
+    //~^ ERROR no function or associated item named `dim` found for type `D` in the current scope
 }
 
 fn main() {}
diff --git a/src/test/compile-fail/issue-3973.rs b/src/test/compile-fail/issue-3973.rs
index 92456760b05..67a934fccce 100644
--- a/src/test/compile-fail/issue-3973.rs
+++ b/src/test/compile-fail/issue-3973.rs
@@ -30,6 +30,6 @@ impl ToString_ for Point {
 
 fn main() {
     let p = Point::new(0.0, 0.0);
-    //~^ ERROR no associated item named `new` found for type `Point` in the current scope
+    //~^ ERROR no function or associated item named `new` found for type `Point`
     println!("{}", p.to_string());
 }
diff --git a/src/test/compile-fail/issue-7950.rs b/src/test/compile-fail/issue-7950.rs
index 003329a2d7d..dd3a48cb155 100644
--- a/src/test/compile-fail/issue-7950.rs
+++ b/src/test/compile-fail/issue-7950.rs
@@ -13,5 +13,6 @@
 struct Foo;
 
 fn main() {
-    Foo::bar(); //~ ERROR no associated item named `bar` found for type `Foo` in the current scope
+    Foo::bar();
+    //~^ ERROR no function or associated item named `bar` found for type `Foo`
 }
diff --git a/src/test/compile-fail/lexical-scopes.rs b/src/test/compile-fail/lexical-scopes.rs
index 1ab59e790d7..39da0d47a95 100644
--- a/src/test/compile-fail/lexical-scopes.rs
+++ b/src/test/compile-fail/lexical-scopes.rs
@@ -17,7 +17,7 @@ mod Foo {
     pub fn f() {}
 }
 fn g<Foo>() {
-    Foo::f(); //~ ERROR no associated item named `f`
+    Foo::f(); //~ ERROR no function or associated item named `f`
 }
 
 fn main() {}
diff --git a/src/test/compile-fail/trait-item-privacy.rs b/src/test/compile-fail/trait-item-privacy.rs
index 721d7583230..e915ca05f67 100644
--- a/src/test/compile-fail/trait-item-privacy.rs
+++ b/src/test/compile-fail/trait-item-privacy.rs
@@ -86,8 +86,10 @@ fn check_method() {
 
     // Methods, UFCS
     // a, b, c are resolved as trait items, their traits need to be in scope
-    S::a(&S); //~ ERROR no associated item named `a` found for type `S` in the current scope
-    S::b(&S); //~ ERROR no associated item named `b` found for type `S` in the current scope
+    S::a(&S);
+    //~^ ERROR no function or associated item named `a` found for type `S`
+    S::b(&S);
+    //~^ ERROR no function or associated item named `b` found for type `S`
     S::c(&S); // OK
     // a, b, c are resolved as inherent items, their traits don't need to be in scope
     C::a(&S); //~ ERROR method `a` is private
diff --git a/src/test/compile-fail/unspecified-self-in-trait-ref.rs b/src/test/compile-fail/unspecified-self-in-trait-ref.rs
index 84bcca3fc7b..cf8f3e91602 100644
--- a/src/test/compile-fail/unspecified-self-in-trait-ref.rs
+++ b/src/test/compile-fail/unspecified-self-in-trait-ref.rs
@@ -18,13 +18,13 @@ pub trait Bar<X=usize, A=Self> {
 
 fn main() {
     let a = Foo::lol();
-    //~^ ERROR no associated item named
+    //~^ ERROR no function or associated item named
     let b = Foo::<_>::lol();
-    //~^ ERROR no associated item named
+    //~^ ERROR no function or associated item named
     let c = Bar::lol();
-    //~^ ERROR no associated item named
+    //~^ ERROR no function or associated item named
     let d = Bar::<usize, _>::lol();
-    //~^ ERROR no associated item named
+    //~^ ERROR no function or associated item named
     let e = Bar::<usize>::lol();
     //~^ ERROR must be explicitly specified
 }