-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: Removing all unused imports removes used imports for imports used for Derive macros #19793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Removing all unused imports removes used imports for imports used for Derive macros #19793
Conversation
…d for Derive macros Signed-off-by: Hayashi Mikihiro <[email protected]>
if prefer_value_ns { values().or_else(types) } else { types().or_else(values) } | ||
.or_else(items) | ||
.or_else(macros) | ||
if resolve_per_ns { | ||
PathResolutionPerNs { | ||
type_ns: types().or_else(items), | ||
value_ns: values(), | ||
macro_ns: macros(), | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I resolve type per namespace and make Struct for keep with split.
pub(crate) fn resolve_hir_path_per_ns( | ||
&self, | ||
db: &dyn HirDatabase, | ||
path: &ast::Path, | ||
) -> Option<PathResolutionPerNs> { | ||
let mut collector = ExprCollector::new(db, self.resolver.module(), self.file_id); | ||
let hir_path = | ||
collector.lower_path(path.clone(), &mut ExprCollector::impl_trait_error_allocator)?; | ||
let store = collector.store.finish(); | ||
Some(resolve_hir_path_( | ||
db, | ||
&self.resolver, | ||
&hir_path, | ||
false, | ||
name_hygiene(db, InFile::new(self.file_id, path.syntax())), | ||
Some(&store), | ||
true, | ||
)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we check unused import, we check only tail of path.
use foo::bar;
^^^
So I check only by resolve_hir_path_
instead of resolve_path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good, I propose a few minor changes.
Signed-off-by: Hayashi Mikihiro <[email protected]>
Signed-off-by: Hayashi Mikihiro <[email protected]>
Signed-off-by: Hayashi Mikihiro <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
fix: #19119
2025-05-15.1.05.49.mov