mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
check glob
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This commit is contained in:
parent
bf13549ab6
commit
55dd2114ed
@ -86,28 +86,29 @@ pub(crate) fn remove_unused_imports(acc: &mut Assists, ctx: &AssistContext<'_>)
|
|||||||
return None;
|
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
|
if u.star_token().is_some() {
|
||||||
.scope(ctx.db(), Some(use_module))
|
// Check if any of the children of this module are used
|
||||||
.iter()
|
let def_mod = match res.type_ns {
|
||||||
.filter_map(|(_, x)| match x {
|
Some(PathResolution::Def(ModuleDef::Module(module))) => module,
|
||||||
hir::ScopeDef::ModuleDef(d) => Some(Definition::from(*d)),
|
_ => return None,
|
||||||
_ => None,
|
};
|
||||||
})
|
|
||||||
.any(|d| used_once_in_scope(ctx, d, u.rename(), scope))
|
if !def_mod
|
||||||
{
|
.scope(ctx.db(), Some(use_module))
|
||||||
Some(u)
|
.iter()
|
||||||
} else {
|
.filter_map(|(_, x)| match x {
|
||||||
None
|
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 {
|
PathResolutionPerNs {
|
||||||
type_ns: Some(PathResolution::Def(ModuleDef::Trait(ref t))),
|
type_ns: Some(PathResolution::Def(ModuleDef::Trait(ref t))),
|
||||||
value_ns,
|
value_ns,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user