@@ -1413,25 +1413,6 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
14131413
14141414 fn resolve_str_path ( & mut self , span : Span , crate_root : Option < & str > ,
14151415 components : & [ & str ] , is_value : bool ) -> hir:: Path {
1416- self . resolve_str_path_cb ( span, crate_root, components, is_value,
1417- |resolver, span, error| resolve_error ( resolver, span, error) )
1418- }
1419-
1420- fn get_resolution ( & mut self , id : NodeId ) -> Option < PathResolution > {
1421- self . def_map . get ( & id) . cloned ( )
1422- }
1423-
1424- fn definitions ( & mut self ) -> & mut Definitions {
1425- & mut self . definitions
1426- }
1427- }
1428-
1429- impl < ' a > Resolver < ' a > {
1430- /// resolve_str_path, but takes a callback in case there was an error
1431- fn resolve_str_path_cb < F > ( & mut self , span : Span , crate_root : Option < & str > ,
1432- components : & [ & str ] , is_value : bool , error_callback : F ) -> hir:: Path
1433- where F : for <' b , ' c > FnOnce ( & ' c mut Resolver , Span , ResolutionError < ' b > )
1434- {
14351416 use std:: iter;
14361417 let mut path = hir:: Path {
14371418 span,
@@ -1441,19 +1422,45 @@ impl<'a> Resolver<'a> {
14411422 } ) . map ( hir:: PathSegment :: from_name) . collect ( ) ,
14421423 } ;
14431424
1444- self . resolve_hir_path_cb ( & mut path, is_value, error_callback ) ;
1425+ self . resolve_hir_path ( & mut path, is_value) ;
14451426 path
14461427 }
14471428
1429+ fn get_resolution ( & mut self , id : NodeId ) -> Option < PathResolution > {
1430+ self . def_map . get ( & id) . cloned ( )
1431+ }
1432+
1433+ fn definitions ( & mut self ) -> & mut Definitions {
1434+ & mut self . definitions
1435+ }
1436+ }
1437+
1438+ impl < ' a > Resolver < ' a > {
14481439 /// Rustdoc uses this to resolve things in a recoverable way. ResolutionError<'a>
14491440 /// isn't something that can be returned because it can't be made to live that long,
14501441 /// and also it's a private type. Fortunately rustdoc doesn't need to know the error,
14511442 /// just that an error occured.
1452- pub fn resolve_str_path_error ( & mut self , span : Span , crate_root : Option < & str > ,
1453- components : & [ & str ] , is_value : bool ) -> Result < hir :: Path , ( ) > {
1443+ pub fn resolve_str_path_error ( & mut self , span : Span , path_str : & str , is_value : bool ) -> Result < hir :: Path , ( ) > {
1444+ use std :: iter ;
14541445 let mut errored = false ;
1455- let path = self . resolve_str_path_cb ( span, crate_root, components, is_value,
1456- |_, _, _| errored = true ) ;
1446+
1447+ let mut path = if path_str. starts_with ( "::" ) {
1448+ hir:: Path {
1449+ span,
1450+ def : Def :: Err ,
1451+ segments : iter:: once ( keywords:: CrateRoot . name ( ) ) . chain ( {
1452+ path_str. split ( "::" ) . skip ( 1 ) . map ( Symbol :: intern)
1453+ } ) . map ( hir:: PathSegment :: from_name) . collect ( ) ,
1454+ }
1455+ } else {
1456+ hir:: Path {
1457+ span,
1458+ def : Def :: Err ,
1459+ segments : path_str. split ( "::" ) . map ( Symbol :: intern)
1460+ . map ( hir:: PathSegment :: from_name) . collect ( ) ,
1461+ }
1462+ } ;
1463+ self . resolve_hir_path_cb ( & mut path, is_value, |_, _, _| errored = true ) ;
14571464 if errored || path. def == Def :: Err {
14581465 Err ( ( ) )
14591466 } else {
@@ -1874,8 +1881,8 @@ impl<'a> Resolver<'a> {
18741881 // generate a fake "implementation scope" containing all the
18751882 // implementations thus found, for compatibility with old resolve pass.
18761883
1877- fn with_scope < F > ( & mut self , id : NodeId , f : F )
1878- where F : FnOnce ( & mut Resolver )
1884+ pub fn with_scope < F , T > ( & mut self , id : NodeId , f : F ) -> T
1885+ where F : FnOnce ( & mut Resolver ) -> T
18791886 {
18801887 let id = self . definitions . local_def_id ( id) ;
18811888 let module = self . module_map . get ( & id) . cloned ( ) ; // clones a reference
@@ -1886,13 +1893,14 @@ impl<'a> Resolver<'a> {
18861893 self . ribs [ TypeNS ] . push ( Rib :: new ( ModuleRibKind ( module) ) ) ;
18871894
18881895 self . finalize_current_module_macro_resolutions ( ) ;
1889- f ( self ) ;
1896+ let ret = f ( self ) ;
18901897
18911898 self . current_module = orig_module;
18921899 self . ribs [ ValueNS ] . pop ( ) ;
18931900 self . ribs [ TypeNS ] . pop ( ) ;
1901+ ret
18941902 } else {
1895- f ( self ) ;
1903+ f ( self )
18961904 }
18971905 }
18981906
0 commit comments