@@ -908,13 +908,11 @@ struct AmbiguityError<'a> {
908
908
}
909
909
910
910
impl < ' 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 > > {
912
912
match self . kind {
913
- NameBindingKind :: Module ( module) => Ok ( module) ,
913
+ NameBindingKind :: Module ( module) => Some ( module) ,
914
914
NameBindingKind :: Import { binding, .. } => binding. module ( ) ,
915
- NameBindingKind :: Def ( Def :: Err ) => Err ( true ) ,
916
- NameBindingKind :: Def ( _) => Err ( false ) ,
917
- NameBindingKind :: Ambiguity { .. } => Err ( false ) ,
915
+ _ => None ,
918
916
}
919
917
}
920
918
@@ -1332,7 +1330,7 @@ impl<'a> Resolver<'a> {
1332
1330
fn record_use ( & mut self , name : Name , ns : Namespace , binding : & ' a NameBinding < ' a > , span : Span )
1333
1331
-> bool /* true if an error was reported */ {
1334
1332
// 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) {
1336
1334
self . used_crates . insert ( krate) ;
1337
1335
}
1338
1336
@@ -2372,7 +2370,7 @@ impl<'a> Resolver<'a> {
2372
2370
2373
2371
match binding {
2374
2372
Ok ( binding) => {
2375
- if let Ok ( next_module) = binding. module ( ) {
2373
+ if let Some ( next_module) = binding. module ( ) {
2376
2374
module = Some ( next_module) ;
2377
2375
} else if binding. def ( ) == Def :: Err {
2378
2376
return PathResult :: NonModule ( err_path_resolution ( ) ) ;
@@ -2980,7 +2978,7 @@ impl<'a> Resolver<'a> {
2980
2978
}
2981
2979
2982
2980
// collect submodules to explore
2983
- if let Ok ( module) = name_binding. module ( ) {
2981
+ if let Some ( module) = name_binding. module ( ) {
2984
2982
// form the path
2985
2983
let mut path_segments = path_segments. clone ( ) ;
2986
2984
path_segments. push ( PathSegment {
@@ -3141,8 +3139,8 @@ impl<'a> Resolver<'a> {
3141
3139
( ValueNS , _) => "a value" ,
3142
3140
( MacroNS , _) => "a macro" ,
3143
3141
( 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" ,
3146
3144
( TypeNS , _) => "a type" ,
3147
3145
} ;
3148
3146
format ! ( "{} named `{}` has already been {} in this {}" ,
0 commit comments