-
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
Make sure -Dunused-crate-dependencies --json unused-externs
makes rustc exit with error status
#96085
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
I don't like this PR, see my comment here: #96068 (comment) |
Just took a look at this. These changes look good to me, but I don't have context around why the behavior this PR adjusts is the way it currently is (except for reading #96068 (comment)). More concretely, is this blocked on #96067 landing and cargo being adjusted to use |
// aux-crate:bar=bar.rs | ||
|
||
fn main() {} | ||
//~^ ERROR external crate `bar` unused in |
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.
This line can be removed now, right? stderr should not contain it.
let mut inner = self.inner.borrow_mut(); | ||
|
||
if loud && lint_level.is_error() { | ||
inner.bump_err_count(); |
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.
Is this needed? bumping the error count should happen automatically if the lint is an error, no?
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.
Yes, it's needed because if we're going via the json event path, the normal diagnostics are not emitted, so error count isn't bumped. This is the core of the change to make get errors to be reported in the exit status.
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.
I see, makes sense 👍 .
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.
With the --json unused-externs-silent
flag my general concerns are resolved. I still wonder about two of the code changes, see inline comments.
03a2965
to
bb91830
Compare
ping? |
@compiler-errors the cargo implementation was never merged. #96067. It won't break any users, but I would still prefer for the feature to be compatible with the design my PR proposed. |
@compiler-errors Yeah, I think |
@bors r+ |
📌 Commit bb91830f7a1545ec38a2736819a1931c4b259c98 has been approved by |
⌛ Testing commit bb91830f7a1545ec38a2736819a1931c4b259c98 with merge 299f80b2776088e087a626daf2c3e455d5044c1b... |
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
As generated by --json unused-externs.
There were none at all. These test for original functionality, but this also adds a test that `-Dunused-crate-dependencies` causes a compilation failure, which currently fails (rust-lang#96068). This is fixed in subsequent changes.
…error status Closes: rust-lang#96068
Since Cargo wants to do its own fatal error handling for unused dependencies, add the option `--json unused-externs-silent` which has the original behaviour of not indicating non-zero exit status for `deny`/`forbid`-level unused dependencies.
Update with reblessed tests. |
@bors r+ |
📌 Commit c6bafa7 has been approved by |
…rrors Make sure `-Dunused-crate-dependencies --json unused-externs` makes rustc exit with error status This PR: - fixes compiletest to understand unused extern notifications - adds tests for `--json unused-externs` - makes sure that deny-level unused externs notifications are treated as compile errors - refactors the `emit_unused_externs` callstack to plumb through the level as an enum as a string, and adds `Level::is_error` Update: adds `--json unused-externs-silent` with the original behaviour since Cargo needs it. Should address `@est31's` concerns. Fixes: rust-lang#96068
☀️ Test successful - checks-actions |
Finished benchmarking commit (0e7915d): comparison url. Summary: This benchmark run did not return any relevant results. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
This PR:
--json unused-externs
emit_unused_externs
callstack to plumb through the level as an enum as a string, and addsLevel::is_error
Update: adds
--json unused-externs-silent
with the original behaviour since Cargo needs it. Should address @est31's concerns.Fixes: #96068