Skip to content

Commit 4cd939a

Browse files
committed
chore: add test case for nested use tree
1 parent bc2dee7 commit 4cd939a

File tree

1 file changed

+76
-3
lines changed

1 file changed

+76
-3
lines changed

crates/ide-assists/src/handlers/remove_unused_imports.rs

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ mod z {
423423
struct X();
424424
struct Y();
425425
mod z {
426-
use super::{X};
426+
use super::X;
427427
428428
fn w() {
429429
let x = X();
@@ -495,7 +495,7 @@ struct X();
495495
mod y {
496496
struct Y();
497497
mod z {
498-
use crate::{X};
498+
use crate::X;
499499
fn f() {
500500
let x = X();
501501
}
@@ -526,7 +526,7 @@ struct X();
526526
mod y {
527527
struct Y();
528528
mod z {
529-
use crate::{y::Y};
529+
use crate::y::Y;
530530
fn f() {
531531
let y = Y();
532532
}
@@ -536,6 +536,79 @@ mod y {
536536
);
537537
}
538538

539+
#[test]
540+
fn remove_unused_auto_remove_brace_nested() {
541+
check_assist(
542+
remove_unused_imports,
543+
r#"
544+
mod a {
545+
pub struct A();
546+
}
547+
mod b {
548+
struct F();
549+
mod c {
550+
$0use {{super::{{
551+
{d::{{{{{{{S, U}}}}}}}},
552+
{{{{e::{H, L, {{{R}}}}}}}},
553+
F, super::a::A
554+
}}}};$0
555+
fn f() {
556+
let f = F();
557+
let l = L();
558+
let a = A();
559+
let s = S();
560+
let h = H();
561+
}
562+
}
563+
564+
mod d {
565+
pub struct S();
566+
pub struct U();
567+
}
568+
569+
mod e {
570+
pub struct H();
571+
pub struct L();
572+
pub struct R();
573+
}
574+
}
575+
"#,
576+
r#"
577+
mod a {
578+
pub struct A();
579+
}
580+
mod b {
581+
struct F();
582+
mod c {
583+
use super::{
584+
d::S,
585+
e::{H, L},
586+
F, super::a::A
587+
};
588+
fn f() {
589+
let f = F();
590+
let l = L();
591+
let a = A();
592+
let s = S();
593+
let h = H();
594+
}
595+
}
596+
597+
mod d {
598+
pub struct S();
599+
pub struct U();
600+
}
601+
602+
mod e {
603+
pub struct H();
604+
pub struct L();
605+
pub struct R();
606+
}
607+
}
608+
"#,
609+
);
610+
}
611+
539612
#[test]
540613
fn remove_nested_all_unused() {
541614
check_assist(

0 commit comments

Comments
 (0)