@@ -2654,10 +2654,34 @@ impl<'a> Resolver<'a> {
26542654
26552655 }
26562656 Some ( _) => {
2657- // The import is unresolved. Bail out.
2658- debug ! ( "(resolving single import) unresolved import; \
2659- bailing out") ;
2660- return Indeterminate ;
2657+ // If containing_module is the same module whose import we are resolving
2658+ // and there it has an unresolved import with the same name as `source`,
2659+ // then the user is actually trying to import an item that is declared
2660+ // in the same scope
2661+ //
2662+ // e.g
2663+ // use self::submodule;
2664+ // pub mod submodule;
2665+ //
2666+ // In this case we continue as if we resolved the import and let the
2667+ // check_for_conflicts_between_imports_and_items call below handle
2668+ // the conflict
2669+ match ( module_. def_id . get ( ) , containing_module. def_id . get ( ) ) {
2670+ ( Some ( id1) , Some ( id2) ) if id1 == id2 => {
2671+ if value_result. is_unknown ( ) {
2672+ value_result = UnboundResult ;
2673+ }
2674+ if type_result. is_unknown ( ) {
2675+ type_result = UnboundResult ;
2676+ }
2677+ }
2678+ _ => {
2679+ // The import is unresolved. Bail out.
2680+ debug ! ( "(resolving single import) unresolved import; \
2681+ bailing out") ;
2682+ return Indeterminate ;
2683+ }
2684+ }
26612685 }
26622686 }
26632687 }
@@ -3018,7 +3042,7 @@ impl<'a> Resolver<'a> {
30183042 fn check_for_conflicts_between_imports_and_items ( & mut self ,
30193043 module : & Module ,
30203044 import_resolution :
3021- & mut ImportResolution ,
3045+ & ImportResolution ,
30223046 import_span : Span ,
30233047 name : Name ) {
30243048 if self . session . features . borrow ( ) . import_shadowing {
@@ -3031,8 +3055,9 @@ impl<'a> Resolver<'a> {
30313055 . contains_key ( & name) {
30323056 match import_resolution. type_target {
30333057 Some ( ref target) if !target. shadowable => {
3034- let msg = format ! ( "import `{}` conflicts with imported \
3035- crate in this module",
3058+ let msg = format ! ( "import `{0}` conflicts with imported \
3059+ crate in this module \
3060+ (maybe you meant `use {0}::*`?)",
30363061 token:: get_name( name) . get( ) ) ;
30373062 self . session . span_err ( import_span, msg. as_slice ( ) ) ;
30383063 }
0 commit comments