Skip to content
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

Merged
merged 1 commit into from
Jan 7, 2022
Merged

Exit nonzero on rustc -Wall #92504

merged 1 commit into from
Jan 7, 2022

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Jan 2, 2022

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 like rustc --version or rustc --help or rustc -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 of rustc -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.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 2, 2022
@rust-highfive
Copy link
Collaborator

r? @jackh726

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 2, 2022
@joshtriplett
Copy link
Member

joshtriplett commented Jan 3, 2022

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 rustc under similar circumstances?

@dtolnay
Copy link
Member Author

dtolnay commented Jan 3, 2022

I do not.

}

// 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);
Copy link
Member

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.

Copy link
Member Author

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.

@jackh726
Copy link
Member

jackh726 commented Jan 6, 2022

r=me with commits squashed

@jackh726 jackh726 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 6, 2022
@dtolnay
Copy link
Member Author

dtolnay commented Jan 6, 2022

@bors r=jackh726

@bors
Copy link
Contributor

bors commented Jan 6, 2022

📌 Commit 7174ec2 has been approved by jackh726

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 6, 2022
@jackh726
Copy link
Member

jackh726 commented Jan 6, 2022

@bors rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 6, 2022
…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
@bors bors merged commit 844a657 into rust-lang:master Jan 7, 2022
@rustbot rustbot added this to the 1.59.0 milestone Jan 7, 2022
@dtolnay dtolnay deleted the wall branch January 31, 2022 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler 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