From 6c9d2ad1d5309a2d99a5ed2bf09bee5ec83e8684 Mon Sep 17 00:00:00 2001 From: Young-Flash <871946895@qq.com> Date: Fri, 22 Dec 2023 21:04:53 +0800 Subject: [PATCH] test: add test case for remove comma --- .../src/handlers/remove_unused_imports.rs | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/crates/ide-assists/src/handlers/remove_unused_imports.rs b/crates/ide-assists/src/handlers/remove_unused_imports.rs index 482c36d502..859ed1476c 100644 --- a/crates/ide-assists/src/handlers/remove_unused_imports.rs +++ b/crates/ide-assists/src/handlers/remove_unused_imports.rs @@ -609,6 +609,111 @@ mod b { ); } + #[test] + fn remove_comma_after_auto_remove_brace() { + check_assist( + remove_unused_imports, + r#" +mod m { + pub mod x { + pub struct A; + pub struct B; + } + pub mod y { + pub struct C; + } +} + +$0use m::{ + x::{A, B}, + y::C, +};$0 + +fn main() { + B; +} +"#, + r#" +mod m { + pub mod x { + pub struct A; + pub struct B; + } + pub mod y { + pub struct C; + } +} + +use m:: + x::B +; + +fn main() { + B; +} +"#, + ); + check_assist( + remove_unused_imports, + r#" +mod m { + pub mod x { + pub struct A; + pub struct B; + } + pub mod y { + pub struct C; + pub struct D; + } + pub mod z { + pub struct E; + pub struct F; + } +} + +$0use m::{ + x::{A, B}, + y::{C, D,}, + z::{E, F}, +};$0 + +fn main() { + B; + C; + F; +} +"#, + r#" +mod m { + pub mod x { + pub struct A; + pub struct B; + } + pub mod y { + pub struct C; + pub struct D; + } + pub mod z { + pub struct E; + pub struct F; + } +} + +use m::{ + x::B, + y::C, + z::F, +}; + +fn main() { + B; + C; + F; +} +"#, + ); + } + #[test] fn remove_nested_all_unused() { check_assist(