Skip to content

We should extend --explain to include config options #9990

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

Closed
xFrednet opened this issue Nov 29, 2022 · 3 comments · Fixed by #10751
Closed

We should extend --explain to include config options #9990

xFrednet opened this issue Nov 29, 2022 · 3 comments · Fixed by #10751
Assignees
Labels
A-documentation Area: Adding or improving documentation A-ui Area: Clippy interface, usage and configuration C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise.

Comments

@xFrednet
Copy link
Member

xFrednet commented Nov 29, 2022

Clippy has an --explain command to display the lint documentation in the console. Ideally, we'd like to expand the command to include the configurations, which effect the lint emission. This is already done for Clippy's lint list.

Here is an example for such a lint: borrow_as_ptr

This implementation could take inspiration from how we collect the metadata for our lint list:

fn get_lint_configs(&self, lint_name: &str) -> Option<String> {

CC: #9880

@xFrednet xFrednet added A-documentation Area: Adding or improving documentation C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise. A-ui Area: Clippy interface, usage and configuration labels Nov 29, 2022
bors added a commit that referenced this issue Dec 28, 2022
fix codeblocks in the document

While I've looked into #9990, I found broken code blocks in the document.

This patch not only improves visibility, but also fixes a potential bug. When a lint description ends with code block, the string will have three backquotes at the end.
Since the current implementation prints the default value immediately after that, the markdown renderer is unable to properly close the code block.

e.g. `arithmetic_side_effects`, we can see code block is not rendered properly, and (I think) it's bit hard to understand what ``"defaults to `[]`"`` is meant.

![2022-12-26_01-51](https://user-images.githubusercontent.com/14945055/209476342-4d0b2e18-44b6-4c74-8c3c-4f4f0904e8ca.png)

In this PR, it will be rendered as:

![image](https://user-images.githubusercontent.com/14945055/209476353-07587b86-1100-445f-946d-41f62f741e51.png)

changelog: none

r? `@xFrednet`
@blyxyas
Copy link
Member

blyxyas commented Apr 22, 2023

This would require moving metadata_collector.rs out of internal_lints and removing this #[cfg] feature check.

Btw, why does this feature (internal) exists? rustup downloads compiled artifacts, so unused code gets removed AFAIK.

If the feature exists because of compile-times, maybe we should remove it as between times from cargo build --features internal to cargo build there's only a 1.4% difference (in my machine). I think that's negligible.

@xFrednet
Copy link
Member Author

It would be good if we could find a way, to connect the data without enabling all internal lints. But this can include enabling some code from the metadata collection monster by default. This mainly involves connecting the configs to the lint documentation and should be relatively simple.

Btw, why does this feature (internal) exists?

I'm not 100% sure, but my guess is a combination of these factors:

  • Performance and size, these lints should never detect code outside of Clippy, so they would just waste time and disk space for other projects
  • Errors, internal lints are generally less tested than normal lints, which increases the chance of ICEs
  • Maybe dependencies?

metadata_collector.rs

The metadata collection monster was the first bigger project I worked on in Clippy/rust-lang. Looking at the code takes me back. I also love how it was okay to have more stupid comments in that code :D

@blyxyas
Copy link
Member

blyxyas commented May 5, 2023

@rustbot claim
Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documentation Area: Adding or improving documentation A-ui Area: Clippy interface, usage and configuration C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants