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

Build the Clippy book as part of x.py doc #98848

Merged
merged 2 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ impl<'a> Builder<'a> {
doc::RustcBook,
doc::CargoBook,
doc::Clippy,
doc::ClippyBook,
doc::Miri,
doc::EmbeddedBook,
doc::EditionGuide,
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ macro_rules! book {
// and checking against it?).
book!(
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;
EmbeddedBook, "src/doc/embedded-book", "embedded-book", submodule;
Nomicon, "src/doc/nomicon", "nomicon", submodule;
Expand Down
4 changes: 4 additions & 0 deletions src/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ accomplishing various tasks.

[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

Many of Rust's errors come with error codes, and you can request extended
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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)
[![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
[Rust](https://github.com/rust-lang/rust) code.
Expand Down
33 changes: 18 additions & 15 deletions src/tools/clippy/book/src/development/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ because that's clearly a non-descriptive name.
- [Testing](#testing)
- [Cargo lints](#cargo-lints)
- [Rustfix tests](#rustfix-tests)
- [Edition 2018 tests](#edition-2018-tests)
- [Testing manually](#testing-manually)
- [Lint declaration](#lint-declaration)
- [Lint registration](#lint-registration)
Expand Down Expand Up @@ -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
a lower MSRV.

First, add an MSRV alias for the required feature in
[`clippy_utils::msrvs`](/clippy_utils/src/msrvs.rs). This can be accessed later
as `msrvs::STR_STRIP_PREFIX`, for example.
First, add an MSRV alias for the required feature in [`clippy_utils::msrvs`].
This can be accessed later as `msrvs::STR_STRIP_PREFIX`, for example.

```rust
msrv_aliases! {
Expand Down Expand Up @@ -468,6 +466,8 @@ define_Conf! {
}
```

[`clippy_utils::msrvs`]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/msrvs/index.html

## Author lint

If you have trouble implementing your lint, there is also the internal `author`
Expand Down Expand Up @@ -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
for some users. Adding a configuration is done in the following steps:

1. Adding a new configuration entry to
[clippy_lints::utils::conf](/clippy_lints/src/utils/conf.rs) like this:
1. Adding a new configuration entry to [`clippy_lints::utils::conf`] like this:

```rust
/// Lint: LINT_NAME.
Expand Down Expand Up @@ -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:

First find the struct construction in the [clippy_lints lib
file](/clippy_lints/src/lib.rs). The configuration value is now cloned or
copied into a local value that is then passed to the impl struct like this:
First find the struct construction in the [`clippy_lints` lib file]. The
configuration value is now cloned or copied into a local value that is then
passed to the impl struct like this:

```rust
// Default generated registration:
Expand All @@ -653,12 +652,16 @@ for some users. Adding a configuration is done in the following steps:

4. Adding tests:
1. The default configured value can be tested like any normal lint in
[`tests/ui`](/tests/ui).
2. The configuration itself will be tested separately in
[`tests/ui-toml`](/tests/ui-toml). Simply add a new subfolder with a
fitting name. This folder contains a `clippy.toml` file with the
configuration value and a rust file that should be linted by Clippy. The
test can otherwise be written as usual.
[`tests/ui`].
2. The configuration itself will be tested separately in [`tests/ui-toml`].
Simply add a new subfolder with a fitting name. This folder contains a
`clippy.toml` file with the configuration value and a rust file that
should be linted by Clippy. The 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

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/development/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ cargo dev setup intellij
```

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,4 @@ functions to deal with macros:
[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
[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
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ clippy-driver --edition 2018 -Cpanic=abort foo.rs
> that are not optimized as expected, for example.

[Installation]: installation.md
[CI]: continuous_integration
[CI]: continuous_integration/index.md