File tree 1 file changed +29
-5
lines changed
1 file changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -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 {
You can’t perform that action at this time.
0 commit comments