提交 c0787695 编写于 作者: G Guillaume Gomez 提交者: ggomez

Add new help messages for E0425

上级 38201501
......@@ -72,7 +72,7 @@
use rustc_front::hir;
use rustc_front::hir::{Arm, BindByRef, BindByValue, BindingMode, Block};
use rustc_front::hir::Crate;
use rustc_front::hir::{Expr, ExprAgain, ExprBreak, ExprField};
use rustc_front::hir::{Expr, ExprAgain, ExprBreak, ExprCall, ExprField};
use rustc_front::hir::{ExprLoop, ExprWhile, ExprMethodCall};
use rustc_front::hir::{ExprPath, ExprStruct, FnDecl};
use rustc_front::hir::{ForeignItemFn, ForeignItemStatic, Generics};
......@@ -423,7 +423,7 @@ fn resolve_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
msg);
match context {
UnresolvedNameContext::Other => {} // no help available
UnresolvedNameContext::Other => { } // no help available
UnresolvedNameContext::PathIsMod(id) => {
let mut help_msg = String::new();
let parent_id = resolver.ast_map.get_parent_node(id);
......@@ -436,7 +436,6 @@ fn resolve_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
module = &*path,
ident = ident.node);
}
ExprMethodCall(ident, _, _) => {
help_msg = format!("To call a function from the \
`{module}` module, use \
......@@ -444,9 +443,15 @@ fn resolve_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
module = &*path,
ident = ident.node);
}
_ => {} // no help available
ExprCall(_, _) => {
help_msg = format!("No function corresponds to `{module}(..)`",
module = &*path);
}
_ => { } // no help available
}
} else {
help_msg = format!("Module `{module}` cannot be the value of an expression",
module = &*path);
}
if !help_msg.is_empty() {
......
......@@ -58,3 +58,15 @@ fn h6() -> i32 {
//~^ ERROR E0425
//~| HELP To call a function from the `a::b` module, use `a::b::f(..)`
}
fn h7() {
a::b
//~^ ERROR E0425
//~| HELP Module `a::b` cannot be the value of an expression
}
fn h8() -> i32 {
a::b()
//~^ ERROR E0425
//~| HELP No function corresponds to `a::b(..)`
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册