Improve unknown external crate error

This commit is contained in:
Ryan Levick
2021-01-15 18:05:11 +01:00
parent 4e208f6a3a
commit d829e40c7b
5 changed files with 21 additions and 8 deletions

View File

@@ -244,6 +244,13 @@ impl<'a> PathSource<'a> {
// "function" here means "anything callable" rather than `DefKind::Fn`,
// this is not precise but usually more helpful than just "value".
Some(ExprKind::Call(call_expr, _)) => match &call_expr.kind {
// the case of `::some_crate()`
ExprKind::Path(_, path)
if path.segments.len() == 2
&& path.segments[0].ident.name == kw::PathRoot =>
{
"external crate"
}
ExprKind::Path(_, path) => {
let mut msg = "function";
if let Some(segment) = path.segments.iter().last() {