Commit Graph

14403 Commits

Author SHA1 Message Date
bors
5a45805db5 Auto merge of #8947 - Serial-ATA:lint-produces-output, r=xFrednet
Add lint output to lint list

changelog: Add the ability to show the lint output in the lint list

This just adds the logic to produce the output, it hasn't been added to any lints yet. It did help find some mistakes in some docs though 😄.

### Screenshots

<details>
<summary>A single code block</summary>

![single-code-block](https://user-images.githubusercontent.com/69764315/172013766-145b22b1-1d91-4fb8-9cd0-b967a52d6330.png)
</details>

<details>
<summary>A single code block with a "Use instead" section</summary>

![with-usage](https://user-images.githubusercontent.com/69764315/172013792-d2dd6c9c-defa-41e0-8c27-8e8e311adb63.png)
</details>

<details>
<summary>Multiple code blocks</summary>

![multi-code-block](https://user-images.githubusercontent.com/69764315/172013808-5328f59b-e7c5-4914-a396-253822a6d350.png)
</details>

This is the last task in #7172 🎉.
r? `@xFrednet` (?)
2022-06-14 10:42:09 +00:00
bors
c07cbb9ea6 Auto merge of #8901 - Jarcho:sharing_code, r=dswij
Rework `branches_sharing_code`

fixes #7378

This changes the lint from checking pairs of blocks, to checking all the blocks at the same time. As such there's almost none of the original code left.

changelog: Don't lint `branches_sharing_code` when using different binding names
2022-06-14 08:59:40 +00:00
bors
c80ca2c1d6 Auto merge of #8997 - Jarcho:clap_deprecate, r=flip1995
Fix `clap` deprecation warnings

Clap `3.2.0` deprecated a few functions used by lintcheck.

changelog: None
2022-06-14 08:33:52 +00:00
Nicholas Nethercote
7969056f6f Rename the ConstS::val field as kind.
And likewise for the `Const::val` method.

Because its type is called `ConstKind`. Also `val` is a confusing name
because `ConstKind` is an enum with seven variants, one of which is
called `Value`. Also, this gives consistency with `TyS` and `PredicateS`
which have `kind` fields.

The commit also renames a few `Const` variables from `val` to `c`, to
avoid confusion with the `ConstKind::Value` variant.
2022-06-14 13:06:44 +10:00
Jason Newcomb
cccc750046 Fix clap deprecation warnings 2022-06-13 21:57:17 -04:00
bors
17b7ab004f Auto merge of #8988 - xFrednet:8947-test-monster-in-bors-ci, r=flip1995
Test metadata collection in Bors CI workflow

This PR adds a new check to bors CI workflows, which ensures that the metadata collection success, when it's run as part of the `deploy` script. I've only added it to bors workflows, as the runtime will be high while it'll also succeed most of the time. This is a preparation for rust-lang/rust-clippy#8947.

---

changelog: none

r? `@ghost`
2022-06-13 08:21:54 +00:00
Takayuki Maeda
d024997943 remove unnecessary to_string and String::new for tool_only_span_suggestion 2022-06-13 16:01:16 +09:00
Takayuki Maeda
f2d9acfc01 remove unnecessary to_string and String::new 2022-06-13 15:48:40 +09:00
bors
b95ce0eada Auto merge of #8983 - Alexendoo:redundant_closure_tests, r=giraffate
Add tests for some fixed `redundant_closure` issues

closes #7861
closes #5939

changelog: none
2022-06-13 00:14:31 +00:00
xFrednet
c6d04ec20b
Test metadata collection in Bors CI workflow 2022-06-12 16:22:24 +02:00
Camille GILLOT
7b84a97c3e Make ExprKind::Closure a struct variant. 2022-06-12 00:16:27 +02:00
Micha White
ded2bb5464
Slight documentation change 2022-06-10 13:12:03 -04:00
Micha White
f3dc7ae370
Fixed up the documentation for a couple functions 2022-06-10 13:12:03 -04:00
Micha White
01c75e4b98
Added tests for Cow and Result 2022-06-10 13:12:02 -04:00
Micha White
b0c20302b7
Some refactoring 2022-06-10 13:12:02 -04:00
Micha White
b46f1c4a7f
Don't trigger if a binding is in the else pattern 2022-06-10 13:12:02 -04:00
Micha White
2967127de2
Refactored the candidate type checking 2022-06-10 13:12:02 -04:00
Micha White
6d6c63ee23
Lint single_match with Options, Results, and Cows 2022-06-10 13:11:50 -04:00
Alex Macleod
eae9c56aab Add tests for some fixed redundant_closure issues 2022-06-10 13:25:22 +00:00
bors
b3c94c0828 Auto merge of #8976 - xFrednet:rust-97660-catch-emissions-with-expect, r=Jarcho
Fix some `#[expect]` lint interaction

Fixing the first few lints that aren't caught by `#[expect]`. The root cause of these examples was, that the lint was emitted at the wrong location.

---

changelog: none

r? `@Jarcho`

cc: rust-lang/rust#97660
2022-06-09 22:28:36 +00:00
bors
65f518e06c Auto merge of #8979 - Alexendoo:version-numbers, r=flip1995
Correct some `#[clippy::version]`s

Some were a bit off

changelog: none
2022-06-09 14:02:36 +00:00
Alex Macleod
2b655d4630 Correct some #[clippy::version]s 2022-06-09 13:50:07 +00:00
bors
4970527296 Auto merge of #8954 - Serial-ATA:doc-comment-issues, r=xFrednet
Improve lint doc consistency

changelog: none

This is a continuation of #8908.

Notable changes:
- Removed empty `Known Problems` sections
- Removed "Good"/"Bad" language (replaced with "Use instead")
- Removed (and added some 😄) duplication
- Ignored the [`create_dir`] example so it doesn't create `clippy_lints/foo` 😄
2022-06-09 11:03:49 +00:00
Serial
649ac36836 Fix [needless_bool] example 2022-06-09 06:54:01 -04:00
xFrednet
9d201d68b4
Fix #[expect] for default_numeric_fallback 2022-06-09 09:17:46 +02:00
bors
919cf5083b Auto merge of #8907 - kyoto7250:fix_8898, r=giraffate
fix(lint): check const context

close: https://github.com/rust-lang/rust-clippy/issues/8898

This PR fixes a bug in checked_conversions.

Thank you in advance.

changelog: check const context in checked_conversions.
2022-06-09 00:04:09 +00:00
bors
50541b90e9 Auto merge of #8950 - Jarcho:derive_non_pub, r=dswij
Fixes for `derive_partial_eq_without_eq`

fixes  #8875

changelog: Don't lint `derive_partial_eq_without_eq` on non-public types
changelog: Better handle generics in `derive_partial_eq_without_eq`
2022-06-08 14:03:50 +00:00
bors
ab8c8c6081 Auto merge of #8960 - Jarcho:iter_cloned, r=giraffate
Changes to `iter_overeager_cloned`

fixes: #8494

changelog: Don't lint `iter_overeager_cloned` on `.cloned().flatten()` when `T::Item` doesn't implement `IntoIterator`
2022-06-08 00:41:05 +00:00
Nicholas Nethercote
e34621c24e Folding revamp.
This commit makes type folding more like the way chalk does it.

Currently, `TypeFoldable` has `fold_with` and `super_fold_with` methods.
- `fold_with` is the standard entry point, and defaults to calling
  `super_fold_with`.
- `super_fold_with` does the actual work of traversing a type.
- For a few types of interest (`Ty`, `Region`, etc.) `fold_with` instead
  calls into a `TypeFolder`, which can then call back into
  `super_fold_with`.

With the new approach, `TypeFoldable` has `fold_with` and
`TypeSuperFoldable` has `super_fold_with`.
- `fold_with` is still the standard entry point, *and* it does the
  actual work of traversing a type, for all types except types of
  interest.
- `super_fold_with` is only implemented for the types of interest.

Benefits of the new model.
- I find it easier to understand. The distinction between types of
  interest and other types is clearer, and `super_fold_with` doesn't
  exist for most types.
- With the current model is easy to get confused and implement a
  `super_fold_with` method that should be left defaulted. (Some of the
  precursor commits fixed such cases.)
- With the current model it's easy to call `super_fold_with` within
  `TypeFolder` impls where `fold_with` should be called. The new
  approach makes this mistake impossible, and this commit fixes a number
  of such cases.
- It's potentially faster, because it avoids the `fold_with` ->
  `super_fold_with` call in all cases except types of interest. A lot of
  the time the compile would inline those away, but not necessarily
  always.
2022-06-08 09:24:03 +10:00
Serial
0e07f55ceb Hide unnecessary code in [implicit_saturating_sub] 2022-06-07 18:51:45 -04:00
bors
34f2839683 Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakis
Remove migrate borrowck mode

Closes #58781
Closes #43234

# Stabilization proposal

This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile.

Tracking issue: #43234
RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md
Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable).

## Motivation

Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors.

The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition.

In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker.

In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver.

While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff.

## What is stabilized

As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise.

There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](https://github.com/rust-lang/rust/issues/95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl.

As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions.

## What isn't stabilized

This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck.

## Tests

Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll`

## History

* On 2017-07-14, [tracking issue opened](https://github.com/rust-lang/rust/issues/43234)
* On 2017-07-20, [initial empty MIR pass added](https://github.com/rust-lang/rust/pull/43271)
* On 2017-08-29, [RFC opened](https://github.com/rust-lang/rfcs/pull/2094)
* On 2017-11-16, [Integrate MIR type-checker with NLL](https://github.com/rust-lang/rust/pull/45825)
* On 2017-12-20, [NLL feature complete](https://github.com/rust-lang/rust/pull/46862)
* On 2018-07-07, [Don't run AST borrowck on mir mode](https://github.com/rust-lang/rust/pull/52083)
* On 2018-07-27, [Add migrate mode](https://github.com/rust-lang/rust/pull/52681)
* On 2019-04-22, [Enable migrate mode on 2015 edition](https://github.com/rust-lang/rust/pull/59114)
* On 2019-08-26, [Don't downgrade errors on 2015 edition](https://github.com/rust-lang/rust/pull/64221)
* On 2019-08-27, [Remove AST borrowck](https://github.com/rust-lang/rust/pull/64790)
2022-06-07 05:04:14 +00:00
Jason Newcomb
bf3ab592f0 Changes to iter_overeager_cloned
* Don't lint on `.cloned().flatten()` when `T::Item` doesn't implement `IntoIterator`
* Reduce verbosity of lint message
* Narrow down the scope of the replacement range
2022-06-07 00:40:32 -04:00
Serial
cab5362d32 Suppress unused in doc examples 2022-06-06 20:28:16 -04:00
Serial
fdadebe672 Add lint output to lint list 2022-06-06 20:04:56 -04:00
Matthias Krüger
c1dcfd175e Rollup merge of #97794 - eltociear:patch-13, r=matthiaskrgr
Fix typo in redundant_pattern_match.rs

alway -> always
2022-06-07 01:13:48 +02:00
bors
72f5ff6903 Auto merge of #7359 - joshrotenberg:clippy_guide, r=xFrednet
Clippy book

A work in progress Clippy Book using mdbook. See #6011.

This is currently just a moving around of things:

1. The current README.md split up a bit and put into sections.
1. A rough outline of Clippy lint categories (currently no content, potentially add a basic introduction for each and some example, see questions below.
1. The `docs` content repurposed into a top level `Development` section.
1. The current Roadmap.

Some big questions:

1. is `guide/` the right place? I'm modeling after mdbook itself.
1. What is the relationship between ALL the Clippy Lints and this guide? It seems like they can coexist. Does that mean the guide should just point to the current side with regard to actual lints, and maybe just include some examples to keep it interesting? Keeping both up to date seems like a maintenance nightmare unless its automated somehow. Or should the current ALL the Clippy lints somehow be incorporated into the book?
1. Related to the above, where should this guide be published since the `gh-pages` branch is already in use?
1. This PR doesn't currently change any existing content. Obviously that would make sense assuming the general structure and relocation is an acceptable approach.

---

Open Tasks for follow up PR:
- Set up CI/CD
- Split up Installation and Usage
- Add more content to Usage (and Installation) chapters
- Enhance CI chapter with more examples for different CIs

---

changelog: The first version of the *Clippy Book*
staring, *The Clippy Team*, *Bors* and *rustc*
2022-06-06 16:53:37 +00:00
bors
ad70bffa9e Auto merge of #8944 - xFrednet:8877-append-doc-idents, r=Manishearth
List configuration values can now be extended instead of replaced

I've seen some `clippy.toml` files, that have a few additions to the default list of a configuration and then a copy of our default. The list will therefore not be updated, when we add new names. This change should make it simple for new users to append values instead of replacing them.

I'm uncertain if the documentation of the `".."` is apparent. Any suggestions are welcome. I've also check that the lint list displays the examples correctly.

<details>
<summary>Lint list screenshots</summary>

![image](https://user-images.githubusercontent.com/17087237/171999434-393f2f83-09aa-4bab-8b05-bd4973150f27.png)

![image](https://user-images.githubusercontent.com/17087237/171999401-e6942b53-25e6-4b09-89e5-d867c7463156.png)

</details>

---

changelog: enhancement: [`doc_markdown`]: Users can now indicate, that the `doc-valid-idents` should extend the default and not replace it
changelog: enhancement: [`blacklisted-name`]: Users can now indicate, that the `blacklisted-names` should extend the default and not replace it

Closes: #8877

That's it. Have a fantastic weekend to everyone reading this. Here is a cookie 🍪
2022-06-06 16:34:27 +00:00
Philipp Krones
b2660de8ec
Book: Improve release documentation
Make it clear for all code blocks in which repository they should be
run. Also make sure that the correct beta commit is fetched.
2022-06-06 16:17:58 +02:00
Philipp Krones
99a731d265
Book: Improve sync documentation
- Move doc about defining remotes to the front and use the defined
  remotes in the further documentation
- Don't recommend pushing to the remote repo directly
- Add some clarifying comments
2022-06-06 16:17:58 +02:00
Philipp Krones
9305659922
Book: Improve chapter on CI
Recommend the -Dwarnings and --all-targets/--all-features more strongly.
2022-06-06 16:17:58 +02:00
Philipp Krones
1f11cd17ac
Remove bit-rotty list of Clippy team members from CONTRIBUTING.md 2022-06-06 16:17:58 +02:00
flip1995
b551928800
Auto update lint count in Clippy book 2022-06-06 16:17:58 +02:00
flip1995
c9cbead656
Book: Add infrastructure description 2022-06-06 16:17:57 +02:00
flip1995
b37d24f7ff
Move parts of CONTRIBUTING.md to the book 2022-06-06 16:17:57 +02:00
flip1995
cbe4de2f6c
Book: Add continuous integration description 2022-06-06 16:17:57 +02:00
flip1995
6b21d386f6
Book: Add Proposals description 2022-06-06 16:17:57 +02:00
flip1995
97bceb0e31
Book: Restructure Dev chapter
Group everything that has something to do with Clippy development under
the "Development" chapter, so that Clippy users can't get confused.
2022-06-06 16:16:11 +02:00
flip1995
0e42282ed5
Book: Write lint group descriptions
This removes the empty separate files for the different groups and adds
a single file giving short explanations for each group and what to
expect from those groups.
2022-06-06 16:16:07 +02:00
flip1995
d12a5c3a52
Book: Split up and rewrite installation and usage 2022-06-06 16:16:01 +02:00
flip1995
404432b791
Book: Update GHA doc and remove GitLab placeholder 2022-06-06 16:15:53 +02:00