@@ -2654,10 +2654,34 @@ impl<'a> Resolver<'a> {
2654
2654
2655
2655
}
2656
2656
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
+ }
2661
2685
}
2662
2686
}
2663
2687
}
@@ -3018,7 +3042,7 @@ impl<'a> Resolver<'a> {
3018
3042
fn check_for_conflicts_between_imports_and_items ( & mut self ,
3019
3043
module : & Module ,
3020
3044
import_resolution :
3021
- & mut ImportResolution ,
3045
+ & ImportResolution ,
3022
3046
import_span : Span ,
3023
3047
name : Name ) {
3024
3048
if self . session . features . borrow ( ) . import_shadowing {
@@ -3031,8 +3055,9 @@ impl<'a> Resolver<'a> {
3031
3055
. contains_key ( & name) {
3032
3056
match import_resolution. type_target {
3033
3057
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}::*`?)",
3036
3061
token:: get_name( name) . get( ) ) ;
3037
3062
self . session . span_err ( import_span, msg. as_slice ( ) ) ;
3038
3063
}
0 commit comments