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

Update Clippy #110003

Merged
merged 136 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
471de0c
Document `cargo-clippy` feature
danielparks Jan 26, 2023
1e17a44
Remove the `NodeId` of `ast::ExprKind::Async`
Swatinem Jan 31, 2023
4fdae81
add large future lint
csmoe Feb 27, 2023
7f44530
Create `clear_with_drain` lint
bluthej Mar 18, 2023
85d4281
Pull `is_full_range` method from `iter_with_drain`
bluthej Mar 18, 2023
589d7e1
Add tests to cover all cases
bluthej Mar 18, 2023
484c82e
Update lint declaration
bluthej Mar 20, 2023
c7e3e30
Add the lint logic
bluthej Mar 21, 2023
1d0acce
Add test for partial range
bluthej Mar 21, 2023
e8ec242
Finish tests - add rustfix
bluthej Mar 21, 2023
d56c941
Merge branch 'rust-lang:master' into clear-with-drain
bluthej Mar 22, 2023
a90e5cc
Use split-debuginfo = "unpacked" for debug builds
Alexendoo Mar 17, 2023
ecc2012
Wrap transmutes_expressible_as_ptr_casts suggestions in parentheses
Alexendoo Mar 23, 2023
765c6b8
A MIR transform that checks pointers are aligned
saethlin Nov 10, 2022
f96e38b
Fix clippy
saethlin Mar 24, 2023
50d92d0
Add suggestions to `extra_unused_type_parameters`
mkrasnitski Mar 23, 2023
00e9372
Auto merge of #10516 - Alexendoo:split-debuginfo, r=flip1995
bors Mar 24, 2023
8df896c
Merge commit 'd5e2a7aca55ed49fc943b7a07a8eba05ab5a0079' into clippyup
flip1995 Mar 24, 2023
982c81a
docs fix: unknown field `allowed-locales`
FixedThink Mar 24, 2023
b13f99c
Fix allow attribute, items from macros in `items_after_statements`
Alexendoo Mar 24, 2023
b782a07
Add explanation on how to run `cargo-clippy` and `clippy-driver`
Noratrieb Mar 22, 2023
ed6c15a
Auto merge of #10541 - FixedThink:patch-1, r=llogiq
bors Mar 24, 2023
52c4dc6
fix [`cast_possible_truncation`] offering wrong suggestion when casti…
J-ZhengLi Mar 14, 2023
f1b9105
Auto merge of #10454 - Alexendoo:transmutes-expressible-as-ptr-casts-…
bors Mar 25, 2023
27edc2a
Auto merge of #10531 - Nilstrieb:linklink, r=giraffate
bors Mar 25, 2023
5ed64d4
Auto merge of #10496 - J-ZhengLi:issue_10366, r=Alexendoo
bors Mar 25, 2023
a6f56cb
Move unnecessary_struct_initialization to nursery
Alexendoo Mar 26, 2023
1d168b3
Merge branch 'rust-lang:master' into clear-with-drain
bluthej Mar 26, 2023
ee0de53
Add some tests
bluthej Mar 23, 2023
2493be2
Improve `is_range_full` implementation
bluthej Mar 26, 2023
3966580
Add tests with `usize::MIN`
bluthej Mar 26, 2023
db4e4af
Don't elaborate non-obligations into obligations
compiler-errors Mar 26, 2023
022f76d
Added the new lint with some docs and tests
botahamec Jul 2, 2022
1b55c81
Lint on trait declarations, not implementations
botahamec Feb 26, 2023
a143fb7
Avoid breaking exported API
botahamec Feb 26, 2023
76d13bb
Don't lint functions with "box" in their name
botahamec Mar 26, 2023
5698f43
Auto merge of #10552 - Alexendoo:unnecessary-struct-initialization-nu…
bors Mar 27, 2023
df65d21
Include tests where the iterator is used later
bluthej Mar 27, 2023
70db226
Auto merge of #10528 - bluthej:clear-with-drain, r=llogiq
bors Mar 27, 2023
28b8005
Add notes to non-structural const in pattern error message
jamen Mar 27, 2023
538e8bd
Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errors
GuillaumeGomez Mar 27, 2023
fc6262f
Add `(..)` syntax for RTN
compiler-errors Mar 16, 2023
d57abf3
Rollup merge of #108548 - jamen:master, r=compiler-errors
matthiaskrgr Mar 28, 2023
3259b48
Migrate `format_args.rs` to `rustc_ast::FormatArgs`
Alexendoo Mar 28, 2023
d9821e1
Auto merge of #10542 - Alexendoo:items-after-statements, r=giraffate
bors Mar 28, 2023
84e42fb
Auto merge of #10484 - Alexendoo:format-args-ast-2, r=Manishearth
bors Mar 28, 2023
6589d79
Replace remaining usage of `FormatArgsExpn`
Alexendoo Mar 28, 2023
58fb801
Auto merge of #10561 - Alexendoo:format-args-ast-3, r=Manishearth
bors Mar 28, 2023
783879e
Partial no-op refactoring of #9948
nyurik Mar 29, 2023
4f5a019
Update clippy_lints/src/large_futures.rs
csmoe Mar 29, 2023
51b4d2a
In uninit checking, add fallback for polymorphic types
Noratrieb Mar 26, 2023
c5011e9
Auto merge of #10553 - Nilstrieb:better-uninit, r=Alexendoo
bors Mar 29, 2023
4cf5bdc
Stabilize a portion of 'once_cell'
tgross35 Dec 12, 2022
a216553
fix `single_component_path_imports` FP
ebobrow Mar 30, 2023
ef3867f
Auto merge of #9102 - botahamec:unused-box, r=xFrednet
bors Mar 30, 2023
6e87ae0
Run metadata collection
xFrednet Mar 30, 2023
799732c
Auto merge of #10414 - csmoe:large-future, r=xFrednet
bors Mar 30, 2023
17f8045
Ignore `file!()` macro in `print_literal`, `write_literal`
Alexendoo Mar 30, 2023
d43714a
Auto merge of #10573 - Alexendoo:print-literal-file-macro, r=Jarcho
bors Mar 30, 2023
d29dec1
Update subtree sync docs for changes in rustc-dev-guide
jyn514 Mar 30, 2023
41b367f
Gramar, and spelin kleanup
nyurik Mar 11, 2023
89160b6
Auto merge of #10487 - nyurik:readme-fixes, r=dswij
bors Mar 31, 2023
3c964ea
Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obk
bors Mar 31, 2023
6601d85
Flag `bufreader.lines().filter_map(Result::ok)` as suspicious
samueltardieu Mar 22, 2023
2998706
Auto merge of #10536 - mkrasnitski:suggestions, r=flip1995
bors Mar 31, 2023
6a6a262
Auto merge of #109010 - compiler-errors:rtn, r=eholk
bors Mar 31, 2023
ac4838c
Auto merge of #10534 - samueltardieu:lines-filter-map-ok, r=llogiq
bors Apr 1, 2023
b2856a7
Add `tests_outside_test_module` lint
blyxyas Mar 24, 2023
05650b7
[arithmetic_side_effects] Fix #10583
c410-f3r Apr 2, 2023
36047b0
Fix `nonminimal_bool` `#[allow]` attributes.
blyxyas Apr 2, 2023
8d83c15
Auto merge of #10585 - c410-f3r:aaaaaaaaaaaa, r=Jarcho
bors Apr 2, 2023
8f0ba1f
Auto merge of #10563 - nyurik:handle-all-fmt2, r=llogiq
bors Apr 2, 2023
7fe83ed
Auto merge of #10588 - blyxyas:fix-allow_nonminimal_bool, r=llogiq
bors Apr 2, 2023
e2742a0
Fix `double_must_use` for async functions
blyxyas Apr 2, 2023
207955c
Auto merge of #10574 - jyn514:update-docs, r=flip1995
bors Apr 3, 2023
e903af5
Auto merge of #10229 - danielparks:doc-feature-cargo-clippy, r=flip1995
bors Apr 3, 2023
d602743
only focus on `double_must_use` + Add `Result<(), ()>` test
blyxyas Apr 3, 2023
afdfbf8
Show multiple clippy.toml warnings with `sess.warn` instead of `eprin…
bhould287 Apr 1, 2023
a37eb4d
Fix false negative on `Result<(), ()>`
blyxyas Apr 3, 2023
9e53b65
Auto merge of #10591 - beetrees:warnings-not-eprintln, r=flip1995
bors Apr 3, 2023
3b22352
Fix bug with getting parent directories in `lookup_conf_file`
bhould287 Apr 1, 2023
bd2a5b2
Remove check for `#[cfg(test)]`
blyxyas Apr 3, 2023
85d9f17
Auto merge of #10589 - blyxyas:fix-double_must_use, r=giraffate
bors Apr 4, 2023
c12748f
fix(needless_return): do not trigger on ambiguous match arms return
feniljain Apr 1, 2023
73e412b
Auto merge of #10592 - beetrees:parent-dir-bug-fix, r=giraffate
bors Apr 4, 2023
b2f9191
Fix formatting and lint description
blyxyas Apr 4, 2023
a6beddc
rust-analyzer guided enum variant structification
oli-obk Mar 29, 2023
929696d
rust-analyzer guided tuple field to named field
oli-obk Mar 29, 2023
ff7636d
Split out ast::ItemKind::Const into its own struct
oli-obk Mar 29, 2023
5d149c5
Auto merge of #10543 - blyxyas:tests_outside_test_module, r=flip1995
bors Apr 4, 2023
e610ddf
box a bunch of large types
oli-obk Mar 29, 2023
e9c7fb1
Rename `ast::Static` to `ast::StaticItem` to match `ast::ConstItem`
oli-obk Mar 29, 2023
2891d8f
Make redundant_async_block a more complete late pass
samueltardieu Mar 26, 2023
b499b7d
test: add test for match as stmt no triggering needless_return
feniljain Apr 5, 2023
9cf57d0
fix(needles_return): correct span selection for text replacement
feniljain Apr 5, 2023
26e245d
Auto merge of #10554 - samueltardieu:redundant-async-block, r=Jarcho
bors Apr 5, 2023
008e07d
fix [mem_replace_option_with_none] not considering field variables
J-ZhengLi Apr 6, 2023
04c387e
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Apr 6, 2023
fa42506
Bump nightly version -> 2023-04-06
flip1995 Apr 6, 2023
2b05f79
Auto merge of #10602 - flip1995:rustup, r=flip1995
bors Apr 6, 2023
b66aa09
Add [`manual_slice_size_calculation`]
schubart Mar 19, 2023
b47a322
Add tests suggested by @llogiq
schubart Apr 6, 2023
de5c6d6
Auto merge of #10594 - J-ZhengLi:issue9824, r=Jarcho
bors Apr 6, 2023
cf260bc
Fix broken links for Rust merge
blyxyas Apr 6, 2023
b1c784d
Fix false negatives by using `expr_or_init`
schubart Apr 6, 2023
9408d01
Auto merge of #10566 - ebobrow:iss10549, r=giraffate
bors Apr 7, 2023
b8cbce8
Auto merge of #10601 - schubart:manual_slice_size_calculation, r=llogiq
bors Apr 7, 2023
5d01e6e
new lint: suspicious_doc_comments
y21 Mar 13, 2023
90e6ddc
New chapter: "Type Checking"
blyxyas Apr 7, 2023
4a2cb5a
Auto merge of #10497 - y21:outer_doc_comment_bang, r=dswij
bors Apr 7, 2023
592ea39
Auto merge of #10604 - blyxyas:fix-book_broken_links, r=flip1995
bors Apr 7, 2023
9ec5428
Add 5 other container types and start testing
bluthej Apr 6, 2023
4905a21
Add `max_line_length` to `.editorconfig`, matching `rustfmt.toml`
beetrees Apr 8, 2023
1cf6406
Add "`hir::Ty` and `ty::Ty`" section
blyxyas Apr 8, 2023
82d71b1
Auto merge of #10605 - blyxyas:book-type_checking, r=llogiq
bors Apr 8, 2023
5b57e5c
Fix false negative with `String` and add tests
bluthej Apr 9, 2023
32aa07f
Fix false negative for `Strings`
bluthej Apr 9, 2023
423b54a
Update documentation for `clear_with_drain`
bluthej Apr 9, 2023
7852962
Change `format!` style to please dogfood test
bluthej Apr 9, 2023
d8f0a96
Merge branch 'rust-lang:master' into clear-with-drain
bluthej Apr 9, 2023
5109a8a
[missing_const_for_fn] fix #7121
KisaragiEffective Apr 9, 2023
ba1f19e
apply code review suggestion
KisaragiEffective Apr 9, 2023
7de7ca8
Auto merge of #10610 - beetrees:max-line-length, r=Jarcho
bors Apr 9, 2023
015fb8a
Auto merge of #10618 - KisaragiEffective:patch-2, r=llogiq
bors Apr 9, 2023
d6fe73d
remove unusued feature
the8472 Apr 10, 2023
4904d75
Auto merge of #10624 - the8472:remove-drain-filter-feature, r=xFrednet
bors Apr 10, 2023
e22019d
Auto merge of #10593 - feniljain:fix-needless-return, r=xFrednet
bors Apr 10, 2023
5ec2e19
Auto merge of #10614 - bluthej:clear-with-drain, r=Manishearth
bors Apr 11, 2023
63030ac
Refactor
schubart Mar 12, 2023
008ba73
Ignore fake read access
schubart Mar 12, 2023
3d71145
Add test case from #10488
schubart Mar 12, 2023
3b5b2ed
Auto merge of #10492 - schubart:collection_is_never_read_unit_type, r…
bors Apr 11, 2023
0266a9e
Fix links in Clippy book
flip1995 Apr 11, 2023
83e42a2
Auto merge of #10630 - flip1995:book-link-fix, r=xFrednet
bors Apr 11, 2023
0ca8ae5
Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup
flip1995 Apr 11, 2023
c355e6b
Update Cargo.lock
flip1995 Apr 11, 2023
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 Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ dependencies = [
name = "clippy_lints"
version = "0.1.70"
dependencies = [
"arrayvec 0.7.0",
"cargo_metadata 0.15.3",
"clippy_utils",
"declare_clippy_lint",
Expand Down
3 changes: 3 additions & 0 deletions src/tools/clippy/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ target-dir = "target"

[unstable]
binary-dep-depinfo = true

[profile.dev]
split-debuginfo = "unpacked"
1 change: 1 addition & 0 deletions src/tools/clippy/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
max_line_length = 120

[*.md]
# double whitespace at end of line
Expand Down
2 changes: 2 additions & 0 deletions src/tools/clippy/.github/workflows/clippy_bors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ jobs:

# Run
- name: Build Integration Test
env:
CARGO_PROFILE_DEV_SPLIT_DEBUGINFO: off
run: cargo test --test integration --features integration --no-run

# Upload
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/.github/workflows/remark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install mdbook
run: |
mkdir mdbook
curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.18/mdbook-v0.4.18-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.28/mdbook-v0.4.28-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH

# Run
Expand Down
7 changes: 7 additions & 0 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4441,6 +4441,7 @@ Released 2018-09-13
[`chars_last_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_last_cmp
[`chars_next_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_next_cmp
[`checked_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#checked_conversions
[`clear_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#clear_with_drain
[`clone_double_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
[`clone_on_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
[`clone_on_ref_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_ref_ptr
Expand Down Expand Up @@ -4632,6 +4633,7 @@ Released 2018-09-13
[`large_const_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays
[`large_digit_groups`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_digit_groups
[`large_enum_variant`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
[`large_futures`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_futures
[`large_include_file`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_include_file
[`large_stack_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_arrays
[`large_types_passed_by_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_types_passed_by_value
Expand All @@ -4645,6 +4647,7 @@ Released 2018-09-13
[`let_underscore_untyped`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_untyped
[`let_unit_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
[`let_with_type_underscore`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_with_type_underscore
[`lines_filter_map_ok`]: https://rust-lang.github.io/rust-clippy/master/index.html#lines_filter_map_ok
[`linkedlist`]: https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist
[`logic_bug`]: https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug
[`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal
Expand All @@ -4671,6 +4674,7 @@ Released 2018-09-13
[`manual_rem_euclid`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid
[`manual_retain`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_retain
[`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
[`manual_slice_size_calculation`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_slice_size_calculation
[`manual_split_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_split_once
[`manual_str_repeat`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat
[`manual_string_new`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_string_new
Expand Down Expand Up @@ -4921,6 +4925,7 @@ Released 2018-09-13
[`suspicious_arithmetic_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_arithmetic_impl
[`suspicious_assignment_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_assignment_formatting
[`suspicious_command_arg_space`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_command_arg_space
[`suspicious_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_doc_comments
[`suspicious_else_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting
[`suspicious_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_map
[`suspicious_op_assign_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_op_assign_impl
Expand All @@ -4933,6 +4938,7 @@ Released 2018-09-13
[`tabs_in_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments
[`temporary_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_assignment
[`temporary_cstring_as_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_cstring_as_ptr
[`tests_outside_test_module`]: https://rust-lang.github.io/rust-clippy/master/index.html#tests_outside_test_module
[`to_digit_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_digit_is_some
[`to_string_in_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_display
[`to_string_in_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args
Expand Down Expand Up @@ -4974,6 +4980,7 @@ Released 2018-09-13
[`unit_hash`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_hash
[`unit_return_expecting_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_return_expecting_ord
[`unknown_clippy_lints`]: https://rust-lang.github.io/rust-clippy/master/index.html#unknown_clippy_lints
[`unnecessary_box_returns`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_box_returns
[`unnecessary_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
[`unnecessary_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_filter_map
[`unnecessary_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_find_map
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Lints are divided into categories, each with a default [lint level](https://doc.
You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.

| Category | Description | Default level |
| --------------------- | ----------------------------------------------------------------------------------- | ------------- |
|-----------------------|-------------------------------------------------------------------------------------|---------------|
| `clippy::all` | all lints that are on by default (correctness, suspicious, style, complexity, perf) | **warn/deny** |
| `clippy::correctness` | code that is outright wrong or useless | **deny** |
| `clippy::suspicious` | code that is most likely wrong or useless | **warn** |
Expand Down Expand Up @@ -130,7 +130,7 @@ for example.

You can add Clippy to Travis CI in the same way you use it locally:

```yml
```yaml
language: rust
rust:
- stable
Expand Down Expand Up @@ -253,7 +253,7 @@ rust-version = "1.30"

The MSRV can also be specified as an attribute, like below.

```rust
```rust,ignore
#![feature(custom_inner_attributes)]
#![clippy::msrv = "1.30.0"]

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
Expand Up @@ -14,7 +14,7 @@ much Clippy is supposed to ~~annoy~~ help you by changing the lint level by
category.

| Category | Description | Default level |
| --------------------- | ----------------------------------------------------------------------------------- | ------------- |
|-----------------------|-------------------------------------------------------------------------------------|---------------|
| `clippy::all` | all lints that are on by default (correctness, suspicious, style, complexity, perf) | **warn/deny** |
| `clippy::correctness` | code that is outright wrong or useless | **deny** |
| `clippy::suspicious` | code that is most likely wrong or useless | **warn** |
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [Development](development/README.md)
- [Basics](development/basics.md)
- [Adding Lints](development/adding_lints.md)
- [Type Checking](development/type_checking.md)
- [Common Tools](development/common_tools_writing_lints.md)
- [Infrastructure](development/infrastructure/README.md)
- [Syncing changes between Clippy and rust-lang/rust](development/infrastructure/sync.md)
Expand Down
29 changes: 25 additions & 4 deletions src/tools/clippy/book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
> **Note:** The configuration file is unstable and may be deprecated in the future.

Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml`. It contains a
basic `variable = value` mapping eg.
basic `variable = value` mapping e.g.

```toml
avoid-breaking-exported-api = false
Expand Down Expand Up @@ -60,7 +60,7 @@ And to warn on `lint_name`, run
cargo clippy -- -W clippy::lint_name
```

This also works with lint groups. For example you can run Clippy with warnings for all lints enabled:
This also works with lint groups. For example, you can run Clippy with warnings for all lints enabled:

```terminal
cargo clippy -- -W clippy::pedantic
Expand All @@ -84,7 +84,7 @@ msrv = "1.30.0"

The MSRV can also be specified as an attribute, like below.

```rust
```rust,ignore
#![feature(custom_inner_attributes)]
#![clippy::msrv = "1.30.0"]

Expand All @@ -96,7 +96,28 @@ fn main() {
You can also omit the patch version when specifying the MSRV, so `msrv = 1.30`
is equivalent to `msrv = 1.30.0`.

Note: `custom_inner_attributes` is an unstable feature so it has to be enabled explicitly.
Note: `custom_inner_attributes` is an unstable feature, so it has to be enabled explicitly.

Lints that recognize this configuration option can be
found [here](https://rust-lang.github.io/rust-clippy/master/index.html#msrv)

### Disabling evaluation of certain code

> **Note:** This should only be used in cases where other solutions, like `#[allow(clippy::all)]`, are not sufficient.

Very rarely, you may wish to prevent Clippy from evaluating certain sections of code entirely. You can do this with
[conditional compilation](https://doc.rust-lang.org/reference/conditional-compilation.html) by checking that the
`cargo-clippy` feature is not set. You may need to provide a stub so that the code compiles:

```rust
#[cfg(not(feature = "cargo-clippy"))]
include!(concat!(env!("OUT_DIR"), "/my_big_function-generated.rs"));

#[cfg(feature = "cargo-clippy")]
fn my_big_function(_input: &str) -> Option<MyStruct> {
None
}
```

This feature is not actually part of your crate, so specifying `--all-features` to other tools, e.g. `cargo test
--all-features`, will not disable it.
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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.
> this point onward, and you should return to one of the earlier chapters.

## Getting started

Expand Down
32 changes: 21 additions & 11 deletions src/tools/clippy/book/src/development/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ because that's clearly a non-descriptive name.
- [Cargo lints](#cargo-lints)
- [Rustfix tests](#rustfix-tests)
- [Testing manually](#testing-manually)
- [Running directly](#running-directly)
- [Lint declaration](#lint-declaration)
- [Lint registration](#lint-registration)
- [Lint passes](#lint-passes)
Expand Down Expand Up @@ -186,6 +187,15 @@ cargo dev lint input.rs
from the working copy root. With tests in place, let's have a look at
implementing our lint now.

## Running directly

While it's easier to just use `cargo dev lint`, it might be desirable to get
`target/release/cargo-clippy` and `target/release/clippy-driver` to work as well in some cases.
By default, they don't work because clippy dynamically links rustc. To help them find rustc,
add the path printed by`rustc --print target-libdir` (ran inside this workspace so that the rustc version matches)
to your library search path.
On linux, this can be done by setting the `LD_LIBRARY_PATH` environment variable to that path.

## Lint declaration

Let's start by opening the new file created in the `clippy_lints` crate at
Expand Down Expand Up @@ -265,7 +275,7 @@ When declaring a new lint by hand and `cargo dev update_lints` is used, the lint
pass may have to be registered manually in the `register_plugins` function in
`clippy_lints/src/lib.rs`:

```rust
```rust,ignore
store.register_early_pass(|| Box::new(foo_functions::FooFunctions));
```

Expand All @@ -291,7 +301,7 @@ either [`EarlyLintPass`][early_lint_pass] or [`LateLintPass`][late_lint_pass].

In short, the `LateLintPass` has access to type information while the
`EarlyLintPass` doesn't. If you don't need access to type information, use the
`EarlyLintPass`. The `EarlyLintPass` is also faster. However linting speed
`EarlyLintPass`. The `EarlyLintPass` is also faster. However, linting speed
hasn't really been a concern with Clippy so far.

Since we don't need type information for checking the function name, we used
Expand All @@ -308,7 +318,7 @@ implementation of the lint logic.

Let's start by implementing the `EarlyLintPass` for our `FooFunctions`:

```rust
```rust,ignore
impl EarlyLintPass for FooFunctions {
fn check_fn(&mut self, cx: &EarlyContext<'_>, fn_kind: FnKind<'_>, span: Span, _: NodeId) {
// TODO: Emit lint here
Expand All @@ -327,10 +337,10 @@ variety of lint emission functions. They can all be found in
[`clippy_utils/src/diagnostics.rs`][diagnostics].

`span_lint_and_help` seems most appropriate in this case. It allows us to
provide an extra help message and we can't really suggest a better name
provide an extra help message, and we can't really suggest a better name
automatically. This is how it looks:

```rust
```rust,ignore
impl EarlyLintPass for FooFunctions {
fn check_fn(&mut self, cx: &EarlyContext<'_>, fn_kind: FnKind<'_>, span: Span, _: NodeId) {
span_lint_and_help(
Expand Down Expand Up @@ -469,7 +479,7 @@ the value from `clippy.toml`. This can be accounted for using the
`extract_msrv_attr!(LintContext)` macro and passing
`LateContext`/`EarlyContext`.

```rust
```rust,ignore
impl<'tcx> LateLintPass<'tcx> for ManualStrip {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
...
Expand All @@ -483,7 +493,7 @@ the lint's test file, `tests/ui/manual_strip.rs` in this example. It should
have a case for the version below the MSRV and one with the same contents but
for the MSRV version itself.

```rust
```rust,ignore
...

#[clippy::msrv = "1.44"]
Expand Down Expand Up @@ -514,7 +524,7 @@ define_Conf! {

If you have trouble implementing your lint, there is also the internal `author`
lint to generate Clippy code that detects the offending pattern. It does not
work for all of the Rust syntax, but can give a good starting point.
work for all the Rust syntax, but can give a good starting point.

The quickest way to use it, is the [Rust playground:
play.rust-lang.org][author_example]. Put the code you want to lint into the
Expand Down Expand Up @@ -607,7 +617,7 @@ output in the `stdout` part.

## PR Checklist

Before submitting your PR make sure you followed all of the basic requirements:
Before submitting your PR make sure you followed all the basic requirements:

<!-- Sync this with `.github/PULL_REQUEST_TEMPLATE` -->

Expand All @@ -627,7 +637,7 @@ for some users. Adding a configuration is done in the following steps:

1. Adding a new configuration entry to [`clippy_lints::utils::conf`] like this:

```rust
```rust,ignore
/// Lint: LINT_NAME.
///
/// <The configuration field doc comment>
Expand Down Expand Up @@ -680,7 +690,7 @@ for some users. Adding a configuration is done in the following steps:
configuration value is now cloned or copied into a local value that is then
passed to the impl struct like this:

```rust
```rust,ignore
// Default generated registration:
store.register_*_pass(|| box module::StructName);

Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/book/src/development/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This document explains the basics for hacking on Clippy. Besides others, this
includes how to build and test Clippy. For a more in depth description on the
codebase take a look at [Adding Lints] or [Common Tools].

[Adding Lints]: https://github.com/rust-lang/rust-clippy/blob/master/book/src/development/adding_lints.md
[Common Tools]: https://github.com/rust-lang/rust-clippy/blob/master/book/src/development/common_tools_writing_lints.md
[Adding Lints]: adding_lints.md
[Common Tools]: common_tools_writing_lints.md

- [Basics for hacking on Clippy](#basics-for-hacking-on-clippy)
- [Get the Code](#get-the-code)
Expand Down Expand Up @@ -125,7 +125,7 @@ We follow a rustc no merge-commit policy. See
## Common Abbreviations

| Abbreviation | Meaning |
| ------------ | -------------------------------------- |
|--------------|----------------------------------------|
| UB | Undefined Behavior |
| FP | False Positive |
| FN | False Negative |
Expand Down
Loading