bootstrap: Make main.rs a stub that calls into the library crate - #160829
Open
Zalathar wants to merge 3 commits into
Open
bootstrap: Make main.rs a stub that calls into the library crate#160829Zalathar wants to merge 3 commits into
main.rs a stub that calls into the library crate#160829Zalathar wants to merge 3 commits into
Conversation
This intermediate commit helps to preserve line history.
If there is non-trivial code in `main.rs`, then any items it touches need to be publicly exported from the library crate. Those public exports make it harder to identify unused code within bootstrap.
There is no need to re-export anything, so all `pub use` imports can be simplified to `use` and merged with their siblings.
Collaborator
|
r? @clubby789 rustbot has assigned @clubby789. Use Why was this reviewer chosen?The reviewer was selected based on:
|
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.
As with some other bootstrap tools (e.g. compiletest), bootstrap itself is built as a small binary crate (executable) that links to a larger library crate.
If there is non-trivial code in
main.rs, then any items it touches need to be publicly exported from the library crate. Those public exports make it harder to identify unused code within bootstrap.As far as I can tell, there is no compelling rule or principle that determines whether code should be in the entry point or in the library crate, other than historical inertia.
This PR therefore takes all of the code from
main.rs, and moves it into a new filecli_main.rswithin the bootstrap library crate. That avoids the need for any public exports other thancli_main::mainitself.There should be no change to bootstrap behaviour.
This change makes it possible to change all of bootstrap's
pubitems topub(crate). That migration is left to a future PR, as it involves a fair bit of churn, and requires decisions on how to deal with pub items that are currently unused.Prior art: