]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #7509 - xFrednet:patch-1, r=flip1995
bors [Thu, 29 Jul 2021 14:44:46 +0000 (14:44 +0000)]
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`

2 years agoUpdated config value name in changelog for 1.54
Fridtjof Stoldt [Thu, 29 Jul 2021 14:26:26 +0000 (16:26 +0200)]
Updated config value name in changelog for 1.54

2 years agoAuto merge of #7507 - LeSeulArtichaut:patch-1, r=flip1995
bors [Thu, 29 Jul 2021 12:41:52 +0000 (12:41 +0000)]
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

2 years agoRemove `or_patterns` feature gate in example
Léo Lanteri Thauvin [Thu, 29 Jul 2021 12:23:12 +0000 (14:23 +0200)]
Remove `or_patterns` feature gate in example

2 years agoAuto merge of #7498 - xFrednet:changelog-1-55, r=flip1995
bors [Thu, 29 Jul 2021 12:03:04 +0000 (12:03 +0000)]
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 :blush:

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 :tada: 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 :newspaper:](https://github.com/xFrednet/rust-clippy/blob/changelog-1-55/CHANGELOG.md)

r? `@flip1995`

changelog: none

2 years agoUpdated changelog for 1.55
xFrednet [Tue, 27 Jul 2021 22:44:24 +0000 (00:44 +0200)]
Updated changelog for 1.55

Co-authored-by: Philipp Krones <hello@philkrones.com>
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2 years agoAuto merge of #7504 - flip1995:rename-lints, r=flip1995
bors [Thu, 29 Jul 2021 10:14:31 +0000 (10:14 +0000)]
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)

2 years agoRename two lints to comply with our lint naming convention
flip1995 [Thu, 29 Jul 2021 10:10:18 +0000 (12:10 +0200)]
Rename two lints to comply with our lint naming convention

self_named_constructor -> self_named_constructors
append_instead_of_extend -> extend_with_drain

2 years agoAuto merge of #7503 - flip1995:rustup, r=flip1995
bors [Thu, 29 Jul 2021 09:35:13 +0000 (09:35 +0000)]
Auto merge of #7503 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump Clippy Version -> 0.1.56
flip1995 [Thu, 29 Jul 2021 09:15:11 +0000 (11:15 +0200)]
Bump Clippy Version -> 0.1.56

2 years agoBump nightly version -> 2021-07-29
flip1995 [Thu, 29 Jul 2021 09:14:53 +0000 (11:14 +0200)]
Bump nightly version -> 2021-07-29

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 29 Jul 2021 09:14:25 +0000 (11:14 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #7502 - flip1995:rollup-y3ho3w0, r=flip1995
bors [Wed, 28 Jul 2021 13:15:43 +0000 (13:15 +0000)]
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

2 years agoRollup merge of #7420 - xFrednet:7172-update-lint-documentation, r=flip1995
Philipp Krones [Wed, 28 Jul 2021 13:06:27 +0000 (15:06 +0200)]
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.

2 years agoRollup merge of #7298 - flip1995:ci-switch-to-monster, r=xFrednet,flip1995
Philipp Krones [Wed, 28 Jul 2021 13:06:26 +0000 (15:06 +0200)]
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 :tada:

2 years agoRollup merge of #7279 - xFrednet:7172-adapt-website-to-new-format, r=flip1995
Philipp Krones [Wed, 28 Jul 2021 13:06:26 +0000 (15:06 +0200)]
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. :bug:

---

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`

2 years agoRun cargo collect-metadata in cargo dev serve
flip1995 [Wed, 28 Jul 2021 13:05:11 +0000 (15:05 +0200)]
Run cargo collect-metadata in cargo dev serve

2 years agoAdapting the lint list to Clippy's new metadata format
xFrednet [Tue, 18 May 2021 22:08:31 +0000 (00:08 +0200)]
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>
2 years agoFix last occurence of **What it does:**
flip1995 [Wed, 28 Jul 2021 11:51:16 +0000 (13:51 +0200)]
Fix last occurence of **What it does:**

2 years agoUpdate lint documentation to use markdown headlines
xFrednet [Fri, 2 Jul 2021 18:37:11 +0000 (20:37 +0200)]
Update lint documentation to use markdown headlines

2 years agoRemove old python lint doc generation scripts
flip1995 [Wed, 28 Jul 2021 12:15:34 +0000 (14:15 +0200)]
Remove old python lint doc generation scripts

2 years agoUpdate deploy CI
flip1995 [Mon, 31 May 2021 15:46:20 +0000 (17:46 +0200)]
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.

2 years agoUpdate tests
Jacob Pratt [Thu, 3 Jun 2021 07:31:27 +0000 (03:31 -0400)]
Update tests

2 years agoAuto merge of #83484 - JulianKnodt:infer, r=oli-obk,lcnr
bors [Tue, 27 Jul 2021 16:24:45 +0000 (16:24 +0000)]
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.

2 years agoAuto merge of #7492 - nfejzic:improve_help, r=Manishearth
bors [Tue, 27 Jul 2021 14:39:08 +0000 (14:39 +0000)]
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`.

2 years agoAuto merge of #7488 - DevinR528:bantype-fix, r=camsteffen
bors [Tue, 27 Jul 2021 14:27:11 +0000 (14:27 +0000)]
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`]

2 years agoAdd primitive type support to disallowed_type lint
Devin Ragotzy [Thu, 22 Jul 2021 12:40:24 +0000 (08:40 -0400)]
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

2 years agoHandle `--no-deps` flag same as `--fix` flag.
Nadir Fejzic [Tue, 27 Jul 2021 09:13:42 +0000 (11:13 +0200)]
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`.

2 years agoAuto merge of #7466 - xFrednet:5393-use-more-diagnostic-items, r=flip1995
bors [Tue, 27 Jul 2021 08:19:23 +0000 (08:19 +0000)]
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 :broom: :wastebasket:

---

changelog: none

(only internal improvements)

cc: #5393

2 years agoActually infer args in visitors
kadmin [Thu, 6 May 2021 15:33:44 +0000 (15:33 +0000)]
Actually infer args in visitors

2 years agoAuto merge of #7495 - camsteffen:extern-conflict, r=Manishearth
bors [Mon, 26 Jul 2021 16:56:05 +0000 (16:56 +0000)]
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
----------------------------------------------------------------------
```

2 years agoImprove conflicting rlibs error again
Cameron Steffen [Mon, 26 Jul 2021 15:32:26 +0000 (10:32 -0500)]
Improve conflicting rlibs error again

2 years agoInclude more information in --help
Nadir Fejzic [Mon, 26 Jul 2021 14:14:29 +0000 (16:14 +0200)]
Include more information in --help

`--no-deps` filled in with a little more information. Explain that
`--fix` implies `--no-deps`.
Explain that `--no-deps` is used with `cargo clippy --`, including
one example.

2 years agoAuto merge of #7493 - xFrednet:7220-fix-new-without-default-impl-type, r=camsteffen
bors [Mon, 26 Jul 2021 12:20:54 +0000 (12:20 +0000)]
Auto merge of #7493 - xFrednet:7220-fix-new-without-default-impl-type, r=camsteffen

Prefer a code snipped over formatting the self type (`new_without_default`)

Fixes: rust-lang/rust-clippy#7220
changelog: [`new_without_default`]: The `Default` impl block type doesn't use the full type path qualification

Have a nice day to everyone reading this :upside_down_face:

2 years agoAuto merge of #7485 - camsteffen:add-test-externs, r=flip1995
bors [Mon, 26 Jul 2021 12:06:07 +0000 (12:06 +0000)]
Auto merge of #7485 - camsteffen:add-test-externs, r=flip1995

Add to test third party crates list

changelog: none

2 years agoAuto merge of #7477 - F3real:needless_continue, r=flip1995
bors [Mon, 26 Jul 2021 11:52:55 +0000 (11:52 +0000)]
Auto merge of #7477 - F3real:needless_continue, r=flip1995

Enhance needless continue to detect loop {continue;}

Fixes #7417

changelog: Report [`needless_continue`] in `loop { continue; }` case

2 years agoAuto merge of #7484 - camsteffen:author, r=flip1995
bors [Mon, 26 Jul 2021 11:41:46 +0000 (11:41 +0000)]
Auto merge of #7484 - camsteffen:author, r=flip1995

Some `clippy::author` improvements

changelog: none

* Use `Debug` instead of re-implementing it for some things
* Fix block trailing expression handing
* Don't double print on stmt/expr with `#[clippy::author]` attribute

2 years agoPrefer a code snipped over formatting the self type (`new_without_default`)
xFrednet [Sun, 25 Jul 2021 18:35:51 +0000 (20:35 +0200)]
Prefer a code snipped over formatting the self type (`new_without_default`)

2 years agoauthor: check block.expr: None
Cameron Steffen [Sun, 25 Jul 2021 21:35:35 +0000 (16:35 -0500)]
author: check block.expr: None

2 years agoExplain flags missing in cargo check in --help
Nadir Fejzic [Sun, 25 Jul 2021 12:41:35 +0000 (14:41 +0200)]
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.

2 years agoAuto merge of #83723 - cjgillot:ownernode, r=petrochenkov
bors [Sun, 25 Jul 2021 11:11:02 +0000 (11:11 +0000)]
Auto merge of #83723 - cjgillot:ownernode, r=petrochenkov

Store all HIR owners in the same container

This replaces the previous storage in a BTreeMap for each of Item/ImplItem/TraitItem/ForeignItem.
This should allow for a more compact storage.

Based on https://github.com/rust-lang/rust/pull/83114

2 years agoIntroduce OwnerNode::Crate.
Camille GILLOT [Sun, 25 Jul 2021 10:03:24 +0000 (12:03 +0200)]
Introduce OwnerNode::Crate.

2 years agoAdd inferred args to typeck
kadmin [Mon, 26 Apr 2021 18:19:23 +0000 (18:19 +0000)]
Add inferred args to typeck

2 years agoAdd generic arg infer
kadmin [Sat, 24 Apr 2021 21:41:57 +0000 (21:41 +0000)]
Add generic arg infer

2 years agoAuto merge of #7482 - xFrednet:7306-document-repeat-once-fp, r=giraffate
bors [Sat, 24 Jul 2021 14:15:32 +0000 (14:15 +0000)]
Auto merge of #7482 - xFrednet:7306-document-repeat-once-fp, r=giraffate

Documented constant expression evaluation for `repeat_once`

Documents the fact that the `repeat_once` lint evaluates constant expressions

---

closes: #7306

changelog: none
(I don't think it's worth a change log entry, as nothing has really changed)

r? `@giraffate` as you've implemented the lint and were part of the discussion in the issue :upside_down_face:

2 years agoclippy::author improvements
Cameron Steffen [Fri, 23 Jul 2021 21:02:09 +0000 (16:02 -0500)]
clippy::author improvements

2 years agoAdd clippy_utils and if_chain to extern crate list
Cameron Steffen [Fri, 23 Jul 2021 22:00:00 +0000 (17:00 -0500)]
Add clippy_utils and if_chain to extern crate list

2 years agoupdate clippy ui test 'future_not_send.stderr' to match
chaz-kiker [Fri, 23 Jul 2021 17:30:52 +0000 (12:30 -0500)]
update clippy ui test 'future_not_send.stderr' to match
the new diagnostic messages

2 years agoClean up unnecessary unwraps
F3real [Fri, 23 Jul 2021 15:30:27 +0000 (17:30 +0200)]
Clean up unnecessary unwraps

2 years agoDocumented constant expression evaluation for `repeat_once`
xFrednet [Fri, 23 Jul 2021 15:02:45 +0000 (17:02 +0200)]
Documented constant expression evaluation for `repeat_once`

2 years agoLint on continue expression without semi-colon
F3real [Thu, 22 Jul 2021 20:21:34 +0000 (22:21 +0200)]
Lint on continue expression without semi-colon

2 years agoEmit needless_continue warning if loop ends on continue
F3real [Wed, 21 Jul 2021 21:15:29 +0000 (23:15 +0200)]
Emit needless_continue warning if loop ends on continue

2 years agoEnhance needless continue to detect loop {continue;}
F3real [Tue, 20 Jul 2021 15:29:03 +0000 (17:29 +0200)]
Enhance needless continue to detect loop {continue;}

2 years agoAuto merge of #7221 - th1000s:keyword_, r=giraffate
bors [Mon, 19 Jul 2021 14:18:59 +0000 (14:18 +0000)]
Auto merge of #7221 - th1000s:keyword_, r=giraffate

similar_names: No longer suggest inserting or appending an underscore

changelog: [`similar_names`] lint no longer suggests to insert or add an underscore to "fix" too similar names

2 years agoMerge commit '4c41a222ca5d1325fb4b6709395bd06e766cc042' into clippyup
flip1995 [Mon, 19 Jul 2021 09:52:05 +0000 (11:52 +0200)]
Merge commit '4c41a222ca5d1325fb4b6709395bd06e766cc042' into clippyup

2 years agoAuto merge of #7476 - flip1995:rustup, r=flip1995
bors [Mon, 19 Jul 2021 09:49:57 +0000 (09:49 +0000)]
Auto merge of #7476 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

Out of cycle sync for 2 ICE fixes #7470 #7471 #7473

changelog: none

2 years agoBump nightly version -> 2021-07-19
flip1995 [Mon, 19 Jul 2021 09:49:03 +0000 (11:49 +0200)]
Bump nightly version -> 2021-07-19

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Mon, 19 Jul 2021 09:38:40 +0000 (11:38 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #7470 - DevinR528:fix-ice7447, r=flip1995
bors [Mon, 19 Jul 2021 09:22:34 +0000 (09:22 +0000)]
Auto merge of #7470 - DevinR528:fix-ice7447, r=flip1995

Add check if ty has_escaping_bound_vars in zero_sized_map_values lint

Fixes: #7447
changelog: fix ICE in [`zero_sized_map_values`]

2 years agoAuto merge of #7403 - Anthuang:redundant-method-names, r=Manishearth
bors [Mon, 19 Jul 2021 06:49:51 +0000 (06:49 +0000)]
Auto merge of #7403 - Anthuang:redundant-method-names, r=Manishearth

New lint: [`self_named_constructor`]

Adds the `self_named_constructor` lint for detecting when an implemented method has the same name as the type it is implemented for.

changelog: [`self_named_constructor`]

closes: #7142

2 years agoRun bless
Anthony Huang [Mon, 19 Jul 2021 05:21:06 +0000 (01:21 -0400)]
Run bless

2 years agoAuto merge of #7474 - camsteffen:binop, r=Manishearth
bors [Sun, 18 Jul 2021 15:52:49 +0000 (15:52 +0000)]
Auto merge of #7474 - camsteffen:binop, r=Manishearth

Use lang items for BinOp lints

changelog: none

2 years agofix(clippy): add missing allow(dyn_drop)
Michael Howell [Sun, 18 Jul 2021 14:57:03 +0000 (07:57 -0700)]
fix(clippy): add missing allow(dyn_drop)

2 years agoAuto merge of #7473 - Jarcho:ice_7340, r=Manishearth
bors [Sun, 18 Jul 2021 03:32:31 +0000 (03:32 +0000)]
Auto merge of #7473 - Jarcho:ice_7340, r=Manishearth

Fix ICE in `is_integer_const`

fixes: #7340
changelog: Fix ICE in `modulo_one` in const contexts

2 years agoFactor BinOp utils
Cameron Steffen [Fri, 16 Jul 2021 19:41:19 +0000 (14:41 -0500)]
Factor BinOp utils

2 years agoUse From to convert BinOpKind
Cameron Steffen [Mon, 28 Jun 2021 19:05:48 +0000 (14:05 -0500)]
Use From to convert BinOpKind

2 years agoFix ICE in `is_integer_const` when the expression is inside an `AnonConst` body
Jason Newcomb [Sat, 17 Jul 2021 23:01:19 +0000 (19:01 -0400)]
Fix ICE in `is_integer_const` when the expression is inside an `AnonConst` body

2 years agoAuto merge of #7471 - flip1995:ice-7410, r=giraffate
bors [Fri, 16 Jul 2021 14:26:08 +0000 (14:26 +0000)]
Auto merge of #7471 - flip1995:ice-7410, r=giraffate

Fix ICE in redundant_pattern_matching

Fixes #7410

changelog: Fix ICE in `redundant_pattern_matching` in `no_std` crates.

2 years agoAuto merge of #87140 - camsteffen:pat-slice-refs, r=oli-obk
bors [Fri, 16 Jul 2021 13:35:48 +0000 (13:35 +0000)]
Auto merge of #87140 - camsteffen:pat-slice-refs, r=oli-obk

Remove refs from Pat slices

Changes `PatKind::Or(&'hir [&'hir Pat<'hir>])` to `PatKind::Or(&'hir [Pat<'hir>])` and others. This is more consistent with `ExprKind`, saves a little memory, and is a little easier to use.

2 years agoFix ICE in redundant_pattern_matching
flip1995 [Fri, 16 Jul 2021 08:45:28 +0000 (10:45 +0200)]
Fix ICE in redundant_pattern_matching

2 years agoRollup merge of #87069 - sexxi-goose:copy_ref_always, r=nikomatsakis
Guillaume Gomez [Fri, 16 Jul 2021 08:08:05 +0000 (10:08 +0200)]
Rollup merge of #87069 - sexxi-goose:copy_ref_always, r=nikomatsakis

ExprUseVisitor: Treat ByValue use of Copy types as ImmBorrow

r? ```@nikomatsakis```

2 years agoAdd check if ty has_escaping_bound_vars in zero_sized_map_values lint
Devin Ragotzy [Thu, 15 Jul 2021 22:35:43 +0000 (18:35 -0400)]
Add check if ty has_escaping_bound_vars in zero_sized_map_values lint

2 years agoAuto merge of #7460 - camsteffen:run-from-source, r=Manishearth
bors [Thu, 15 Jul 2021 21:53:17 +0000 (21:53 +0000)]
Auto merge of #7460 - camsteffen:run-from-source, r=Manishearth

Add instructions to run from source

changelog: none

We often get messages on Zulip asking how to install and run Clippy from source. This adds instructions to the readme. I also added a note explaining that `cargo install --path . --force` is bad, which I just decided after some investigating. I use macOS. It would be nice to get some tests on other platforms to see if this is correct.

2 years agoRemove refs from pat slices
Cameron Steffen [Wed, 14 Jul 2021 21:17:04 +0000 (16:17 -0500)]
Remove refs from pat slices

2 years agoAdd instructions to run from source
Cameron Steffen [Tue, 13 Jul 2021 15:09:24 +0000 (10:09 -0500)]
Add instructions to run from source

2 years agoMerge commit '54a20a02ecd0e1352a871aa0990bcc8b8b03173e' into clippyup
flip1995 [Thu, 15 Jul 2021 08:44:10 +0000 (10:44 +0200)]
Merge commit '54a20a02ecd0e1352a871aa0990bcc8b8b03173e' into clippyup

2 years agoAuto merge of #7468 - flip1995:rustup, r=flip1995
bors [Thu, 15 Jul 2021 08:37:36 +0000 (08:37 +0000)]
Auto merge of #7468 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2021-07-15
flip1995 [Thu, 15 Jul 2021 08:32:21 +0000 (10:32 +0200)]
Bump nightly version -> 2021-07-15

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 15 Jul 2021 08:21:01 +0000 (10:21 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #7308 - lengyijun:redundant_allocation_arc, r=xFrednet,flip1995
bors [Thu, 15 Jul 2021 07:20:37 +0000 (07:20 +0000)]
Auto merge of #7308 - lengyijun:redundant_allocation_arc, r=xFrednet,flip1995

add Arc to `redundant_allocation`

 fixes #7303
changelog:  add Arc to `redundant_allocation`

2 years agoredundant_allocation: add Arc; some refractoring.
lyj [Wed, 2 Jun 2021 05:41:52 +0000 (13:41 +0800)]
redundant_allocation: add Arc; some refractoring.

2 years agoUse diagnostic items for `Vec`, `VecDeque` and connected refactorings
xFrednet [Wed, 14 Jul 2021 21:34:34 +0000 (23:34 +0200)]
Use diagnostic items for `Vec`, `VecDeque` and connected refactorings

2 years agoUse diagnostic items for `intrinsics::transmute`, `TryInto`
xFrednet [Wed, 14 Jul 2021 21:09:24 +0000 (23:09 +0200)]
Use diagnostic items for `intrinsics::transmute`, `TryInto`

2 years agoUse diagnostic items for `Into`, `IntoIterator`, `LinkedList`, `ptr::null`, `prt...
xFrednet [Wed, 14 Jul 2021 20:10:15 +0000 (22:10 +0200)]
Use diagnostic items for `Into`, `IntoIterator`, `LinkedList`, `ptr::null`, `prt::null_mut`

2 years agoAuto merge of #7462 - xFrednet:7369-branches-sharing-code-else-expr-fp, r=camsteffen
bors [Wed, 14 Jul 2021 20:29:56 +0000 (20:29 +0000)]
Auto merge of #7462 - xFrednet:7369-branches-sharing-code-else-expr-fp, r=camsteffen

FP fix and documentation for `branches_sharing_code` lint

Closes rust-lang/rust-clippy#7369

Related rust-lang/rust-clippy#7452 I'm still thinking about the best way to fix this. I could simply add another visitor to ensure that the moved expressions don't modify values being used in the condition, but I'm not totally happy with this due to the complexity. I therefore only documented it for now

changelog: [`branches_sharing_code`] fixed false positive where block expressions would sometimes be ignored.

2 years agoUse diagnostic items for `BinaryHeap`, `BTreeMap`, `BTreeSet`, `HashMap`, `HashSet...
xFrednet [Wed, 14 Jul 2021 10:58:43 +0000 (12:58 +0200)]
Use diagnostic items for `BinaryHeap`, `BTreeMap`, `BTreeSet`, `HashMap`, `HashSet`, `Borrow`, `Default`

2 years agoFixed `branches_sharing_code` FP with block expressions in else
xFrednet [Tue, 13 Jul 2021 21:27:19 +0000 (23:27 +0200)]
Fixed `branches_sharing_code` FP with block expressions in else

And added `branches_sharing_code` PF note to lint doc for `rust-clippy#7452`

2 years agoAuto merge of #7437 - ebobrow:redundant-closure-move, r=flip1995
bors [Wed, 14 Jul 2021 15:15:28 +0000 (15:15 +0000)]
Auto merge of #7437 - ebobrow:redundant-closure-move, r=flip1995

suggest `&mut` for redundant FnMut closures

fixes #6903

changelog: suggest `&mut` for redundant FnMut closures

2 years agosuggest `&mut` for redundant FnMut closures
Elliot Bobrow [Sat, 3 Jul 2021 03:25:55 +0000 (20:25 -0700)]
suggest `&mut` for redundant FnMut closures

2 years agoAuto merge of #7346 - lengyijun:redundant_clone_5707, r=oli-obk
bors [Wed, 14 Jul 2021 10:10:14 +0000 (10:10 +0000)]
Auto merge of #7346 - lengyijun:redundant_clone_5707, r=oli-obk

fix 5707

changelog: ``[`redundant_clone`]``, fix #5707

# Root problem of #5707 :
```
&2:&mut HashMap = &mut _4;
&3:&str = & _5;
_1 = HashMap::insert(move _2,move _3, _);
```

generate PossibleBorrower(_2,_1) and PossibleBorrower(_3,_1).

However, it misses PossibleBorrower(_3,_2).

# My solution to #5707 :

When meet a function call, we should:
1. build PossibleBorrower between borrow parameters and return value (currently)
2. build PossibleBorrower between immutable borrow parameters and mutable borrow parameters (*add*)
3. build PossibleBorrower inside mutable borrow parameters (*add*)

For example:
```
_2: &mut _22;
_3: &mut _;
_4: & _;
_5: & _;
_1 = call(move _2, move _3, move _4, move _5);
```
we need to build
1. return value with parameter(current implementataion)
 PossibleBorrower(_2,_1)
 PossibleBorrower(_3,_1)
 PossibleBorrower(_4,_1)
 PossibleBorrower(_5,_1)

2. between mutable borrow and immutable borrow
PossibleBorrower(_4,_2)
PossibleBorrower(_5,_2)
PossibleBorrower(_4,_3)
PossibleBorrower(_5,_3)

3. between mutable borrow and mutable borrow
PossibleBorrower(_3,_2)
PossibleBorrower(_2,_3)

  But that's not enough.
 Modification to _2 actually apply to _22.
  So I write a `PossibleBorrowed` visitor, which tracks (borrower => possible borrowed) relation.
  For example (_2 => _22).
  However, a lot of problems exist here.

## Known Problems:
  1. not sure all `&mut`'s origin are collected.
  I'm not sure how to deal with `&mut` when meet a function call, so I didn't do it currently.
  Also, my implement is not flow sensitive, so it's not accurate.

```
foo(_2:&mut _, _3: &_)
```
This pr doesn't count _3 as origin of _2.

 2. introduce false negative
`foo(_2, _3)` will  emit PossibleBorrower(_3,_2) in this pr, but _3 and _2 may not have relation.
Clippy may feel that _3 is still in use because of _2, but actually, _3 is on longer needed and can be moved.

## Insight
  The key problem is determine where every `&mut` come from accurately.
  I think Polonius is an elegant solution to it. Polonius is flow sensitive and accurate.
  But I'm uncertain about whether we can import Polonius in rust-clippy currently.
  This pr actually is part of Polonius' functionality, I think.

# TODO
1. `cargo test` can't pass yet due to similar variable name

2 years agoExprUseVisitor::Delegate consume only when moving
Aman Arora [Wed, 14 Jul 2021 06:21:08 +0000 (02:21 -0400)]
ExprUseVisitor::Delegate consume only when moving

2 years agorename possible_borrowed to possible_origin; pass dogfood
lyj [Wed, 14 Jul 2021 03:29:39 +0000 (11:29 +0800)]
rename possible_borrowed to possible_origin; pass dogfood

2 years agofix 5707
lyj [Fri, 11 Jun 2021 12:57:11 +0000 (20:57 +0800)]
fix 5707

2 years agoNo longer suggest inserting or appending an underscore
Thomas Otto [Thu, 13 May 2021 20:53:31 +0000 (22:53 +0200)]
No longer suggest inserting or appending an underscore

changelog: [`similar_names`] lint no longer suggests to insert or add an underscore
to "fix" too similar names

2 years agoAuto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk
bors [Tue, 13 Jul 2021 15:06:10 +0000 (15:06 +0000)]
Auto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk

Fix internal `default_hash_types` lint to use resolved path

I run into false positives now and then (mostly in Clippy) when I want to name some util after HashMap.

2 years agoAuto merge of #7446 - Y-Nak:fix-7445, r=xFrednet,flip1995
bors [Tue, 13 Jul 2021 14:31:02 +0000 (14:31 +0000)]
Auto merge of #7446 - Y-Nak:fix-7445, r=xFrednet,flip1995

`default_numeric_fallback`: Fix FP with floating literal

Fix #7445

changelog: `default_numeric_fallback`: Fix FP with floating literal

2 years ago`default_numeric_fallback`: Add rustfix tests
Yoshitomo Nakanishi [Tue, 13 Jul 2021 13:57:47 +0000 (22:57 +0900)]
`default_numeric_fallback`: Add rustfix tests

2 years agoAuto merge of #7442 - camsteffen:format-args, r=xFrednet
bors [Tue, 13 Jul 2021 13:58:38 +0000 (13:58 +0000)]
Auto merge of #7442 - camsteffen:format-args, r=xFrednet

Refactor `format_args!` expansion parsing

Introduces `FormatExpn::parse` and `FormatArgsExpn::parse`. Motivated by rust-lang/rust#83302, so I only have to change Clippy in one place. Fixed an FP along the way.

I also allowed `needless_bool` in macros because I often want to do `if_chain! { .. then { true } else { false } }`.

changelog: Fix false positive in `useless_format` when some text is appended or prepended to a single string with some useless formatting params
changelog: Allow `needless_bool` in macros

2 years agoSplit a lint message into help
Cameron Steffen [Mon, 12 Jul 2021 01:30:19 +0000 (20:30 -0500)]
Split a lint message into help

2 years agoReduce redundant code
Cameron Steffen [Mon, 12 Jul 2021 01:21:21 +0000 (20:21 -0500)]
Reduce redundant code