about summary refs log tree commit diff
diff options
context:
space:
mode:
authorXuefeng Wu <xfwu@thoughtworks.com>2015-05-04 19:27:02 +0800
committerXuefeng Wu <benewu@gmail.com>2015-05-16 17:21:43 +0800
commit8e82c21bf3479d338fcb8f378095daa8e698de1e (patch)
tree64d3a31fbf46c5229347543c66b945dc0c1fdedc
parent15c18e725c5fcdfce1ebeb82344121a3a381237a (diff)
downloadrust-8e82c21bf3479d338fcb8f378095daa8e698de1e.tar.gz
rust-8e82c21bf3479d338fcb8f378095daa8e698de1e.zip
more friend error message for in fn arg
-rw-r--r--src/librustc_resolve/lib.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 38ab0a8c5ed..6f8e70dad2e 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -2361,8 +2361,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                             "type name"
                         };
 
-                        let msg = format!("use of undeclared {} `{}`", kind,
-                                          path_names_to_string(path, 0));
+                        let self_type_name = special_idents::type_self.name;
+                        let is_invalid_self_type_name =
+                            path.segments.len() > 0 &&
+                            maybe_qself.is_none() &&
+                            path.segments[0].identifier.name == self_type_name;
+                        let msg = if is_invalid_self_type_name {
+                            "expected type name, found keyword `Self`".to_string()
+                        } else {
+                            format!("use of undeclared {} `{}`",
+                                kind, path_names_to_string(path, 0))
+                        };
+
                         self.resolve_error(ty.span, &msg[..]);
                     }
                 }