Skip to content

Commit 8e82c21

Browse files
committed
more friend error message for in fn arg
1 parent 15c18e7 commit 8e82c21

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/librustc_resolve/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,8 +2361,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
23612361
"type name"
23622362
};
23632363

2364-
let msg = format!("use of undeclared {} `{}`", kind,
2365-
path_names_to_string(path, 0));
2364+
let self_type_name = special_idents::type_self.name;
2365+
let is_invalid_self_type_name =
2366+
path.segments.len() > 0 &&
2367+
maybe_qself.is_none() &&
2368+
path.segments[0].identifier.name == self_type_name;
2369+
let msg = if is_invalid_self_type_name {
2370+
"expected type name, found keyword `Self`".to_string()
2371+
} else {
2372+
format!("use of undeclared {} `{}`",
2373+
kind, path_names_to_string(path, 0))
2374+
};
2375+
23662376
self.resolve_error(ty.span, &msg[..]);
23672377
}
23682378
}

0 commit comments

Comments
 (0)