@@ -908,13 +908,11 @@ struct AmbiguityError<'a> {
908908}
909909
910910impl < ' a > NameBinding < ' a > {
911- fn module ( & self ) -> Result < Module < ' a > , bool /* true if an error has already been reported */ > {
911+ fn module ( & self ) -> Option < Module < ' a > > {
912912 match self . kind {
913- NameBindingKind :: Module ( module) => Ok ( module) ,
913+ NameBindingKind :: Module ( module) => Some ( module) ,
914914 NameBindingKind :: Import { binding, .. } => binding. module ( ) ,
915- NameBindingKind :: Def ( Def :: Err ) => Err ( true ) ,
916- NameBindingKind :: Def ( _) => Err ( false ) ,
917- NameBindingKind :: Ambiguity { .. } => Err ( false ) ,
915+ _ => None ,
918916 }
919917 }
920918
@@ -1332,7 +1330,7 @@ impl<'a> Resolver<'a> {
13321330 fn record_use ( & mut self , name : Name , ns : Namespace , binding : & ' a NameBinding < ' a > , span : Span )
13331331 -> bool /* true if an error was reported */ {
13341332 // track extern crates for unused_extern_crate lint
1335- if let Some ( DefId { krate, .. } ) = binding. module ( ) . ok ( ) . and_then ( ModuleS :: def_id) {
1333+ if let Some ( DefId { krate, .. } ) = binding. module ( ) . and_then ( ModuleS :: def_id) {
13361334 self . used_crates . insert ( krate) ;
13371335 }
13381336
@@ -2372,7 +2370,7 @@ impl<'a> Resolver<'a> {
23722370
23732371 match binding {
23742372 Ok ( binding) => {
2375- if let Ok ( next_module) = binding. module ( ) {
2373+ if let Some ( next_module) = binding. module ( ) {
23762374 module = Some ( next_module) ;
23772375 } else if binding. def ( ) == Def :: Err {
23782376 return PathResult :: NonModule ( err_path_resolution ( ) ) ;
@@ -2980,7 +2978,7 @@ impl<'a> Resolver<'a> {
29802978 }
29812979
29822980 // collect submodules to explore
2983- if let Ok ( module) = name_binding. module ( ) {
2981+ if let Some ( module) = name_binding. module ( ) {
29842982 // form the path
29852983 let mut path_segments = path_segments. clone ( ) ;
29862984 path_segments. push ( PathSegment {
@@ -3141,8 +3139,8 @@ impl<'a> Resolver<'a> {
31413139 ( ValueNS , _) => "a value" ,
31423140 ( MacroNS , _) => "a macro" ,
31433141 ( TypeNS , _) if old_binding. is_extern_crate ( ) => "an extern crate" ,
3144- ( TypeNS , Ok ( module) ) if module. is_normal ( ) => "a module" ,
3145- ( TypeNS , Ok ( module) ) if module. is_trait ( ) => "a trait" ,
3142+ ( TypeNS , Some ( module) ) if module. is_normal ( ) => "a module" ,
3143+ ( TypeNS , Some ( module) ) if module. is_trait ( ) => "a trait" ,
31463144 ( TypeNS , _) => "a type" ,
31473145 } ;
31483146 format ! ( "{} named `{}` has already been {} in this {}" ,
0 commit comments