@@ -61,25 +61,31 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
6161 path_str : & str ,
6262 current_item : & Option < String > ,
6363 module_id : syntax:: ast:: NodeId ,
64- ) -> Result < ( Res , Option < String > ) , ( ) > {
64+ ) -> Result < ( Res , Option < String > ) , ErrorKind > {
6565 let cx = self . cx ;
6666
6767 let mut split = path_str. rsplitn ( 3 , "::" ) ;
68- let variant_field_name = split. next ( ) . map ( |f| Symbol :: intern ( f) ) . ok_or ( ( ) ) ?;
69- let variant_name = split. next ( ) . map ( |f| Symbol :: intern ( f) ) . ok_or ( ( ) ) ?;
68+ let variant_field_name = split
69+ . next ( )
70+ . map ( |f| Symbol :: intern ( f) )
71+ . ok_or ( ErrorKind :: ResolutionFailure ) ?;
72+ let variant_name = split
73+ . next ( )
74+ . map ( |f| Symbol :: intern ( f) )
75+ . ok_or ( ErrorKind :: ResolutionFailure ) ?;
7076 let path = split. next ( ) . map ( |f| {
7177 if f == "self" || f == "Self" {
7278 if let Some ( name) = current_item. as_ref ( ) {
7379 return name. clone ( ) ;
7480 }
7581 }
7682 f. to_owned ( )
77- } ) . ok_or ( ( ) ) ?;
83+ } ) . ok_or ( ErrorKind :: ResolutionFailure ) ?;
7884 let ( _, ty_res) = cx. enter_resolver ( |resolver| {
7985 resolver. resolve_str_path_error ( DUMMY_SP , & path, TypeNS , module_id)
80- } ) ?;
86+ } ) . map_err ( |_| ErrorKind :: ResolutionFailure ) ?;
8187 if let Res :: Err = ty_res {
82- return Err ( ( ) ) ;
88+ return Err ( ErrorKind :: ResolutionFailure ) ;
8389 }
8490 let ty_res = ty_res. map_id ( |_| panic ! ( "unexpected node_id" ) ) ;
8591 match ty_res {
@@ -88,7 +94,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
8894 . iter ( )
8995 . flat_map ( |imp| cx. tcx . associated_items ( * imp) )
9096 . any ( |item| item. ident . name == variant_name) {
91- return Err ( ( ) ) ;
97+ return Err ( ErrorKind :: ResolutionFailure ) ;
9298 }
9399 match cx. tcx . type_of ( did) . kind {
94100 ty:: Adt ( def, _) if def. is_enum ( ) => {
@@ -98,13 +104,13 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
98104 Some ( format ! ( "variant.{}.field.{}" ,
99105 variant_name, variant_field_name) ) ) )
100106 } else {
101- Err ( ( ) )
107+ Err ( ErrorKind :: ResolutionFailure )
102108 }
103109 }
104- _ => Err ( ( ) ) ,
110+ _ => Err ( ErrorKind :: ResolutionFailure ) ,
105111 }
106112 }
107- _ => Err ( ( ) )
113+ _ => Err ( ErrorKind :: ResolutionFailure )
108114 }
109115 }
110116
0 commit comments