-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Exit nonzero on rustc -Wall #92504
Exit nonzero on rustc -Wall #92504
Conversation
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
Seems reasonable to me; returning non-zero on an unknown command-line option seems like the correct behavior, as long as that option isn't something ignored for compatibility purposes (which this isn't). For some reason, I'm remembering a past incarnation of an issue very much like this, though I don't remember the details. Do you recall a previous issue about the exit code of |
I do not. |
compiler/rustc_driver/src/lib.rs
Outdated
} | ||
|
||
// Handle the special case of -Wall. | ||
let wall = matches.opt_strs("W"); | ||
if wall.iter().any(|x| *x == "all") { | ||
print_wall_help(); | ||
return None; | ||
return Err(ErrorReported); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use rustc_errors::FatalError.raise();
instead. This is what early_error()
uses too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! That works. I've updated the PR.
r=me with commits squashed |
@bors r=jackh726 |
📌 Commit 7174ec2 has been approved by |
@bors rollup |
…askrgr Rollup of 8 pull requests Successful merges: - rust-lang#91055 (return the correct type for closures in `type_of`) - rust-lang#92207 (Delay remaining `span_bug`s in drop elaboration) - rust-lang#92417 (Fix spacing and ordering of words in pretty printed Impl) - rust-lang#92504 (Exit nonzero on rustc -Wall) - rust-lang#92559 (RustWrapper: adapt to new AttributeMask API) - rust-lang#92589 (Break the loop) - rust-lang#92607 (rustc_metadata: Some minor cleanups and optimizations) - rust-lang#92620 (Remove unused `ExtendDefault` struct) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Previously
rustc -Wall /dev/null
would print a paragraph explaining that-Wall
is not a thing in Rust, but would then exit 0. I believe exiting 0 is not the right behavior. For something likerustc --version
orrustc --help
orrustc -C help
the user is requesting rustc to print some information; rustc prints that information and exits 0 because what the user requested has been accomplished. In the case ofrustc -Wall path/to/main.rs
, I don't find it correct to conceptualize this as "the user requested rustc to print information about the fact that Wall doesn't exist". The user requested a particular thing, and despite rustc knowing what they probably meant and informing them about that, the thing they requested has not been accomplished. Thus a nonzero exit code is needed.