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

Support lint tool names in rustc command line options #86639

Merged
merged 5 commits into from
Jul 8, 2021

Conversation

eholk
Copy link
Contributor

@eholk eholk commented Jun 25, 2021

When rustc is running without a lint tool such as clippy enabled, options for lints such as clippy::foo are meant to be ignored. This was already working for those specified by attrs, such as #![allow(clippy::foo)], but this did not work for command line arguments like -A clippy::foo. This PR fixes that issue.

Note that we discovered this issue while discussing rust-lang/cargo#5034.

Fixes #86628.

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(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 Jun 25, 2021
@bors

This comment has been minimized.

@camsteffen
Copy link
Contributor

Does this mean we no longer need -- in cargo clippy -- -W clippy::lint?

@eholk
Copy link
Contributor Author

eholk commented Jun 30, 2021

Does this mean we no longer need -- in cargo clippy -- -W clippy::lint?

It shoudn't have any change there. This simply makes it so you can do rust -W clippy::lint without getting an error message.

@petrochenkov
Copy link
Contributor

The src/tools/rust-analyzer submodule update looks unintentional and needs to be removed.

@petrochenkov petrochenkov 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 Jul 1, 2021
@eholk
Copy link
Contributor Author

eholk commented Jul 2, 2021

Thanks for the comments, @petrochenkov. I removed the rust-analyzer submodule update.

@eholk
Copy link
Contributor Author

eholk commented Jul 2, 2021

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 2, 2021
@petrochenkov petrochenkov 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 Jul 2, 2021
@rust-log-analyzer

This comment has been minimized.

eholk added 3 commits July 6, 2021 15:49
This adds a ui test to make sure rustc accepts lint arguments such as
`-A clippy::foo` when clippy is disabled.
This shares a little more code between checking command line and
attribute lint specifications.
@eholk
Copy link
Contributor Author

eholk commented Jul 7, 2021

This is a little better now, although probably not quite ready to merge. I think there's some more cleanup still to do. Is it at least on the right path for solving the problem?

I'm also having an issue with my tests. Even after adding the .stderr file, I get the following failure. Any ideas?

unexpected errors (from JSON output): [
    Error {
        line_num: 1,
        kind: Some(
            Error,
        ),
        msg: "1:1: 1:1: unknown lint tool: `unknown_tool` [E0602]",
    },
    Error {
        line_num: 1,
        kind: Some(
            Error,
        ),
        msg: "1:1: 1:1: unknown lint tool: `unknown_tool` [E0602]",
    },
]

@rust-log-analyzer

This comment has been minimized.

@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 7, 2021
@petrochenkov
Copy link
Contributor

I'm also having an issue with my tests. Even after adding the .stderr file, I get the following failure. Any ideas?

The tests are missing //~ ERROR annotations.
Although, since the errors are not attached to spans you'll probably have to use // error-pattern: unknown lint tool: `unknown_tool` instead.

@petrochenkov
Copy link
Contributor

Tests need some adjustments, but otherwise LGTM.

@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 7, 2021
@petrochenkov petrochenkov added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 7, 2021
Previously this was using a `.stderr` file, but that does not seem to
work for all cases. This change uses `// error-pattern:` instead.
@rust-log-analyzer

This comment has been minimized.

This change merges `check_lint_and_tool_name` into `check_lint_name` in
order to avoid having two very similar functions.

Also adds the `.stderr` file back for the test case, since apparently
it is still needed.
@eholk
Copy link
Contributor Author

eholk commented Jul 7, 2021

Okay, this should be ready to go now.

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 7, 2021
@petrochenkov
Copy link
Contributor

Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented Jul 7, 2021

📌 Commit 4a83a93 has been approved by petrochenkov

@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-review Status: Awaiting review from the assignee but also interested parties. labels Jul 7, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jul 7, 2021
Support lint tool names in rustc command line options

When rustc is running without a lint tool such as clippy enabled, options for lints such as `clippy::foo` are meant to be ignored. This was already working for those specified by attrs, such as `#![allow(clippy::foo)]`, but this did not work for command line arguments like `-A clippy::foo`. This PR fixes that issue.

Note that we discovered this issue while discussing rust-lang/cargo#5034.

Fixes rust-lang#86628.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 8, 2021
Rollup of 9 pull requests

Successful merges:

 - rust-lang#86639 (Support lint tool names in rustc command line options)
 - rust-lang#86812 (Recover from `&dyn mut ...` parse errors)
 - rust-lang#86917 (Add doc comment for `impl From<LayoutError> for TryReserveError`)
 - rust-lang#86925 (Add self to mailmap)
 - rust-lang#86927 (Sync rustc_codegen_cranelift)
 - rust-lang#86932 (Fix ICE when misplaced visibility cannot be properly parsed)
 - rust-lang#86933 (Clean up rustdoc static files)
 - rust-lang#86955 (Fix typo in `ops::Drop` docs)
 - rust-lang#86956 (Revert "Add "every" as a doc alias for "all".")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c2d3f5f into rust-lang:master Jul 8, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 8, 2021
@eholk eholk deleted the lint-tool branch July 8, 2021 16:11
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rustc does not parse tool name for lints controlled by the command line
7 participants