@@ -447,14 +447,15 @@ impl ImportUnits {
447447
448448 // Separate imports into:
449449 // - sortable: indices of imports that should be sorted
450- // - fixed: indices of side-effect imports when `sort_side_effects: false`
450+ // - fixed: indices of imports that should be ignored
451+ // - e.g. side-effect imports when `sort_side_effects: false`, with ignore comments, etc...
451452 let mut sortable_indices = vec ! [ ] ;
452453 let mut fixed_indices = vec ! [ ] ;
453454 for ( idx, si) in self . 0 . iter ( ) . enumerate ( ) {
454- if options. sort_side_effects || !si. is_side_effect_import ( ) {
455- sortable_indices. push ( idx) ;
456- } else {
455+ if si. is_ignored ( options) {
457456 fixed_indices. push ( idx) ;
457+ } else {
458+ sortable_indices. push ( idx) ;
458459 }
459460 }
460461
@@ -539,10 +540,13 @@ impl SortableImport {
539540 }
540541 }
541542
542- /// Check if this import is a side-effect-only import .
543- fn is_side_effect_import ( & self ) -> bool {
543+ /// Check if this import should be ignored (not sorted) .
544+ fn is_ignored ( & self , options : options :: SortImports ) -> bool {
544545 match self . import_line {
545- SourceLine :: Import ( _, _, is_side_effect) => is_side_effect,
546+ SourceLine :: Import ( _, _, is_side_effect) => {
547+ // TODO: Check ignore comments?
548+ !options. sort_side_effects && is_side_effect
549+ }
546550 _ => unreachable ! ( "`import_line` must be of type `SourceLine::Import`." ) ,
547551 }
548552 }
0 commit comments