@@ -66,35 +66,38 @@ impl LateLintPass<'_> for ImportRename {
6666 }
6767
6868 fn check_item ( & mut self , cx : & LateContext < ' _ > , item : & Item < ' _ > ) {
69- if_chain ! {
70- if let ItemKind :: Use ( path, UseKind :: Single ) = & item. kind;
71- if let Res :: Def ( _, id) = path. res;
72- if let Some ( name) = self . renames. get( & id) ;
73- // Remove semicolon since it is not present for nested imports
74- let span_without_semi = cx. sess( ) . source_map( ) . span_until_char( item. span, ';' ) ;
75- if let Some ( snip) = snippet_opt( cx, span_without_semi) ;
76- if let Some ( import) = match snip. split_once( " as " ) {
77- None => Some ( snip. as_str( ) ) ,
78- Some ( ( import, rename) ) => {
79- if rename. trim( ) == name. as_str( ) {
80- None
81- } else {
82- Some ( import. trim( ) )
69+ if let ItemKind :: Use ( path, UseKind :: Single ) = & item. kind {
70+ for & res in & path. res {
71+ if_chain ! {
72+ if let Res :: Def ( _, id) = res;
73+ if let Some ( name) = self . renames. get( & id) ;
74+ // Remove semicolon since it is not present for nested imports
75+ let span_without_semi = cx. sess( ) . source_map( ) . span_until_char( item. span, ';' ) ;
76+ if let Some ( snip) = snippet_opt( cx, span_without_semi) ;
77+ if let Some ( import) = match snip. split_once( " as " ) {
78+ None => Some ( snip. as_str( ) ) ,
79+ Some ( ( import, rename) ) => {
80+ if rename. trim( ) == name. as_str( ) {
81+ None
82+ } else {
83+ Some ( import. trim( ) )
84+ }
85+ } ,
86+ } ;
87+ then {
88+ span_lint_and_sugg(
89+ cx,
90+ MISSING_ENFORCED_IMPORT_RENAMES ,
91+ span_without_semi,
92+ "this import should be renamed" ,
93+ "try" ,
94+ format!(
95+ "{import} as {name}" ,
96+ ) ,
97+ Applicability :: MachineApplicable ,
98+ ) ;
8399 }
84- } ,
85- } ;
86- then {
87- span_lint_and_sugg(
88- cx,
89- MISSING_ENFORCED_IMPORT_RENAMES ,
90- span_without_semi,
91- "this import should be renamed" ,
92- "try" ,
93- format!(
94- "{import} as {name}" ,
95- ) ,
96- Applicability :: MachineApplicable ,
97- ) ;
100+ }
98101 }
99102 }
100103 }
0 commit comments