Rollup merge of #98848 - flip1995:clippy-book, r=jyn514

Build the Clippy book as part of x.py doc

r? ``@ehuss`` since you said you would be interested in helping moving this forward.

cc ``@jyn514`` as part of the bootstrap team.
This commit is contained in:
Guillaume Gomez 2022-07-13 10:38:42 +02:00 committed by GitHub
commit 0b3644e1f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 19 deletions

View File

@ -697,6 +697,7 @@ impl<'a> Builder<'a> {
doc::RustcBook, doc::RustcBook,
doc::CargoBook, doc::CargoBook,
doc::Clippy, doc::Clippy,
doc::ClippyBook,
doc::Miri, doc::Miri,
doc::EmbeddedBook, doc::EmbeddedBook,
doc::EditionGuide, doc::EditionGuide,

View File

@ -74,6 +74,7 @@ macro_rules! book {
// and checking against it?). // and checking against it?).
book!( book!(
CargoBook, "src/tools/cargo/src/doc", "cargo", submodule = "src/tools/cargo"; CargoBook, "src/tools/cargo/src/doc", "cargo", submodule = "src/tools/cargo";
ClippyBook, "src/tools/clippy/book", "clippy";
EditionGuide, "src/doc/edition-guide", "edition-guide", submodule; EditionGuide, "src/doc/edition-guide", "edition-guide", submodule;
EmbeddedBook, "src/doc/embedded-book", "embedded-book", submodule; EmbeddedBook, "src/doc/embedded-book", "embedded-book", submodule;
Nomicon, "src/doc/nomicon", "nomicon", submodule; Nomicon, "src/doc/nomicon", "nomicon", submodule;

View File

@ -93,6 +93,10 @@ accomplishing various tasks.
[The Rustdoc Book](rustdoc/index.html) describes our documentation tool, `rustdoc`. [The Rustdoc Book](rustdoc/index.html) describes our documentation tool, `rustdoc`.
## The Clippy Book
[The Clippy Book](clippy/index.html) describes our static analyzer, Clippy.
## Extended Error Listing ## Extended Error Listing
Many of Rust's errors come with error codes, and you can request extended Many of Rust's errors come with error codes, and you can request extended

View File

@ -1,7 +1,7 @@
# Clippy # Clippy
[![Clippy Test](https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test/badge.svg?branch=auto&event=push)](https://github.com/rust-lang/rust-clippy/actions?query=workflow%3A%22Clippy+Test%22+event%3Apush+branch%3Aauto) [![Clippy Test](https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test/badge.svg?branch=auto&event=push)](https://github.com/rust-lang/rust-clippy/actions?query=workflow%3A%22Clippy+Test%22+event%3Apush+branch%3Aauto)
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license) [![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](https://github.com/rust-lang/rust-clippy#license)
A collection of lints to catch common mistakes and improve your A collection of lints to catch common mistakes and improve your
[Rust](https://github.com/rust-lang/rust) code. [Rust](https://github.com/rust-lang/rust) code.

View File

@ -13,7 +13,6 @@ because that's clearly a non-descriptive name.
- [Testing](#testing) - [Testing](#testing)
- [Cargo lints](#cargo-lints) - [Cargo lints](#cargo-lints)
- [Rustfix tests](#rustfix-tests) - [Rustfix tests](#rustfix-tests)
- [Edition 2018 tests](#edition-2018-tests)
- [Testing manually](#testing-manually) - [Testing manually](#testing-manually)
- [Lint declaration](#lint-declaration) - [Lint declaration](#lint-declaration)
- [Lint registration](#lint-registration) - [Lint registration](#lint-registration)
@ -402,9 +401,8 @@ need to ensure that the MSRV configured for the project is >= the MSRV of the
required Rust feature. If multiple features are required, just use the one with required Rust feature. If multiple features are required, just use the one with
a lower MSRV. a lower MSRV.
First, add an MSRV alias for the required feature in First, add an MSRV alias for the required feature in [`clippy_utils::msrvs`].
[`clippy_utils::msrvs`](/clippy_utils/src/msrvs.rs). This can be accessed later This can be accessed later as `msrvs::STR_STRIP_PREFIX`, for example.
as `msrvs::STR_STRIP_PREFIX`, for example.
```rust ```rust
msrv_aliases! { msrv_aliases! {
@ -468,6 +466,8 @@ define_Conf! {
} }
``` ```
[`clippy_utils::msrvs`]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/msrvs/index.html
## Author lint ## Author lint
If you have trouble implementing your lint, there is also the internal `author` If you have trouble implementing your lint, there is also the internal `author`
@ -583,8 +583,7 @@ the workspace directory. Adding a configuration to a lint can be useful for
thresholds or to constrain some behavior that can be seen as a false positive thresholds or to constrain some behavior that can be seen as a false positive
for some users. Adding a configuration is done in the following steps: for some users. Adding a configuration is done in the following steps:
1. Adding a new configuration entry to 1. Adding a new configuration entry to [`clippy_lints::utils::conf`] like this:
[clippy_lints::utils::conf](/clippy_lints/src/utils/conf.rs) like this:
```rust ```rust
/// Lint: LINT_NAME. /// Lint: LINT_NAME.
@ -635,9 +634,9 @@ for some users. Adding a configuration is done in the following steps:
``` ```
3. Passing the configuration value to the lint impl struct: 3. Passing the configuration value to the lint impl struct:
First find the struct construction in the [clippy_lints lib First find the struct construction in the [`clippy_lints` lib file]. The
file](/clippy_lints/src/lib.rs). The configuration value is now cloned or configuration value is now cloned or copied into a local value that is then
copied into a local value that is then passed to the impl struct like this: passed to the impl struct like this:
```rust ```rust
// Default generated registration: // Default generated registration:
@ -653,12 +652,16 @@ for some users. Adding a configuration is done in the following steps:
4. Adding tests: 4. Adding tests:
1. The default configured value can be tested like any normal lint in 1. The default configured value can be tested like any normal lint in
[`tests/ui`](/tests/ui). [`tests/ui`].
2. The configuration itself will be tested separately in 2. The configuration itself will be tested separately in [`tests/ui-toml`].
[`tests/ui-toml`](/tests/ui-toml). Simply add a new subfolder with a Simply add a new subfolder with a fitting name. This folder contains a
fitting name. This folder contains a `clippy.toml` file with the `clippy.toml` file with the configuration value and a rust file that
configuration value and a rust file that should be linted by Clippy. The should be linted by Clippy. The test can otherwise be written as usual.
test can otherwise be written as usual.
[`clippy_lints::utils::conf`]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/utils/conf.rs
[`clippy_lints` lib file]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/lib.rs
[`tests/ui`]: https://github.com/rust-lang/rust-clippy/blob/master/tests/ui
[`tests/ui-toml`]: https://github.com/rust-lang/rust-clippy/blob/master/tests/ui-toml
## Cheat Sheet ## Cheat Sheet

View File

@ -98,7 +98,7 @@ cargo dev setup intellij
``` ```
More about intellij command usage and reasons More about intellij command usage and reasons
[here](../CONTRIBUTING.md#intellij-rust) [here](https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#intellij-rust)
## lintcheck ## lintcheck

View File

@ -276,4 +276,4 @@ functions to deal with macros:
[LateContext]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LateContext.html [LateContext]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LateContext.html
[TyCtxt]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html [TyCtxt]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html
[pat_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckResults.html#method.pat_ty [pat_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckResults.html#method.pat_ty
[paths]: ../clippy_utils/src/paths.rs [paths]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/paths/index.html

View File

@ -148,4 +148,4 @@ clippy-driver --edition 2018 -Cpanic=abort foo.rs
> that are not optimized as expected, for example. > that are not optimized as expected, for example.
[Installation]: installation.md [Installation]: installation.md
[CI]: continuous_integration [CI]: continuous_integration/index.md