Commit Graph

13131 Commits

Author SHA1 Message Date
bors
6f33f690ea Auto merge of #8112 - Alexendoo:disallowed_methods_primitives, r=flip1995
Allow primitive types in disallowed_methods

Fixes #8079

changelog: `disallowed_methods`: Now can disallow methods of primitive types
2022-01-12 16:47:45 +00:00
Alex Macleod
04eb27aeaf Use method name from conf::DisallowedMethod
Since def_path_str returns e.g. "core::f32::<impl f32>::clamp" for
"f32::clamp"
2022-01-12 16:23:22 +00:00
bors
7c82ae1c12 Auto merge of #8213 - paolobarbolini:size-of-as-bits, r=flip1995
Add `manual_bits` lint

Closes #6670

---

changelog: new lint: [`manual_bits`]
2022-01-12 16:21:14 +00:00
Alex Macleod
91581f6d5e Resolve primitive impls in clippy_utils::path_to_res 2022-01-12 16:20:23 +00:00
Paolo Barbolini
166737f3cb Add manual_bits lint 2022-01-12 16:46:57 +01:00
bors
b9cae79d7f Auto merge of #8037 - ojeda:doc-codegen-change, r=camsteffen
`README`: document that Clippy may change codegen

Currently, Clippy does not guarantee the same codegen will be produced.
Therefore, it should not be used as an universal replacement for `rustc`.

See https://github.com/rust-lang/rust-clippy/issues/8035.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

fixes #8035
changelog: document that Clippy may change codegen
2022-01-12 15:11:08 +00:00
bors
ae01c4ab3c Auto merge of #8190 - camsteffen:no-in-band-liftetimes, r=flip1995
Stop using `in_band_lifetimes`

Per rust-lang/rust#91867

changelog: none
2022-01-12 14:25:11 +00:00
bors
0d94167a23 Auto merge of #8198 - camsteffen:no-method-call-macro, r=flip1995
Remove method_call! macro

This is possible now that `SymbolStr` is removed from rustc.

changelog: none
2022-01-12 13:59:12 +00:00
bors
37e9985e86 Auto merge of #8268 - Jarcho:deref_addrof_8247, r=flip1995
Fix `deref_addrof`

fixes #8247

This would supersede #8259

changelog: Don't lint `deref_addrof` when the dereference and the borrow occur in different contexts
2022-01-12 13:25:58 +00:00
Jason Newcomb
d32277d78e Don't lint deref_addrof when the two operations occur in different expansions 2022-01-12 00:25:42 -05:00
bors
88f5be2041 Auto merge of #8262 - 1nF0rmed:chore-update-borrowed-box-doc, r=camsteffen
Improve documentation for `borrowed-box` lint

fixes #8161

Updates documentation to elaborate more on how removing Box from a function parameter can generalize the function.

changelog: none
2022-01-11 17:07:50 +00:00
Pradyumna Rahul
7e989ec07a Improve documentation for borrowed-box lint 2022-01-11 22:02:15 +05:30
Cameron Steffen
02ec39b2ff Stop using in_band_lifetimes 2022-01-11 09:52:23 -06:00
bors
fd9cebe6eb Auto merge of #8210 - guerinoni:master, r=Manishearth
Add borrow_as_ptr lint

Closes: #6995

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

---

changelog: new lint: [`borrow_as_ptr`]
2022-01-11 15:45:50 +00:00
Miguel Ojeda
3d4fdedd7e README: mention clippy-driver on usage list
Removes the "compiled from source" bit, which is confusing.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-01-11 14:48:25 +01:00
Miguel Ojeda
fd97d792f9 README: clippy-driver is not a replacement for rustc
Currently, `clippy-driver` may run codegen, but this is an
implementation detail.

See https://github.com/rust-lang/rust-clippy/issues/8035.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-01-11 14:48:25 +01:00
Federico Guerinoni
3298de7f66 Add borrow_as_ptr lint
Closes: #6995

Signed-off-by: Federico Guerinoni <guerinoni.federico@gmail.com>
Co-authored-by: Paolo Barbolini <paolo@paolo565.org>
2022-01-11 09:53:29 +01:00
bors
fccf07bae5 Auto merge of #8260 - taiki-e:mutex_atomic, r=llogiq
Downgrade mutex_atomic to nursery

See #1516 and #4295.

There are suggestions about removing this lint from the default warned lints in both issues.
Also, [`mutex_integer`](https://rust-lang.github.io/rust-clippy/master/index.html#mutex_integer) lint that has the same problems as this lint is in `nursery` group.

changelog: Moved [`mutex_atomic`] to `nursery`
2022-01-11 08:09:11 +00:00
bors
51282fc488 Auto merge of #8261 - taiki-e:disallowed, r=giraffate
Warn disallowed_methods and disallowed_types by default

Closes #7841

changelog: Moved [`disallowed_methods`] and [`disallowed_types`] to `style`
2022-01-10 23:51:39 +00:00
Taiki Endo
5f143c603e Warn disallowed_methods and disallowed_types by default 2022-01-11 02:17:14 +09:00
Taiki Endo
cf86cee4fe Downgrade mutex_atomic to nursery 2022-01-10 23:36:13 +09:00
bors
b66dbe87f1 Auto merge of #8228 - Jarcho:iter_not_returning_iterator_8225, r=giraffate
fix `iter_not_returning_iterator`

fixes #8225

changelog: Handle type projections in `iter_not_returning_iterator`
changelog: Don't lint `iter_not_returning_iterator` in trait implementations
changelog: Lint `iter_not_returning_iterator` in trait definitions
2022-01-10 12:34:15 +00:00
bors
1816361738 Auto merge of #8257 - camsteffen:internal-features, r=giraffate
Combine internal cargo features

changelog: none

This is just simpler and I don't see any downsides.
2022-01-10 12:18:05 +00:00
bors
88cfd70100 Auto merge of #8252 - dswij:8229, r=xFrednet
cover trait for `trait_duplication_in_bounds`

closes #8229

changelog: [`trait_duplication_in_bounds`] covers trait functions with `Self` bounds
2022-01-10 10:31:59 +00:00
dswij
f4dc348ad5 trait_duplication_in_bounds Update description and add test 2022-01-10 12:45:22 +08:00
Cameron Steffen
e2ce4f9462 Combine internal features in clippy_lints 2022-01-09 18:35:12 -06:00
Cameron Steffen
16d848891d Combine internal features in clippy_utils 2022-01-09 18:24:51 -06:00
bors
59916952c9 Auto merge of #8236 - PatchMixolydic:single_char_lifetime_names, r=llogiq
new lint: `single_char_lifetime_names`

This pull request adds a lint against single character lifetime names, as they might not divulge enough information about the purpose of the lifetime. This can make code harder to understand. I placed this in `restriction` rather than `pedantic` (as suggested in #8233) since most of the Rust ecosystem already uses single character lifetime names (to my knowledge, at least) and since single character lifetime names aren't incorrect. I'd be happy to change this upon request, however. Fixes #8233.

- [x] Followed lint naming conventions
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `cargo dev update_lints`
- [x] Added lint documentation
- [x] Run `cargo dev fmt`

changelog: new lint: [`single_char_lifetime_names`]
2022-01-09 14:27:36 +00:00
bors
a6f80fccb1 new lint: single_char_lifetime_names
This pull request adds a lint against single character lifetime names, as they might not divulge enough information about the purpose of the lifetime. This can make code harder to understand. I placed this in `restriction` rather than `pedantic` (as suggested in #8233) since most of the Rust ecosystem already uses single character lifetime names (to my knowledge, at least) and since single character lifetime names aren't incorrect. I'd be happy to change this upon request, however. Fixes #8233.

- [x] Followed lint naming conventions
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `cargo dev update_lints`
- [x] Added lint documentation
- [x] Run `cargo dev fmt`

changelog: new lint: [`single_char_lifetime_names`]
2022-01-09 14:27:36 +00:00
dswij
f690978023 cover trait for trait_duplication_in_bounds 2022-01-09 13:35:01 +08:00
bors
83a9f68bd7 Auto merge of #8249 - sourcefrog:depinfo, r=Manishearth
Set binary-dep-depinfo in .cargo/config.toml

Fixes #8248

According to https://doc.rust-lang.org/cargo/reference/unstable this
seems to be the right place to set it, and it does fix the build for me.

I haven't removed the other `rustflags` because perhaps it's needed on
different cargo/rust versions?

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: none
2022-01-09 00:19:19 +00:00
Martin Pool
3ea52086fd Set binary-dep-depinfo in .cargo/config.toml
Fixes #8248

According to https://doc.rust-lang.org/cargo/reference/unstable this
seems to be the right place to set it, and it does fix the build for me.

I haven't removed the other `rustflags` because perhaps it's needed on
different cargo/rust versions?
2022-01-08 14:12:53 -08:00
bors
917890babb Auto merge of #8201 - smoelius:master, r=camsteffen
Change `unnecessary_to_owned` `into_iter` suggestions to `MaybeIncorrect`

I am having a hard time finding a good solution for #8148, so I am wondering if is enough to just change the suggestion's applicability to `MaybeIncorrect`?

I apologize, as I realize this is a bit of a cop out.

changelog: none
2022-01-08 16:33:48 +00:00
Samuel E. Moelius III
366234a515 Add unnecessary_to_owned "Known problems" section 2022-01-08 09:09:52 -05:00
bors
be7cf76369 Auto merge of #8234 - Alexendoo:lintcheck-allow-renamed-dir, r=xFrednet
Allow running lintcheck with a renamed rust-clippy dir

I have Clippy checked out in `rust/clippy` rather than `rust/rust-clippy`, this allows lintcheck to still run in that case

changelog: none
2022-01-07 20:31:24 +00:00
Alex Macleod
94fe6719de Allow running lintcheck with a renamed rust-clippy dir 2022-01-06 13:06:24 +00:00
Jason Newcomb
d98339d3e0 Handle type projections in iter_not_returning_iterator 2022-01-05 17:19:13 -05:00
Jason Newcomb
2cc38a2322 Lint iter_not_returning_iterator on the trait definition rather than the implementation 2022-01-05 13:46:35 -05:00
Samuel E. Moelius III
a4ebf6f78e Change unnecessary_to_owned into_iter suggestions to MaybeIncorrect 2022-01-05 05:05:36 -05:00
bors
92048f4826 Auto merge of #8221 - Jarcho:while_let_on_iterator_8113, r=llogiq
Better detect when a field can be moved from in `while_let_on_iterator`

fixes #8113

changelog: Better detect when a field can be moved from in `while_let_on_iterator`
2022-01-05 06:45:58 +00:00
bors
20f2a89026 Auto merge of #8224 - Jarcho:type_repetition_in_bounds_8162, r=llogiq
Fix `type_repetition_in_bounds`

fixes #7360
fixes #8162
fixes #8056

changelog: Check for full equality in `type_repetition_in_bounds` rather than just equal hashes
2022-01-05 01:05:18 +00:00
bors
d5dcda2f42 Auto merge of #8223 - camsteffen:remove-in-macro, r=llogiq
Remove in_macro from clippy_utils

changelog: none

Previously done in #7897 but reverted in #8170. I'd like to keep `in_macro` out of utils because if a span is from expansion in any way (desugaring or macro), we should not proceed without understanding the nature of the expansion IMO.

r? `@llogiq`
2022-01-05 00:49:23 +00:00
bors
ba03dc70fd Auto merge of #8219 - camsteffen:macro-decoupling, r=llogiq
New macro utils

changelog: none

Sorry, this is a big one. A lot of interrelated changes and I wanted to put the new utils to use to make sure they are somewhat battle-tested. We may want to divide some of the lint-specific refactoring commits into batches for smaller reviewing tasks. I could also split into more PRs.

Introduces a bunch of new utils at `clippy_utils::macros::...`. Please read through the docs and give any feedback! I'm happy to introduce `MacroCall` and various functions to retrieve an instance. It feels like the missing puzzle piece. I'm also introducing `ExpnId` from rustc as "useful for Clippy too". `@rust-lang/clippy`

Fixes #7843 by not parsing every node of macro implementations, at least the major offenders.

I probably want to get rid of `is_expn_of` at some point.
2022-01-04 22:32:02 +00:00
bors
786f874c34 New macro utils
changelog: none

Sorry, this is a big one. A lot of interrelated changes and I wanted to put the new utils to use to make sure they are somewhat battle-tested. We may want to divide some of the lint-specific refactoring commits into batches for smaller reviewing tasks. I could also split into more PRs.

Introduces a bunch of new utils at `clippy_utils::macros::...`. Please read through the docs and give any feedback! I'm happy to introduce `MacroCall` and various functions to retrieve an instance. It feels like the missing puzzle piece. I'm also introducing `ExpnId` from rustc as "useful for Clippy too". `@rust-lang/clippy`

Fixes #7843 by not parsing every node of macro implementations, at least the major offenders.

I probably want to get rid of `is_expn_of` at some point.
2022-01-04 22:32:02 +00:00
Jason Newcomb
2dd216a186 Check for full equality in type_repetition_in_bounds rather than just equal hashes 2022-01-04 14:28:27 -05:00
bors
0e28e38e36 Auto merge of #8220 - Jarcho:manual_swap_8154, r=camsteffen
Consider auto-deref when linting `manual_swap`

fixes #8154

changelog: Don't lint `manual_swap` when a field access involves auto-deref
2022-01-04 18:23:39 +00:00
Jason Newcomb
a7097b80c3 Consider auto-deref when linting manual_swap 2022-01-04 13:22:30 -05:00
Cameron Steffen
00da1b8f14 Remove in_macro from utils 2022-01-04 12:07:42 -06:00
Jason Newcomb
ff58efb2b2 Better detect when a field can be moved from in while_let_on_iterator 2022-01-03 23:13:31 -05:00
bors
3ea77847fe Auto merge of #8216 - pmnoxx:piotr-fix-clippy-warnings, r=xFrednet
Fix `clippy::use-self`` warning in ` src/main.rs`

`ClippyCmd` warnings gets generated due to addition of `clippy::use-self`. This PR fixes that.

```
warning: unnecessary structure name repetition
  --> src/main.rs:99:9
   |
99 |         ClippyCmd {
   |         ^^^^^^^^^ help: use the applicable keyword: `Self`
   |
   = note: `-W clippy::use-self` implied by `-W clippy::nursery`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self
```

---

changelog: none
2022-01-03 16:54:39 +00:00