Add check on find_best_match_for_name and improve help message for undefined macro

This commit is contained in:
ggomez
2016-02-16 14:47:37 +01:00
committed by Guillaume Gomez
parent 0bf6394801
commit eca0ab25d8
2 changed files with 31 additions and 1 deletions

View File

@@ -760,7 +760,12 @@ impl<'a> ExtCtxt<'a> {
err: &mut DiagnosticBuilder<'a>) {
let names = &self.syntax_env.names;
if let Some(suggestion) = find_best_match_for_name(names.iter(), name, None) {
err.fileline_help(span, &format!("did you mean `{}!`?", suggestion));
if suggestion != name {
err.fileline_help(span, &format!("did you mean `{}!`?", suggestion));
} else {
err.fileline_help(span, &format!("have you added the `#[macro_use]` on the \
module/import?"));
}
}
}
}