Skip to content

Commit ead06fc

Browse files
authored
Merge branch 'rust-lang:master' into collection_is_never_read_unit_type
2 parents dbaeb1b + 82d71b1 commit ead06fc

File tree

306 files changed

+6694
-3123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

306 files changed

+6694
-3123
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ target-dir = "target"
1111

1212
[unstable]
1313
binary-dep-depinfo = true
14+
15+
[profile.dev]
16+
split-debuginfo = "unpacked"

.github/workflows/clippy_bors.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ jobs:
180180

181181
# Run
182182
- name: Build Integration Test
183+
env:
184+
CARGO_PROFILE_DEV_SPLIT_DEBUGINFO: off
183185
run: cargo test --test integration --features integration --no-run
184186

185187
# Upload

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4382,6 +4382,7 @@ Released 2018-09-13
43824382
<!-- begin autogenerated links to lint list -->
43834383
[`absurd_extreme_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
43844384
[`alloc_instead_of_core`]: https://rust-lang.github.io/rust-clippy/master/index.html#alloc_instead_of_core
4385+
[`allow_attributes`]: https://rust-lang.github.io/rust-clippy/master/index.html#allow_attributes
43854386
[`allow_attributes_without_reason`]: https://rust-lang.github.io/rust-clippy/master/index.html#allow_attributes_without_reason
43864387
[`almost_complete_letter_range`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_complete_letter_range
43874388
[`almost_complete_range`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_complete_range
@@ -4440,6 +4441,7 @@ Released 2018-09-13
44404441
[`chars_last_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_last_cmp
44414442
[`chars_next_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_next_cmp
44424443
[`checked_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#checked_conversions
4444+
[`clear_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#clear_with_drain
44434445
[`clone_double_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
44444446
[`clone_on_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
44454447
[`clone_on_ref_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_ref_ptr
@@ -4631,6 +4633,7 @@ Released 2018-09-13
46314633
[`large_const_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays
46324634
[`large_digit_groups`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_digit_groups
46334635
[`large_enum_variant`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
4636+
[`large_futures`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_futures
46344637
[`large_include_file`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_include_file
46354638
[`large_stack_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_arrays
46364639
[`large_types_passed_by_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_types_passed_by_value
@@ -4644,6 +4647,7 @@ Released 2018-09-13
46444647
[`let_underscore_untyped`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_untyped
46454648
[`let_unit_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
46464649
[`let_with_type_underscore`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_with_type_underscore
4650+
[`lines_filter_map_ok`]: https://rust-lang.github.io/rust-clippy/master/index.html#lines_filter_map_ok
46474651
[`linkedlist`]: https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist
46484652
[`logic_bug`]: https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug
46494653
[`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal
@@ -4661,6 +4665,7 @@ Released 2018-09-13
46614665
[`manual_instant_elapsed`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_instant_elapsed
46624666
[`manual_is_ascii_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check
46634667
[`manual_let_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
4668+
[`manual_main_separator_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_main_separator_str
46644669
[`manual_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
46654670
[`manual_memcpy`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_memcpy
46664671
[`manual_non_exhaustive`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive
@@ -4669,6 +4674,7 @@ Released 2018-09-13
46694674
[`manual_rem_euclid`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid
46704675
[`manual_retain`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_retain
46714676
[`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
4677+
[`manual_slice_size_calculation`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_slice_size_calculation
46724678
[`manual_split_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_split_once
46734679
[`manual_str_repeat`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat
46744680
[`manual_string_new`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_string_new
@@ -4919,6 +4925,7 @@ Released 2018-09-13
49194925
[`suspicious_arithmetic_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_arithmetic_impl
49204926
[`suspicious_assignment_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_assignment_formatting
49214927
[`suspicious_command_arg_space`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_command_arg_space
4928+
[`suspicious_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_doc_comments
49224929
[`suspicious_else_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting
49234930
[`suspicious_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_map
49244931
[`suspicious_op_assign_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_op_assign_impl
@@ -4931,6 +4938,7 @@ Released 2018-09-13
49314938
[`tabs_in_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments
49324939
[`temporary_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_assignment
49334940
[`temporary_cstring_as_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_cstring_as_ptr
4941+
[`tests_outside_test_module`]: https://rust-lang.github.io/rust-clippy/master/index.html#tests_outside_test_module
49344942
[`to_digit_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_digit_is_some
49354943
[`to_string_in_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_display
49364944
[`to_string_in_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args
@@ -4972,6 +4980,7 @@ Released 2018-09-13
49724980
[`unit_hash`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_hash
49734981
[`unit_return_expecting_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_return_expecting_ord
49744982
[`unknown_clippy_lints`]: https://rust-lang.github.io/rust-clippy/master/index.html#unknown_clippy_lints
4983+
[`unnecessary_box_returns`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_box_returns
49754984
[`unnecessary_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
49764985
[`unnecessary_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_filter_map
49774986
[`unnecessary_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_find_map
@@ -4985,6 +4994,7 @@ Released 2018-09-13
49854994
[`unnecessary_safety_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_safety_doc
49864995
[`unnecessary_self_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_self_imports
49874996
[`unnecessary_sort_by`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by
4997+
[`unnecessary_struct_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_struct_initialization
49884998
[`unnecessary_to_owned`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned
49894999
[`unnecessary_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
49905000
[`unnecessary_wraps`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ a [developer guide] and is a good place to start your journey.
5050
All issues on Clippy are mentored, if you want help simply ask someone from the
5151
Clippy team directly by mentioning them in the issue or over on [Zulip]. All
5252
currently active team members can be found
53-
[here](https://github.com/rust-lang/highfive/blob/master/highfive/configs/rust-lang/rust-clippy.json#L3)
53+
[here](https://github.com/rust-lang/rust-clippy/blob/master/triagebot.toml#L18)
5454

5555
Some issues are easier than others. The [`good-first-issue`] label can be used to find the easy
5656
issues. You can use `@rustbot claim` to assign the issue to yourself.

COPYRIGHT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
// REUSE-IgnoreStart
2+
13
Copyright 2014-2022 The Rust Project Developers
24

35
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
46
http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
57
<LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
68
option. All files in the project carrying such notice may not be
79
copied, modified, or distributed except according to those terms.
10+
11+
// REUSE-IgnoreEnd

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Lints are divided into categories, each with a default [lint level](https://doc.
1111
You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.
1212

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

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

133-
```yml
133+
```yaml
134134
language: rust
135135
rust:
136136
- stable
@@ -253,7 +253,7 @@ rust-version = "1.30"
253253

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

256-
```rust
256+
```rust,ignore
257257
#![feature(custom_inner_attributes)]
258258
#![clippy::msrv = "1.30.0"]
259259
@@ -275,10 +275,14 @@ If you want to contribute to Clippy, you can find more information in [CONTRIBUT
275275

276276
## License
277277

278+
<!-- REUSE-IgnoreStart -->
279+
278280
Copyright 2014-2022 The Rust Project Developers
279281

280282
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
281283
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)> or the MIT license
282284
<LICENSE-MIT or [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)>, at your
283285
option. Files in the project may not be
284286
copied, modified, or distributed except according to those terms.
287+
288+
<!-- REUSE-IgnoreEnd -->

book/src/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ much Clippy is supposed to ~~annoy~~ help you by changing the lint level by
1414
category.
1515

1616
| Category | Description | Default level |
17-
| --------------------- | ----------------------------------------------------------------------------------- | ------------- |
17+
|-----------------------|-------------------------------------------------------------------------------------|---------------|
1818
| `clippy::all` | all lints that are on by default (correctness, suspicious, style, complexity, perf) | **warn/deny** |
1919
| `clippy::correctness` | code that is outright wrong or useless | **deny** |
2020
| `clippy::suspicious` | code that is most likely wrong or useless | **warn** |

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [Development](development/README.md)
1414
- [Basics](development/basics.md)
1515
- [Adding Lints](development/adding_lints.md)
16+
- [Type Checking](development/type_checking.md)
1617
- [Common Tools](development/common_tools_writing_lints.md)
1718
- [Infrastructure](development/infrastructure/README.md)
1819
- [Syncing changes between Clippy and rust-lang/rust](development/infrastructure/sync.md)

book/src/configuration.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
> **Note:** The configuration file is unstable and may be deprecated in the future.
44
55
Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml`. It contains a
6-
basic `variable = value` mapping eg.
6+
basic `variable = value` mapping e.g.
77

88
```toml
99
avoid-breaking-exported-api = false
@@ -60,7 +60,7 @@ And to warn on `lint_name`, run
6060
cargo clippy -- -W clippy::lint_name
6161
```
6262

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

6565
```terminal
6666
cargo clippy -- -W clippy::pedantic
@@ -84,7 +84,7 @@ msrv = "1.30.0"
8484

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

87-
```rust
87+
```rust,ignore
8888
#![feature(custom_inner_attributes)]
8989
#![clippy::msrv = "1.30.0"]
9090
@@ -96,7 +96,28 @@ fn main() {
9696
You can also omit the patch version when specifying the MSRV, so `msrv = 1.30`
9797
is equivalent to `msrv = 1.30.0`.
9898

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

101101
Lints that recognize this configuration option can be
102102
found [here](https://rust-lang.github.io/rust-clippy/master/index.html#msrv)
103+
104+
### Disabling evaluation of certain code
105+
106+
> **Note:** This should only be used in cases where other solutions, like `#[allow(clippy::all)]`, are not sufficient.
107+
108+
Very rarely, you may wish to prevent Clippy from evaluating certain sections of code entirely. You can do this with
109+
[conditional compilation](https://doc.rust-lang.org/reference/conditional-compilation.html) by checking that the
110+
`cargo-clippy` feature is not set. You may need to provide a stub so that the code compiles:
111+
112+
```rust
113+
#[cfg(not(feature = "cargo-clippy"))]
114+
include!(concat!(env!("OUT_DIR"), "/my_big_function-generated.rs"));
115+
116+
#[cfg(feature = "cargo-clippy")]
117+
fn my_big_function(_input: &str) -> Option<MyStruct> {
118+
None
119+
}
120+
```
121+
122+
This feature is not actually part of your crate, so specifying `--all-features` to other tools, e.g. `cargo test
123+
--all-features`, will not disable it.

book/src/development/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ making Clippy better by contributing to it. In that case, welcome to the
55
project!
66

77
> _Note:_ If you're just interested in using Clippy, there's nothing to see from
8-
> this point onward and you should return to one of the earlier chapters.
8+
> this point onward, and you should return to one of the earlier chapters.
99
1010
## Getting started
1111

book/src/development/adding_lints.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ because that's clearly a non-descriptive name.
1818
- [Cargo lints](#cargo-lints)
1919
- [Rustfix tests](#rustfix-tests)
2020
- [Testing manually](#testing-manually)
21+
- [Running directly](#running-directly)
2122
- [Lint declaration](#lint-declaration)
2223
- [Lint registration](#lint-registration)
2324
- [Lint passes](#lint-passes)
@@ -186,6 +187,15 @@ cargo dev lint input.rs
186187
from the working copy root. With tests in place, let's have a look at
187188
implementing our lint now.
188189

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

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

268-
```rust
278+
```rust,ignore
269279
store.register_early_pass(|| Box::new(foo_functions::FooFunctions));
270280
```
271281

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

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

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

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

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

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

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

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

486-
```rust
496+
```rust,ignore
487497
...
488498
489499
#[clippy::msrv = "1.44"]
@@ -514,7 +524,7 @@ define_Conf! {
514524

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

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

608618
## PR Checklist
609619

610-
Before submitting your PR make sure you followed all of the basic requirements:
620+
Before submitting your PR make sure you followed all the basic requirements:
611621

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

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

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

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

683-
```rust
693+
```rust,ignore
684694
// Default generated registration:
685695
store.register_*_pass(|| box module::StructName);
686696

book/src/development/basics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ We follow a rustc no merge-commit policy. See
125125
## Common Abbreviations
126126

127127
| Abbreviation | Meaning |
128-
| ------------ | -------------------------------------- |
128+
|--------------|----------------------------------------|
129129
| UB | Undefined Behavior |
130130
| FP | False Positive |
131131
| FN | False Negative |

0 commit comments

Comments
 (0)