about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2016-01-08 13:02:30 -0500
committerSteve Klabnik <steve@steveklabnik.com>2016-01-08 13:02:30 -0500
commitc518664ea50263707d3871b03e400ecb54db2384 (patch)
treecebe62db5506601b6dd307d566de5fa073e0176d
parent64a8ffeffaae2fe72994fb0832ae525346b8a3c0 (diff)
parentc07876951be2d5619727ca2f4847c24f6682c598 (diff)
downloadrust-c518664ea50263707d3871b03e400ecb54db2384.tar.gz
rust-c518664ea50263707d3871b03e400ecb54db2384.zip
Rollup merge of #30584 - GuillaumeGomez:new_handles, r=pnkfelix
Last part of #30413.

r? @pnkfelix
-rw-r--r--src/librustc_resolve/lib.rs15
-rw-r--r--src/test/compile-fail/suggest-path-instead-of-mod-dot-item.rs12
2 files changed, 22 insertions, 5 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 5a17f2528c8..a5a22fd7f39 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -72,7 +72,7 @@ use rustc_front::intravisit::{self, FnKind, Visitor};
 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};
@@ -433,7 +433,7 @@ fn resolve_struct_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);
@@ -446,7 +446,6 @@ fn resolve_struct_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 \
@@ -454,9 +453,15 @@ fn resolve_struct_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() {
diff --git a/src/test/compile-fail/suggest-path-instead-of-mod-dot-item.rs b/src/test/compile-fail/suggest-path-instead-of-mod-dot-item.rs
index ecf17fa84d7..1d04679fd11 100644
--- a/src/test/compile-fail/suggest-path-instead-of-mod-dot-item.rs
+++ b/src/test/compile-fail/suggest-path-instead-of-mod-dot-item.rs
@@ -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(..)`
+}