@@ -2336,20 +2336,19 @@ impl<'a> Resolver<'a> {
23362336 PathResult :: Indeterminate => bug ! ( "indetermined path result in resolve_qpath" ) ,
23372337 } ;
23382338
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 ( ) ) ;
23482351 }
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 ( ) ) ;
23532352 }
23542353
23552354 Some ( result)
0 commit comments