Skip to content

Conversation

@ChrisDenton
Copy link
Member

@ChrisDenton ChrisDenton commented Dec 25, 2025

This makes rustc simply return an exit code from main rather than calling std::process::exit with an exit code. This means that drops run normally and the process exits cleanly. This is similar to what happens when an ICE occurs (due to being a panic that's caught by std's lang_start).

Also instead of hard coding success and failure codes this uses ExitCode::SUCCESS and ExitCode::FAILURE, which in turn effectively uses libc::EXIT_SUCCESS and libc::EXIT_FAILURE (via std). These are 0 and 1 respectively for all currently supported host platforms so it doesn't actually change the exit code.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 25, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 25, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Dec 25, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Dec 25, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 25, 2025

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@Kobzol
Copy link
Member

Kobzol commented Dec 25, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Dec 25, 2025
Return `ExitCode` from `rustc_driver::main` instead of calling `process::exit`
@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 25, 2025
@rust-bors
Copy link
Contributor

rust-bors bot commented Dec 25, 2025

☀️ Try build successful (CI)
Build commit: ffd099f (ffd099ff891368a934635eba38de913f96f6ab17, parent: 1bf12c32a08384862297674921d1137ad94892dc)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ffd099f): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.2%] 1
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.0% [-0.1%, -0.0%] 3
All ❌✅ (primary) 0.2% [0.2%, 0.2%] 1

Max RSS (memory usage)

Results (secondary -1.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.2% [1.6%, 2.4%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.2% [-5.1%, -3.7%] 5
All ❌✅ (primary) - - 0

Cycles

Results (secondary 2.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.3% [2.5%, 6.6%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.6%, -2.2%] 2
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 482.343s -> 483.621s (0.26%)
Artifact size: 392.46 MiB -> 390.44 MiB (-0.51%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 25, 2025
Comment on lines +410 to +412
exit(if exit_code == ExitCode::SUCCESS {
rustc_driver::EXIT_SUCCESS
} else {
rustc_driver::EXIT_FAILURE
})
Copy link
Member Author

@ChrisDenton ChrisDenton Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annoyingly ExitCode does not have a method to convert it to the i32 that process::exit requires. I think this is a libs issue that should be addressed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that is unfortunate.

Either way, 👍 for the Miri changes.

@rust-bors

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 23, 2026

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.

@rust-log-analyzer

This comment has been minimized.

This makes rustc simply return an exit code from main rather than calling `std::process::exit` with an exit code. This means that drops run normally and the process exits cleanly.

Also instead of hard coding success and failure codes this uses `ExitCode::SUCCESS` and `ExitCode::FAILURE`, which in turn effectively uses `libc::EXIT_SUCCESS` and `libc::EXIT_FAILURE` (via std). These are `0` and `1` respectively for all currently supported host platforms so it doesn't actually change the exit code.
/// Variant of `catch_fatal_errors` for the `interface::Result` return type
/// that also computes the exit code.
pub fn catch_with_exit_code(f: impl FnOnce()) -> i32 {
pub fn catch_with_exit_code<T: Termination>(f: impl FnOnce() -> T) -> ExitCode {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this so that people can optionally return an ExitCode when using catch_with_exit_code rather than having to use process::exit.

Note that the Termination trait is implemented for () so this shouldn't make a difference to existing code unless they opt-in to returning ExitCode (or anything else that implements the trait).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants