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

README: Add subsection on running Clippy as a rustc wrapper #6782

Merged
merged 1 commit into from
Feb 24, 2021

Conversation

ojeda
Copy link
Contributor

@ojeda ojeda commented Feb 23, 2021

This is useful for projects that do not use cargo.

changelog: README: Add subsection on running Clippy as a rustc wrapper

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @phansch (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 23, 2021
README.md Outdated
Then, to enable Clippy, you will need to call:

```terminal
clippy-driver rustc --edition 2018 -Cpanic=abort foo.rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
clippy-driver rustc --edition 2018 -Cpanic=abort foo.rs
clippy-driver --edition 2018 -Cpanic=abort foo.rs

also works. This does only work with rustc as a second argument, because the clippy-driver has a hack that removes this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that, but I didn't know it was the preferred way -- that is good to know! I will add a note for that also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the title of the subsection to match, too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't note that, because it is an implementation detail necessary to make clippy work.

The clippy-driver binary is the same as the rustc binary from the user/CLI perspective, just that it runs more lints.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

What do you mean by necessary? From what I understand, the hack around the second argument isn't be necessary but it is there for cargo clippy, no?

Anyway, I agree the chances of someone hitting that behavior by mistake without intending to do so are very low; however, it is still user-facing behavior. For me, as a user, it is OK if it is not supported but I'd prefer to know about it (and users may still notice via cargo verbose output anyway, like I did, and wonder what is going on).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary for cargo clippy to work, yes. It's because cargo for some reason runs clippy-driver rustc, so Clippy has to get rid of the rustc.

It doesn't hurt that adding rustc to the command is possible. But I don't see a reason, why we should advertise it.

(and users may still notice via cargo verbose output anyway, like I did, and wonder what is going on)

If you're interested in that, you could ask why it is implemented like this on Zulip or on other channels. IMO it's the same question as why cargo adds -C extra-filename=-73486377a7462660 to the command.

This is useful for projects that do not use cargo.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
@ojeda ojeda force-pushed the readme-as-wrapper branch from d7bbda5 to 6b8b43c Compare February 24, 2021 00:55
@flip1995
Copy link
Member

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented Feb 24, 2021

📌 Commit 6b8b43c has been approved by flip1995

@bors
Copy link
Contributor

bors commented Feb 24, 2021

⌛ Testing commit 6b8b43c with merge 045d3f3...

@bors
Copy link
Contributor

bors commented Feb 24, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing 045d3f3 to master...

@bors bors merged commit 045d3f3 into rust-lang:master Feb 24, 2021
@ojeda ojeda deleted the readme-as-wrapper branch February 24, 2021 12:30
@ojeda
Copy link
Contributor Author

ojeda commented Feb 24, 2021

Thanks to you! Cheers.

ojeda added a commit to Rust-for-Linux/linux that referenced this pull request Feb 26, 2021
It turns out that is only a workaround intended for `cargo`.
The official instructions since PR [1] describe the usage of
`clippy-driver`, and they intentionally only cover replacing
`rustc` with `clippy-driver` rather than wrapping it, as
discussed in that PR.

[1] rust-lang/rust-clippy#6782

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants