Remove add_directory() from ModuleWriter trait#2824
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors directory creation in the module writer system by removing the add_directory() method from the ModuleWriter trait and making it an implementation detail handled automatically by PathWriter when adding files.
- Removed the
add_directory()method from theModuleWritertrait interface - Updated
PathWriterto automatically create parent directories when adding files - Simplified code by removing explicit directory creation calls throughout the codebase
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/module_writer.rs | Removed add_directory() from trait and all implementations; added automatic parent directory creation in PathWriter.add_bytes_with_permissions() |
| src/source_distribution.rs | Removed explicit add_directory() calls and simplified conditional logic to skip directories |
| src/build_context.rs | Removed unnecessary add_directory() call for libs directory |
| tests/common/metadata.rs | Removed add_directory() implementation from MockWriter and updated test expectations to exclude directory entries |
| Changelog.md | Added changelog entry documenting the refactoring |
Member
|
Thanks! |
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.
In #2823 I considered the idea of removing
add_directory()entirely from theModuleWritertrait since it seemed error-prone to require the programmer to ensure it was called everywhere. I decided to make a PR for that as well to see what it would look like.