fix: Removing all unused imports removes used imports for imports used for Derive macros#19793
Merged
ChayimFriedman2 merged 4 commits intoMay 15, 2025
Conversation
…d for Derive macros Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
Hmikihiro
commented
May 14, 2025
Comment on lines
-1638
to
+1669
| 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 { |
Contributor
Author
There was a problem hiding this comment.
I resolve type per namespace and make Struct for keep with split.
Hmikihiro
commented
May 14, 2025
Comment on lines
+1216
to
+1234
| 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, | ||
| )) | ||
| } |
Contributor
Author
There was a problem hiding this comment.
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
ChayimFriedman2
requested changes
May 14, 2025
ChayimFriedman2
left a comment
Contributor
There was a problem hiding this comment.
The changes look good, I propose a few minor changes.
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: #19119
2025-05-15.1.05.49.mov