Skip to content

Commit

Permalink
more friend error message for in fn arg
Browse files Browse the repository at this point in the history
  • Loading branch information
XuefengWu committed May 16, 2015
1 parent 15c18e7 commit 8e82c21
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/librustc_resolve/lib.rs
Expand Up @@ -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[..]);
}
}
Expand Down

0 comments on commit 8e82c21

Please sign in to comment.