@@ -164,34 +164,37 @@ impl<'l, 'txc> LateLintPass<'l, 'txc> for MacroUseImports {
164164 let seg = import. split ( "::" ) . collect :: < Vec < _ > > ( ) ;
165165
166166 match seg. as_slice ( ) {
167- [ ] => unreachable ! ( "this should never be empty" ) ,
168- [ _] => unreachable ! ( "path must have two segments ?" ) ,
167+ // an empty path is impossible
168+ // a path should always consist of 2 or more segments
169+ [ ] | [ _] => return ,
169170 [ root, item] => {
170171 if !check_dup. contains ( & ( * item) . to_string ( ) ) {
171- used. entry ( ( root. to_string ( ) , span) )
172- . or_insert_with ( || vec ! [ ] )
173- . push ( item. to_string ( ) ) ;
174- check_dup. push ( item. to_string ( ) ) ;
172+ used. entry ( ( ( * root) . to_string ( ) , span) )
173+ . or_insert_with ( Vec :: new )
174+ . push ( ( * item) . to_string ( ) ) ;
175+ check_dup. push ( ( * item) . to_string ( ) ) ;
175176 }
176177 } ,
177178 [ root, rest @ ..] => {
178179 if rest. iter ( ) . all ( |item| !check_dup. contains ( & ( * item) . to_string ( ) ) ) {
179180 let filtered = rest
180181 . iter ( )
181- . filter_map ( |item| if check_dup. contains ( & ( * item) . to_string ( ) ) {
182- None
183- } else {
184- Some ( item. to_string ( ) )
182+ . filter_map ( |item| {
183+ if check_dup. contains ( & ( * item) . to_string ( ) ) {
184+ None
185+ } else {
186+ Some ( ( * item) . to_string ( ) )
187+ }
185188 } )
186189 . collect :: < Vec < _ > > ( ) ;
187190 used. entry ( ( ( * root) . to_string ( ) , span) )
188- . or_insert_with ( || vec ! [ ] )
191+ . or_insert_with ( Vec :: new )
189192 . push ( filtered. join ( "::" ) ) ;
190193 check_dup. extend ( filtered) ;
191194 } else {
192195 let rest = rest. to_vec ( ) ;
193- used. entry ( ( root. to_string ( ) , span) )
194- . or_insert_with ( || vec ! [ ] )
196+ used. entry ( ( ( * root) . to_string ( ) , span) )
197+ . or_insert_with ( Vec :: new )
195198 . push ( rest. join ( "::" ) ) ;
196199 check_dup. extend ( rest. iter ( ) . map ( ToString :: to_string) ) ;
197200 }
0 commit comments