Let empty files be empty files#6839
Merged
ytmimi merged 6 commits intorust-lang:mainfrom Mar 27, 2026
Merged
Conversation
ytmimi
reviewed
Mar 23, 2026
ytmimi
reviewed
Mar 27, 2026
ytmimi
approved these changes
Mar 27, 2026
This was referenced Mar 27, 2026
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.
No longer add a "final newline" to empty files.
Empty files shouldn't need need trailing newlines.
Since this is a breaking change, I've done my best to feature gate this behind
StyleEdition::Edition2027. Please let me know if this should be handled differently.New tests:
append_newline_adds_newlines_before_2027append_newline_leaves_empty_files_empty_in_2027newline_file(existing 2024 behavior; excess newline is preserved)reorder_modules_2027(2027 behavior test extracted fromreorder_modules)The empty file
mod.rstest fixtures for thereorder_modulestest were previously being re-used for multiple editions (2015, 2024, 2027), but since 2027 now requires those files be actually empty instead of\n, I moved{enabled,disabled_style_edition_2027.rs}fromreorder_modules/to a newreorder_modules_2027/and mirrored themod.rstest fixture structure.The existing
empty_file.rstest (empty file becomes newline) remains untouched. (config not specified; so 2015).Update1: Fixed reorder_modules
Update2: 2027 tests pass on nightly, fail on stable. Unsure of the proper fix.
Update3: Renamed
empty_file_style_edition_2024tonewline_filebecause it's not actually an empty file.Update4: Implemented ytmimi's suggestion and fixed tests.