@@ -2336,20 +2336,19 @@ impl<'a> Resolver<'a> {
2336
2336
PathResult :: Indeterminate => bug ! ( "indetermined path result in resolve_qpath" ) ,
2337
2337
} ;
2338
2338
2339
- if path. len ( ) == 1 || global_by_default || result. base_def == Def :: Err {
2340
- return Some ( result) ;
2341
- }
2342
-
2343
- let unqualified_result = {
2344
- match self . resolve_path ( & [ * path. last ( ) . unwrap ( ) ] , Some ( ns) , None ) {
2345
- PathResult :: NonModule ( path_res) => path_res. base_def ,
2346
- PathResult :: Module ( module) => module. def ( ) . unwrap ( ) ,
2347
- _ => return Some ( result) ,
2339
+ if path. len ( ) > 1 && !global_by_default && result. base_def != Def :: Err &&
2340
+ path[ 0 ] . name != keywords:: CrateRoot . name ( ) && path[ 0 ] . name != "$crate" {
2341
+ let unqualified_result = {
2342
+ match self . resolve_path ( & [ * path. last ( ) . unwrap ( ) ] , Some ( ns) , None ) {
2343
+ PathResult :: NonModule ( path_res) => path_res. base_def ,
2344
+ PathResult :: Module ( module) => module. def ( ) . unwrap ( ) ,
2345
+ _ => return Some ( result) ,
2346
+ }
2347
+ } ;
2348
+ if result. base_def == unqualified_result {
2349
+ let lint = lint:: builtin:: UNUSED_QUALIFICATIONS ;
2350
+ self . session . add_lint ( lint, id, span, "unnecessary qualification" . to_string ( ) ) ;
2348
2351
}
2349
- } ;
2350
- if result. base_def == unqualified_result && path[ 0 ] . name != "$crate" {
2351
- let lint = lint:: builtin:: UNUSED_QUALIFICATIONS ;
2352
- self . session . add_lint ( lint, id, span, "unnecessary qualification" . to_string ( ) ) ;
2353
2352
}
2354
2353
2355
2354
Some ( result)
0 commit comments