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

Explain how Clippy and lints work #2687

Merged
merged 2 commits into from Apr 25, 2018

Conversation

phansch
Copy link
Member

@phansch phansch commented Apr 21, 2018

Also for #2666

This adds a rough overview of how Clippy hooks into rustc and how different lint types are registered with the PluginRegistry. It doesn't explain everything yet, but should give a good overview, hopefully.

It is partly inspired by the quick rustfmt tour.

Rendered

@phansch
Copy link
Member Author

phansch commented Apr 21, 2018

Would be good if someone with more experience has a look at this, as I'm not sure if I used the correct terms everywhere.

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

Looks good to me

reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
// ...

reg.register_lint_group("clippy_restriction", vec![
Copy link
Member

Choose a reason for hiding this comment

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

Worth mentioning that this code is autogenerated

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, I'm not sure I understand how that code would be autogenerated. It's a normal call to Registry.register_lint_group, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

The util/update_lints.py script looks through the sources and collects all lint definitions to generate this part of lib.rs.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, that kind of autogenerated! I've always been modifying it manually until now.. Makes sense to add it 👍

@phansch
Copy link
Member Author

phansch commented Apr 24, 2018

I added the note about the update_lints.py script.

@oli-obk oli-obk merged commit 9a37566 into rust-lang:master Apr 25, 2018
@phansch phansch deleted the explain_how_lints_work branch April 25, 2018 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants