more friend error message for in fn arg

This commit is contained in:
Xuefeng Wu 2015-05-04 19:27:02 +08:00 committed by Xuefeng Wu
parent 15c18e725c
commit 8e82c21bf3

View file

@ -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[..]);
}
}