Commit graph

12069 commits

Author SHA1 Message Date
bors
6cb30ad581 Auto merge of #7534 - LeSeulArtichaut:7517-closure-too-many-lines, r=flip1995
Don't emit `too_many_lines` for closures

changelog: don't emit the [`too_many_lines`] lint inside closures to avoir duplicated diagnostics.

Fixes #7517.
2021-08-07 13:05:53 +00:00
bors
a0e71e5d63 Auto merge of #7533 - Valentine-Mario:vec_extend_to_append, r=xFrednet
fix bug on mutable ref

fixes: #7524

This PR is related to issue #7524
changelog:  [`extend_with_drain`] Improve code suggestion for mutable and immutable references
2021-08-07 12:54:13 +00:00
valentine-mario
8a4ffb881d fixed bug that had to deal with mut and non mut suggestion 2021-08-05 16:15:44 +01:00
LeSeulArtichaut
4743ec1948 Don't emit too_many_lines for closures 2021-08-05 15:38:57 +02:00
bors
2dbf0c138d Auto merge of #7528 - matthiaskrgr:nedlbrw, r=Manishearth
needless_borrow: try to make lint example a bit more illustrating

changelog: none
2021-08-04 09:17:10 +00:00
bors
85569106a4 Auto merge of #7529 - giraffate:update_node_version, r=flip1995,llogiq
Use node v12.x in CI

In https://github.com/rust-lang/rust-clippy/pull/7528#issuecomment-892281632, remark-cli version has been updated recently and it requires to use ESM module: https://github.com/remarkjs/remark/releases/tag/14.0.0. Node version in CI was v10.24.1, it seems to be old.

changelog: none
2021-08-04 09:02:48 +00:00
Takayuki Nakata
827f661d3e Address warnings for remark check 2021-08-04 16:22:15 +09:00
Takayuki Nakata
f4ea50b4f7 Use node v12.x in CI 2021-08-04 10:27:05 +09:00
Matthias Krüger
54c41c049c needless_borrow: try to make lint example a bit more illustrating 2021-08-04 00:21:25 +02:00
bors
77af56d181 Auto merge of #7525 - xFrednet:7172-update-define-conf-macro, r=flip1995
Updated `define_Conf!` to support multi-line doc comments

Updated the `define_Conf!` macro to support multi-line doc comments for readability. This also enables configuration documentation to have multiple paragraphs.

I've also added the `metadata-collector-lint` feature to the CI build and testing tasks. (I would think that we want this, now that we officially switched over)

---

Now a small informal explanation what this PR changes (just for fun):

* *Once upon a time there was a monster. It was handsome, supportive and happy to dig through the best source code it has ever seen. Spanning over hundreds of lines and reading over complete crates, it was purely marvels!*

    *However, there was one region in its territory that wasn't clean and well formatted like the rest. That was the mighty `define_Conf` macro. The monster would have cleaned it up a long time ago but, the previous ruler of this kingdom a powerful Python script was prohibiting it. But now that the old king was slain in the great battle of rust-1.54.0, everything was possible again. Our lovely monster was now able to grab its cleaning equipment and get some nice formatting into the now unprotected area.*

    *Said and done! Let this day go down in history!*

(I'll be the first to admit, that I'm a bit lost today. And I'm also procrastinating on some other discussions where I have some catching up to do... Oh, well, this was fun)

---

changelog: none

r? `@flip1995`
2021-08-02 20:09:11 +00:00
xFrednet
51f94ad922 Added the metadata-collector-lint feature to the CI 2021-08-02 17:56:15 +02:00
xFrednet
b7d80e7d65 Updated define_Conf! to support multi-line doc comments 2021-08-02 17:56:09 +02:00
bors
4e760b675c Auto merge of #7522 - dswij:map-flatten-result, r=llogiq
Cover `Result` on `map_flatten` lint

Closes #7496

changelog: `[map_flatten]` handles `Result` type
2021-08-02 07:27:09 +00:00
bors
b6c23297bf Auto merge of #7519 - Jarcho:rustfmt_fix, r=giraffate
Workaround rust-lang/rustfmt#4477 - relative paths in `path` attribute

See rust-lang/rustfmt#4477
changelog: None
2021-08-02 00:56:54 +00:00
Dharma Saputra Wijaya
69d439065e Handle Result on map_flatten lint
Adds a check on `.map(..).flatten()` on `Result` type that follows the
behaviour on `Option` type.
2021-08-01 17:47:54 +08:00
bors
05fa78fd3e Auto merge of #7520 - Jarcho:while_let_7510, r=Manishearth
Fix `while_let_on_iterator` - #7510

fixes: #7510
changelog: Suggest re-borrowing mutable references in `while_let_on_iterator`
2021-07-31 15:15:41 +00:00
Jason Newcomb
205aa88921
Fix while_let_on_iterator
When the iterator is one field within a local correctly check for usages of the field
2021-07-31 09:32:54 -04:00
Jason Newcomb
fe75faa6ee
Fix while_let_on_iterator
Reborrow mutable references rather then take a reference to them.
2021-07-31 00:11:46 -04:00
Jason Newcomb
fc387b877a
Workaround rust-lang/rustfmt#4477 - relative paths in path attribute 2021-07-30 23:43:04 -04:00
bors
f6a5889ffa Auto merge of #7509 - xFrednet:patch-1, r=flip1995
Updated config value name in change log for 1.54

Hey, I've noticed that the change log for 1.54 references the avoid_breaking_exported_api configuration with its Rust name, not the name it actually has in the config file. This should fix it for everyone, as the blog post references our change log on the master branch. Just a very small PR xD

changelog: none

(This is the change log xD)

r? `@flip1995`
2021-07-29 14:44:46 +00:00
Fridtjof Stoldt
35a74a1a6b
Updated config value name in changelog for 1.54 2021-07-29 16:26:26 +02:00
bors
2fe716cee9 Auto merge of #7507 - LeSeulArtichaut:patch-1, r=flip1995
Remove `or_patterns` feature gate in example

changelog: removed `or_patterns` feature gate in the code example for the [`unnested_or_patterns`] lint
2021-07-29 12:41:52 +00:00
Léo Lanteri Thauvin
e9004b063f
Remove or_patterns feature gate in example 2021-07-29 14:23:12 +02:00
bors
b3b2024d1e Auto merge of #7498 - xFrednet:changelog-1-55, r=flip1995
Updated changelog for 1.55

This has again been a bit of work, but I'm happy to notice that my English is still improving, and I'm getting faster at these things. That's a very nice side effect of contributing and getting feedback on reviews 😊

Moving on, there were a few things that I was unsure about:
* The PR rust-lang/rust#86717 changes an old entry in the change log, is this worth mentioning? I've left it out for now.
* The stabilization of `cargo clippy --fix` is quite awesome and important IMO. It sadly gets a bit lost in the *Other* entry, as it's the last one. Do we maybe want to move it somewhere else or change the headline order for this release?
* I've listed the introduction of the new `suspicious` group under the *Moves and Deprecations* section. Is this alright, or should it be moved to the *Other* section as well?
* Last but definitely not least, some fun! I've used the 🎉 emoji in the `cargo clippy --fix` entry, is this okay?

Sorry for the bombardment of questions xD

---

The PR already includes the entries for the new metadata collection and website updates. These are not merged yet, but should probably be to make this correct. This might also require the commit hashes to be updated (Not sure on this, though). It would actually be super fitting to get this into this release as we also stabilize `--fix`. TODOs:
* [x] Merge metadata collection PRs:
  1. #7279
  2. #7298
  3. #7420 (Hope to not get any merge conflicts)

---

[Rendered 📰](https://github.com/xFrednet/rust-clippy/blob/changelog-1-55/CHANGELOG.md)

r? `@flip1995`

changelog: none
2021-07-29 12:03:04 +00:00
xFrednet
fdf29c04ae
Updated changelog for 1.55
Co-authored-by: Philipp Krones <hello@philkrones.com>
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2021-07-29 13:58:15 +02:00
bors
0cce3f643b Auto merge of #7504 - flip1995:rename-lints, r=flip1995
Rename two lints to comply with our lint naming convention

self_named_constructor -> self_named_constructors
append_instead_of_extend -> extend_with_drain

We don't need to `register_renamed` those lints, since I'll backport them to beta, so the old names won't hit stable.

changelog: none
(I'll adapt the changelog before merging #7498)
2021-07-29 10:14:31 +00:00
flip1995
54e539121d
Rename two lints to comply with our lint naming convention
self_named_constructor -> self_named_constructors
append_instead_of_extend -> extend_with_drain
2021-07-29 12:10:18 +02:00
bors
766f09f5c1 Auto merge of #7503 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2021-07-29 09:35:13 +00:00
flip1995
80116f9009
Bump Clippy Version -> 0.1.56 2021-07-29 11:15:11 +02:00
flip1995
7ed7b29d73
Bump nightly version -> 2021-07-29 2021-07-29 11:14:53 +02:00
flip1995
490beda6be
Merge remote-tracking branch 'upstream/master' into rustup 2021-07-29 11:14:25 +02:00
bors
92ca25b3ec Auto merge of #7502 - flip1995:rollup-y3ho3w0, r=flip1995
Rollup of 3 pull requests

Successful merges:

 - #7279 (Adapting the lint list to Clippy's new metadata format)
 - #7298 (Switch CI to new metadata collection)
 - #7420 (Update lint documentation to use markdown headlines)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

changelog: rollup
2021-07-28 13:15:43 +00:00
Philipp Krones
464c85c8c1
Rollup merge of #7420 - xFrednet:7172-update-lint-documentation, r=flip1995
Update lint documentation to use markdown headlines

This PR updates all lint documentation to use markdown headlines. It additionally removed the *Known problems* section for lints without any problems. I've double-checked all automatic replacements, but a second pair of eyes is definitely appreciated!

I wasn't sure when you wanted to switch to the new metadata collection tomorrow, I therefore prepared this PR today. And that's it this is a standalone PR to keep the other related PRs reviewable.

changelog:  none

r? `@flip1995`

cc: #7172

Note: This should be merged with the other metadata collection related PRs.
2021-07-28 15:06:27 +02:00
Philipp Krones
bcdf147aaf
Rollup merge of #7298 - flip1995:ci-switch-to-monster, r=xFrednet,flip1995
Switch CI to new metadata collection

r? `@xFrednet`

Things we have to keep in mind:

- This removes the template files and the scripts used for deployment from the checkout. This was added in #5517. I don't think we ever needed those there. Not sure though.
- ~~As a result, we can't remove the python scripts yet. We have to wait until this hits a stable Clippy release.~~ I'll just break the next stable deploy and do it by hand once.
- This should be merged together with #7279. Me and `@xFrednet` will coordinate the switch
- ...?

I still have to try out some things:

- [x] Is it worth caching? Yes
- [x] ~~Is it worth to do a release build?~~ Nope
- [x] Does it actually work? With a few changes, yes
- [ ] ...?

changelog: Clippy now uses a lint to generate its documentation 🎉
2021-07-28 15:06:26 +02:00
Philipp Krones
ce465995d8
Rollup merge of #7279 - xFrednet:7172-adapt-website-to-new-format, r=flip1995
Adapting the lint list to Clippy's new metadata format

This is close to the end of a long living project to rewrite the lint metadata collection for Clippy. Progress on this has been tracked in #7172. This PR adds one of the last missing puzzle pieces, the actual display of all the changes that have been done in the background. A preview can be seen here: [Clippy's lint list](https://xfrednet.github.io/rust-clippy/master/index.html)

The styling has been discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Styling.20feedback.20for.20Clippy's.20lint.20list/near/239601067) but is still open to suggestion.

Side note: It has been fun working on the website where we don't have unit tests and everything is just tested by playing around. However, it's good that this chaos is contained into this one part of Clippy. 🐛

---

Closes: #1303
Closes: #4310

This actually closes fewer things than I thought it would...

changelog: Reworked Clippy's [website](https://rust-lang.github.io/rust-clippy/master/index.html):
changelog: * Added applicability information about lints
changelog: * Added a link to jump to the specific lint implementation
changelog: * Adapted some styling and improved loading time

r? `@flip1995`
2021-07-28 15:06:26 +02:00
flip1995
c951a3c68d
Run cargo collect-metadata in cargo dev serve 2021-07-28 15:05:11 +02:00
xFrednet
322a768c77
Adapting the lint list to Clippy's new metadata format
Changes included:
    - Minimum adaption to the new `lints.json` format
    - Fixing filtering for the new `lints.json` format; hardcoding the
      lint groups in the index
    - Recreating the original doc styling for the new format
    - Fixed sytax highlighting for rust,ignore code blocks
    - Fixed markdown table extraction in the metadata collector and
      fixed lint level output
    - Adding the additional information row for lints
    - Changed the website title to Clippy's lint list
    - Flexing the website for mobile users
    - Added (?) references for lint levels and groups
    - Making deprecated lints look dead
    - Removed JS code block language extraction in favor of a rust
      implementation `rust-clippy#7352`
    - Added the suspicious lint group to the lint list
    - Remove trailing whitespaces from index.html
    - Fix code highlighting
    - Use default value if the docVersion is empty

Co-authored-by: Philipp Krones <hello@philkrones.com>
2021-07-28 15:03:55 +02:00
flip1995
9bc5803195
Fix last occurence of **What it does:** 2021-07-28 14:32:02 +02:00
xFrednet
12c61612f7
Update lint documentation to use markdown headlines 2021-07-28 14:31:59 +02:00
flip1995
fe25282aaa
Remove old python lint doc generation scripts 2021-07-28 14:18:40 +02:00
flip1995
6c5d199d57
Update deploy CI
This updates all the deploy scripts and the deploy workflow.

The deploy workflow now runs the metadata collector to collect the lint
documentation. It also changes the files that are checked out in the
deploy workflow from master and adds an explanation why we have to do
this.
2021-07-28 14:16:31 +02:00
Jacob Pratt
5331fea875 Update tests 2021-07-27 16:26:50 -04:00
bors
ea988afcda Auto merge of #83484 - JulianKnodt:infer, r=oli-obk,lcnr
Add hir::GenericArg::Infer

In order to extend inference to consts, make an Infer type on hir::GenericArg.
2021-07-27 16:24:45 +00:00
bors
ac0fd99194 Auto merge of #7492 - nfejzic:improve_help, r=Manishearth
Explain flags missing in cargo check in --help

This commit closes #7389. As stated in the issue, `cargo clippy --help`
provides explanation for some flags and states that the rest are same
as in `cargo check --help`, even though some clippy specific flags
exist.

This commit extends the `cargo clippy --help` with two additional flags,
  - `cargo clippy --fix`
  - `cargo clippy --no-deps`

If there are more flags which are not present in `cargo check --help`
please bring these to my attention, I will include these aswell.
For now, I noticed only the two flags mentioned above.

changelog: `cargo clippy --help` now explains additional flags missing in `cargo check --help`.
2021-07-27 14:39:08 +00:00
bors
43905d9f8d Auto merge of #7488 - DevinR528:bantype-fix, r=camsteffen
Add primitive type support to disallowed_type lint

Closes #6845

changelog: Enable the banning of primitive types in [`disallowed_type`]
2021-07-27 14:27:11 +00:00
Devin Ragotzy
a1bab3bc63 Add primitive type support to disallowed_type lint
Fix docs of disallowed_type

Add ability to name primitive types without import path

Move primitive resolution to clippy_utils path_to_res fn

Refactor Res matching, fix naming and docs from review

Use tcx.def_path_str when emitting the lint
2021-07-27 10:01:38 -04:00
Nadir Fejzic
f7af8bf2c1 Handle --no-deps flag same as --fix flag.
As proposed in the pull request thread, there is some inconsistency in
handling the `--no-deps` flag which requires `--` before it, and
`--fix` flag which does not.
In this commit the `--no-deps` flag does not need the `--` anymore.
However, it can still be used that way: `cargo clipyy -- --no-deps`.
2021-07-27 11:13:42 +02:00
bors
ceb7a868d3 Auto merge of #7466 - xFrednet:5393-use-more-diagnostic-items, r=flip1995
Use diagnostic items where possible

Clippy still uses a bunch of paths in places that could easily use already defined diagnostic items. This PR updates all references to such paths and also removes a bunch of them that are no longer needed after this cleanup.

Some paths are also used to construct new paths and can therefore not be removed that easily. I've added a doc comment to those instances that recommends the use of the diagnostic item where possible.

And that's it, cleaning crew signing off 🧹 🗑️

---

changelog: none

(only internal improvements)

cc: #5393
2021-07-27 08:19:23 +00:00
kadmin
74379d4d85 Actually infer args in visitors 2021-07-26 21:15:18 +00:00
bors
fd2b43dfb7 Auto merge of #7495 - camsteffen:extern-conflict, r=Manishearth
Improve conflicting rlibs error again

changelog: none

Now you can do `rm <paste>` and 🐇💨

```text
thread 'compile_test' panicked at '
----------------------------------------------------------------------
ERROR: Found multiple rlibs for crates: `clippy_lints`, `clippy_utils`
Try running `cargo clean` or remove the following files:

target/debug/deps/libclippy_lints-9117c875159004e0.rlib \
target/debug/deps/libclippy_lints-fe45157be7ff9444.rlib \
target/debug/deps/libclippy_utils-5eba1e07a9846ed0.rlib \
target/debug/deps/libclippy_utils-ccbc08fcf64de262.rlib

For details on this error see https://github.com/rust-lang/rust-clippy/issues/7343
----------------------------------------------------------------------
```
2021-07-26 16:56:05 +00:00