-
Notifications
You must be signed in to change notification settings - Fork 180
Fix 'main' return value #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for your contribution fellow Rustacean |
In fact, it seems to follow what is being defined in the source:
Correctly returns 1 to the parent process.
But that can be used in the meantime to test execution behavior. |
Is this really a valid issue? If we don't look at what Rust should really accept, declaring |
This will be fixed as part of traits https://doc.rust-lang.org/std/process/trait.Termination.html Though maybe we should consider implementing the never '!' type sooner than later. I thought this might be an unstable thing last I remember @flip1995 ? |
Correct, the never type is still unstable. We want to stabilize it, but there are some back compat issues around type inference that could cause UB. The current plan is to add a lint for this I believe. |
The #[lang = "start"]
fn lang_start(argc: usize, argv: *const *const u8, main: fn()) -> isize {
main();
0
}
fn main() {} and #[lang = "start"]
fn lang_start<T: Terminator>(argc: usize, argv: *const *const u8, main: fn() -> T) -> isize {
main().report()
}
fn main() {} (might have mixed up the argument order and used the wrong argv type) |
So looking at the Rust reference for main function, exactly 2 types can be returned by main (in stable Rust):
When then looking at the |
As discussed in https://gcc-rust.zulipchat.com/#narrow/stream/281658-compiler-development/topic/Testsuite/near/230597886:
Fixing this (so that we get deterministic normal process termination) is a prerequisite for #281 "Create runnable test folder".
The text was updated successfully, but these errors were encountered: