Skip to content

Commit 28805fd

Browse files
committed
Better error message
1 parent afe3e27 commit 28805fd

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -926,12 +926,19 @@ impl Clean<Attributes> for [ast::Attribute] {
926926
// for structs, etc, and the link won't work.
927927
if let Ok(path) = resolve(false) {
928928
path.def
929-
} else if let Ok(_path) = resolve(true) {
929+
} else if let Ok(path) = resolve(true) {
930+
let kind = match path.def {
931+
Def::Variant(..) | Def::VariantCtor(..) => ("variant", format!("{}()", path_str)),
932+
Def::Fn(..) => ("function", format!("{}()", path_str)),
933+
Def::Method(..) => ("method", format!("{}()", path_str)),
934+
Def::Const(..) => ("const", format!("const@{}", path_str)),
935+
Def::Static(..) => ("static", format!("static@{}", path_str)),
936+
_ => ("value", format!("static@{}", path_str)),
937+
};
930938
let sp = attrs.doc_strings.first().map_or(DUMMY_SP, |a| a.span());
931-
cx.sess().struct_span_err(sp, &format!("could not resolve `{}`",
932-
path_str))
933-
.help(&format!("try `{0}()`, `static@{0}`, or `const@{0}`",
934-
path_str))
939+
cx.sess().struct_span_err(sp, &format!("could not resolve `{}` as a type, it is a {}",
940+
path_str, kind.0))
941+
.help(&format!("try `{}`", kind.1))
935942
.emit();
936943
continue;
937944
} else {

0 commit comments

Comments
 (0)