bootstrap: Make main.rs a stub that calls into the library crate - #160829
Conversation
|
r? @clubby789 rustbot has assigned @clubby789. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
I would really like for rustc/Cargo to have a way of identifying unused In fact, since rustc can now (AFAIK) detect unused |
|
IMO, trying to use Consistently using |
|
@bors r+ |
…uwer Rollup of 9 pull requests Successful merges: - #158404 (trait_solver: normalize next-gen region constraints) - #160631 (Do not eagerly download rustfmt in bootstrap) - #160642 (mir: prohibit projection into scalable vec) - #160749 (MaybeDangling: ensure references fit inside the address space) - #160791 (Use recognizer functions for enums and tuple structs) - #160500 (Fix inaccurate description for crate and pathroot) - #160590 (Docs & bors: Replace mentions of libs-api with libs) - #160825 (Fix references to unsupported on sys::paths::unix) - #160852 (Use `remove_dir_all` for `./x clean`) Failed merges: - #160829 (bootstrap: Make `main.rs` a stub that calls into the library crate)
This comment has been minimized.
This comment has been minimized.
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.
85b2700 to
55050c1
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Rebased over import conflicts. @bors r=clubby789 |
…uwer Rollup of 5 pull requests Successful merges: - #156338 (Implement derives for Reborrow and CoerceShared) - #158083 (Fix perf regression in `Read::read_to_end` on short reads due to not checking if the cursor has initialized bytes) - #160829 (bootstrap: Make `main.rs` a stub that calls into the library crate) - #159839 (point at closure return expression in non-`FnOnce` E0271 errors) - #160775 (interpret: treat pattern and unsafe-binder as ABI-transparent)
Rollup merge of #160829 - Zalathar:bootstrap-main, r=clubby789 bootstrap: Make `main.rs` a stub that calls into the library crate 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 file `cli_main.rs` within the bootstrap library crate. That avoids the need for any public exports other than `cli_main::main` itself. There should be no change to bootstrap behaviour. --- This change makes it possible to change all of bootstrap's `pub` items to `pub(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: - #147506
…uwer Rollup of 9 pull requests Successful merges: - rust-lang/rust#158404 (trait_solver: normalize next-gen region constraints) - rust-lang/rust#160631 (Do not eagerly download rustfmt in bootstrap) - rust-lang/rust#160642 (mir: prohibit projection into scalable vec) - rust-lang/rust#160749 (MaybeDangling: ensure references fit inside the address space) - rust-lang/rust#160791 (Use recognizer functions for enums and tuple structs) - rust-lang/rust#160500 (Fix inaccurate description for crate and pathroot) - rust-lang/rust#160590 (Docs & bors: Replace mentions of libs-api with libs) - rust-lang/rust#160825 (Fix references to unsupported on sys::paths::unix) - rust-lang/rust#160852 (Use `remove_dir_all` for `./x clean`) Failed merges: - rust-lang/rust#160829 (bootstrap: Make `main.rs` a stub that calls into the library crate)
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: