@@ -3391,6 +3391,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3391
3391
3392
3392
self . record_candidate_traits_for_expr_if_necessary ( expr) ;
3393
3393
3394
+ expr. toto ( ) ;
3394
3395
// Next, resolve the node.
3395
3396
match expr. node {
3396
3397
ExprPath ( ref maybe_qself, ref path) => {
@@ -3509,13 +3510,38 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3509
3510
format ! ( "to call `{}::{}`" , path_str, path_name) ,
3510
3511
} ;
3511
3512
3513
+ let mut help_msg = String :: new ( ) ;
3512
3514
if !msg. is_empty ( ) {
3513
3515
msg = format ! ( ". Did you mean {}?" , msg)
3516
+ } else {
3517
+ // we check if this a module and if so, we display a help
3518
+ // message
3519
+ let name_path = path. segments . iter ( )
3520
+ . map ( |seg| seg. identifier . name )
3521
+ . collect :: < Vec < _ > > ( ) ;
3522
+ let current_module = self . current_module . clone ( ) ;
3523
+
3524
+ match self . resolve_module_path ( current_module,
3525
+ & name_path[ ..] ,
3526
+ UseLexicalScope ,
3527
+ expr. span ,
3528
+ PathSearch ) {
3529
+ Success ( _) => {
3530
+ help_msg = format ! ( "To reference an item from the \
3531
+ `{module}` module, use \
3532
+ `{module}::the_function_you_want`",
3533
+ module = & * path_name) ;
3534
+ } ,
3535
+ _ => { } ,
3536
+ } ;
3514
3537
}
3515
3538
3516
3539
resolve_error ( self ,
3517
3540
expr. span ,
3518
3541
ResolutionError :: UnresolvedName ( & * path_name, & * msg) ) ;
3542
+ if !help_msg. is_empty ( ) {
3543
+ self . session . fileline_help ( expr. span , & help_msg) ;
3544
+ }
3519
3545
}
3520
3546
}
3521
3547
}
0 commit comments