@@ -114,8 +114,7 @@ pub fn try_merge_trees(
114
114
let lhs_tl = lhs. use_tree_list ( ) ?;
115
115
let rhs_tl = rhs. use_tree_list ( ) ?;
116
116
117
- // if we are only allowed to merge the last level check if the paths are only one level deep
118
- // FIXME: This shouldn't work yet i think
117
+ // if we are only allowed to merge the last level check if the split off paths are only one level deep
119
118
if merge_behaviour == MergeBehaviour :: Last && use_tree_list_is_nested ( & lhs_tl)
120
119
|| use_tree_list_is_nested ( & rhs_tl)
121
120
{
@@ -463,14 +462,69 @@ use std::io;",
463
462
}
464
463
465
464
#[ test]
466
- fn merges_groups2 ( ) {
465
+ fn merges_groups_full ( ) {
467
466
check_full (
468
467
"std::io" ,
469
468
r"use std::fmt::{Result, Display};" ,
470
469
r"use std::{fmt::{Result, Display}, io};" ,
471
470
)
472
471
}
473
472
473
+ #[ test]
474
+ fn merges_groups_long_full ( ) {
475
+ check_full (
476
+ "std::foo::bar::Baz" ,
477
+ r"use std::foo::bar::Qux;" ,
478
+ r"use std::foo::bar::{Baz, Qux};" ,
479
+ )
480
+ }
481
+
482
+ #[ test]
483
+ fn merges_groups_long_last ( ) {
484
+ check_last (
485
+ "std::foo::bar::Baz" ,
486
+ r"use std::foo::bar::Qux;" ,
487
+ r"use std::foo::bar::{Baz, Qux};" ,
488
+ )
489
+ }
490
+
491
+ #[ test]
492
+ fn merges_groups_long_full_list ( ) {
493
+ check_full (
494
+ "std::foo::bar::Baz" ,
495
+ r"use std::foo::bar::{Qux, Quux};" ,
496
+ r"use std::foo::bar::{Baz, Quux, Qux};" ,
497
+ )
498
+ }
499
+
500
+ #[ test]
501
+ fn merges_groups_long_last_list ( ) {
502
+ check_last (
503
+ "std::foo::bar::Baz" ,
504
+ r"use std::foo::bar::{Qux, Quux};" ,
505
+ r"use std::foo::bar::{Baz, Quux, Qux};" ,
506
+ )
507
+ }
508
+
509
+ #[ test]
510
+ fn merges_groups_long_full_nested ( ) {
511
+ check_full (
512
+ "std::foo::bar::Baz" ,
513
+ r"use std::foo::bar::{Qux, quux::{Fez, Fizz}};" ,
514
+ r"use std::foo::bar::{Baz, quux::{Fez, Fizz}, Qux};" ,
515
+ )
516
+ }
517
+
518
+ #[ test]
519
+ fn merges_groups_long_last_nested ( ) {
520
+ check_last (
521
+ "std::foo::bar::Baz" ,
522
+ r"use std::foo::bar::{Qux, quux::{Fez, Fizz}};" ,
523
+ r"use std::foo::bar::Baz;
524
+ use std::foo::bar::{quux::{Fez, Fizz}, Qux};" ,
525
+ )
526
+ }
527
+
474
528
#[ test]
475
529
fn skip_merges_groups_pub ( ) {
476
530
check_full (
@@ -481,6 +535,17 @@ use std::io;",
481
535
)
482
536
}
483
537
538
+ // should this be a thing?
539
+ #[ test]
540
+ fn split_merge ( ) {
541
+ check_last (
542
+ "std::fmt::Result" ,
543
+ r"use std::{fmt, io};" ,
544
+ r"use std::fmt::Result;
545
+ use std::io;" ,
546
+ )
547
+ }
548
+
484
549
#[ test]
485
550
fn merges_groups_self ( ) {
486
551
check_full ( "std::fmt::Debug" , r"use std::fmt;" , r"use std::fmt::{self, Debug};" )
0 commit comments