rust/book/src/development
bors 15ed281699 Auto merge of #10426 - oli-obk:ui_test, r=Manishearth
Port clippy away from compiletest to ui_test

Reasons to do this:

* runs completely on stable Rust
* is easier to extend with new features
* has its own dogfood test suite, so changes can be tested in [the `ui_test` repo](https://github.com/oli-obk/ui_test)
* supports dependencies from crates.io without having to manually fiddle with command line flags
* supports `ui-cargo`, `ui`, `ui-toml` out of the box, no need to find and run the tests ourselves

One thing that is a big difference to `compiletest` is that if a test emits *any* error, you need to mark all of them with `//~ ERROR:` annotations. Since many clippy tests did not have annotations, I changed many lints to be `warn` in their test so that only the `stderr` output is tested.

TODO:

* [ ] check that this still works as a subtree in the rustc repo

changelog: none
<!-- changelog_checked -->

Note: at present the latest changes needed for clippy are only available as a git dependency, but I expect to publish a new crates.io version soon
2023-06-26 17:32:51 +00:00
..
infrastructure update changelog's data ranges 2023-06-26 13:48:49 +02:00
proposals Spelling 2023-04-23 10:52:27 -04:00
adding_lints.md Port clippy away from compiletest to ui_test 2023-06-26 14:13:07 +00:00
basics.md Port clippy away from compiletest to ui_test 2023-06-26 14:13:07 +00:00
common_tools_writing_lints.md Gramar, and spelin kleanup 2023-03-30 15:31:14 -04:00
lint_passes.md run linkcheck in Remark CI 2023-04-28 15:11:48 +01:00
macro_expansions.md Add new chapter: "Macro Expansions" 2023-04-16 23:16:27 +02:00
README.md Improve type checking and lint passes chapters 2023-04-16 20:59:25 +02:00
type_checking.md Update urls in Type Checking 2023-05-17 22:55:14 +03:00

Clippy Development

Hello fellow Rustacean! If you made it here, you're probably interested in making Clippy better by contributing to it. In that case, welcome to the project!

Note: If you're just interested in using Clippy, there's nothing to see from this point onward, and you should return to one of the earlier chapters.

Getting started

If this is your first time contributing to Clippy, you should first read the Basics docs. This will explain the basics on how to get the source code and how to compile and test the code.

Additional Readings for Beginners

If a dear reader of this documentation has never taken a class on compilers and interpreters, it might be confusing as to why AST level deals with only the language's syntax. And some readers might not even understand what lexing, parsing, and AST mean.

This documentation serves by no means as a crash course on compilers or language design. And for details specifically related to Rust, the Rustc Development Guide is a far better choice to peruse.

The Syntax and AST chapter and the High-Level IR chapter are great introduction to the concepts mentioned in this chapter.

Some readers might also find the introductory chapter of Robert Nystrom's Crafting Interpreters a helpful overview of compiled and interpreted languages before jumping back to the Rustc guide.

Writing code

If you have done the basic setup, it's time to start hacking.

The Adding lints chapter is a walk through on how to add a new lint to Clippy. This is also interesting if you just want to fix a lint, because it also covers how to test lints and gives an overview of the bigger picture.

If you want to add a new lint or change existing ones apart from bugfixing, it's also a good idea to give the stability guarantees and lint categories sections of the Clippy 1.0 RFC a quick read. The lint categories are also described earlier in this book.

Note: Some higher level things about contributing to Clippy are still covered in the CONTRIBUTING.md document. Some of those will be moved to the book over time, like:

  • Finding something to fix
  • IDE setup
  • High level overview on how Clippy works
  • Triage procedure
  • Bors and Homu