about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHayashi Mikihiro <34ttrweoewiwe28@gmail.com>2025-05-15 14:01:05 +0900
committerHayashi Mikihiro <34ttrweoewiwe28@gmail.com>2025-05-15 14:01:05 +0900
commit2c55a78848cebf3bede3339362bbfcbc6c18fa8c (patch)
tree51dbad36a858509dde9c132d58ffec406d7b6611
parent5adbda4ee5d3013cf9e9a9479268fc8e17d24c40 (diff)
downloadrust-2c55a78848cebf3bede3339362bbfcbc6c18fa8c.tar.gz
rust-2c55a78848cebf3bede3339362bbfcbc6c18fa8c.zip
check glob
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
-rw-r--r--src/tools/rust-analyzer/crates/ide-assists/src/handlers/remove_unused_imports.rs43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/remove_unused_imports.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/remove_unused_imports.rs
index dff9a660cf5..994e7c446cc 100644
--- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/remove_unused_imports.rs
+++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/remove_unused_imports.rs
@@ -86,28 +86,29 @@ pub(crate) fn remove_unused_imports(acc: &mut Assists, ctx: &AssistContext<'_>)
                     return None;
                 }
             };
-            match res {
-                PathResolutionPerNs { type_ns: Some(type_ns), .. } if u.star_token().is_some() => {
-                    // Check if any of the children of this module are used
-                    let def_mod = match type_ns {
-                        PathResolution::Def(ModuleDef::Module(module)) => module,
-                        _ => return None,
-                    };
-
-                    if !def_mod
-                        .scope(ctx.db(), Some(use_module))
-                        .iter()
-                        .filter_map(|(_, x)| match x {
-                            hir::ScopeDef::ModuleDef(d) => Some(Definition::from(*d)),
-                            _ => None,
-                        })
-                        .any(|d| used_once_in_scope(ctx, d, u.rename(), scope))
-                    {
-                        Some(u)
-                    } else {
-                        None
-                    }
+
+            if u.star_token().is_some() {
+                // Check if any of the children of this module are used
+                let def_mod = match res.type_ns {
+                    Some(PathResolution::Def(ModuleDef::Module(module))) => module,
+                    _ => return None,
+                };
+
+                if !def_mod
+                    .scope(ctx.db(), Some(use_module))
+                    .iter()
+                    .filter_map(|(_, x)| match x {
+                        hir::ScopeDef::ModuleDef(d) => Some(Definition::from(*d)),
+                        _ => None,
+                    })
+                    .any(|d| used_once_in_scope(ctx, d, u.rename(), scope))
+                {
+                    return Some(u);
+                } else {
+                    return None;
                 }
+            }
+            match res {
                 PathResolutionPerNs {
                     type_ns: Some(PathResolution::Def(ModuleDef::Trait(ref t))),
                     value_ns,