@@ -1544,20 +1544,17 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
15441544 ret
15451545 }
15461546
1547- fn with_scope < T > ( & mut self , id : NodeId , f : impl FnOnce ( & mut Self ) -> T ) -> T {
1548- if let Some ( module) = self . r . get_module ( self . r . local_def_id ( id) . to_def_id ( ) ) {
1549- // Move down in the graph.
1550- let orig_module = replace ( & mut self . parent_scope . module , module) ;
1551- self . with_rib ( ValueNS , RibKind :: Module ( module) , |this| {
1552- this. with_rib ( TypeNS , RibKind :: Module ( module) , |this| {
1553- let ret = f ( this) ;
1554- this. parent_scope . module = orig_module;
1555- ret
1556- } )
1547+ fn with_mod_rib < T > ( & mut self , id : NodeId , f : impl FnOnce ( & mut Self ) -> T ) -> T {
1548+ let module = self . r . expect_module ( self . r . local_def_id ( id) . to_def_id ( ) ) ;
1549+ // Move down in the graph.
1550+ let orig_module = replace ( & mut self . parent_scope . module , module) ;
1551+ self . with_rib ( ValueNS , RibKind :: Module ( module) , |this| {
1552+ this. with_rib ( TypeNS , RibKind :: Module ( module) , |this| {
1553+ let ret = f ( this) ;
1554+ this. parent_scope . module = orig_module;
1555+ ret
15571556 } )
1558- } else {
1559- f ( self )
1560- }
1557+ } )
15611558 }
15621559
15631560 fn visit_generic_params ( & mut self , params : & ' ast [ GenericParam ] , add_self_upper : bool ) {
@@ -2738,7 +2735,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
27382735 }
27392736
27402737 ItemKind :: Mod ( ..) => {
2741- self . with_scope ( item. id , |this| {
2738+ self . with_mod_rib ( item. id , |this| {
27422739 if mod_inner_docs {
27432740 this. resolve_doc_links ( & item. attrs , MaybeExported :: Ok ( item. id ) ) ;
27442741 }
0 commit comments