Commit Graph

14362 Commits

Author SHA1 Message Date
Jason Newcomb
442a68c64b Only check parent node once in dereference.rs 2022-06-28 12:48:26 -04:00
Jason Newcomb
20ea26234a Lint field accesses in explicit_auto_deref 2022-06-28 12:48:26 -04:00
Jason Newcomb
a187d6412b Merge different parent walking loops in dereference.rs
`needless_borrow` will now walk further to find the target type.
2022-06-28 12:48:26 -04:00
Jason Newcomb
ee532c0222 Don't lint explicit_auto_deref on reborrows 2022-06-28 12:48:26 -04:00
Jason Newcomb
8a74d33570 Add explicit_auto_deref lint 2022-06-28 12:48:24 -04:00
Jason Newcomb
c107c97e69 Better support projection types when finding the signature for an expression 2022-06-28 12:47:26 -04:00
bors
b776fb8294 Auto merge of #8774 - hellow554:cargo-rust-version, r=flip1995
try reading rust-version from Cargo.toml

Cargo.toml can contain a field `rust-version`, that acts like a MSRV of
clippy.toml file: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
This will try to read that field and use it, if the clippy.toml config
has no `msrv` entry

changelog: respect `rust-version` from `Cargo.toml`

closes #8746
closes #7765
2022-06-28 07:27:08 +00:00
bors
373bb573af Auto merge of #8639 - Jarcho:trivially_copy_pass_by_ref_5953, r=dswij
`trivially_copy_pass_by_ref` fixes

fixes #5953
fixes #2961

The fix for #5953 is overly aggressive, but the suggestion is so bad that it's worth the false negatives. Basically three things together:
* It's not obviously wrong
* It compiles
* It may actually work when tested

changelog: Don't lint `trivially_copy_pass_by_ref` when unsafe pointers are used.
changelog: Better track lifetimes when linting `trivially_copy_pass_by_ref`.
2022-06-28 07:03:57 +00:00
Marcel Hellwig
f0a1cd5645 add uitests for cargo rust-version field 2022-06-28 08:04:10 +02:00
Marcel Hellwig
6384765665 parse Cargo.toml file in ui-cargo tests
compiletest_rs is not meant to test full cargo projects, but instead
only files.
So we need to parse the `Cargo.toml` file ourself and set the
corresponding environment variable. In this case we just set
`CARGO_PKG_RUST_VERSION`, nothing more. But, of course, this can be
extended.
2022-06-28 08:03:48 +02:00
Marcel Hellwig
83511d1d9a update README.md to reflect rust-version in cargo.toml 2022-06-28 08:03:44 +02:00
Marcel Hellwig
81737bf850 try reading rust-version from Cargo.toml
Cargo.toml can contain a field `rust-version`, that acts like a MSRV of
clippy.toml file: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
This will try to read that field and use it, if the clippy.toml config
has no `msrv` entry
2022-06-28 08:01:50 +02:00
bors
d85539571f Auto merge of #9045 - alex-semenyuk:self_assignment_example, r=llogiq
Fix example `SELF_ASSIGNMENT`

changelog: Fix example in `SELF_ASSIGNMENT` docs
2022-06-27 17:33:31 +00:00
bors
fdd0e727e2 Auto merge of #8649 - ebobrow:imperative_find, r=flip1995
add [`manual_find`] lint for function return case

part of the implementation discussed in #7143

changelog: add [`manual_find`] lint for function return case
2022-06-27 17:15:25 +00:00
Jason Newcomb
c10101cf1c Don't lint trivially_copy_pass_by_ref when unsafe pointers are used 2022-06-27 13:14:27 -04:00
Jason Newcomb
2315f76f9d Actually check lifetimes in trivially_copy_pass_by_ref 2022-06-27 13:14:25 -04:00
alexey semenyuk
c6a2221393 Fix example SELF_ASSIGNMENT 2022-06-27 18:21:09 +03:00
bors
eaa03ea911 Auto merge of #8972 - kyoto7250:use_retain, r=llogiq
feat(new lint): new lint `manual_retain`

close #8097

This PR is  a new  lint implementation.
This lint checks if the `retain` method is available.

Thank you in advance.

changelog: add new ``[`manual_retain`]`` lint
2022-06-27 13:58:26 +00:00
bors
889b3613ae Auto merge of #8990 - tsoutsman:master, r=llogiq
Fix `let_undescore_lock` false-positive when binding without locking

Fixes #8486.

changelog: Fix `let_undescore_lock` false-positive when binding without locking.
2022-06-27 13:38:50 +00:00
Klim Tsoutsman
65f700fa89
Fix let_undescore_lock false-positive when binding without locking
Signed-off-by: Klim Tsoutsman <klimusha@gmail.com>
2022-06-27 20:35:26 +10:00
bors
6b762ee330 Auto merge of #9054 - alex-semenyuk:string_add_example, r=giraffate
STRING_ADD example

changelog: none
STRING_ADD example, how it should be
2022-06-27 06:08:00 +00:00
bors
57e7e1d7d8 Auto merge of #8871 - Serial-ATA:cargo-dev-deprecate, r=giraffate
Add `cargo dev deprecate`

changelog: none

I wrote this awhile ago when `regex` was still a dependency. Is it alright to add it back?
2022-06-27 00:32:22 +00:00
bors
88da5f2bb3 Auto merge of #8939 - Jarcho:transmute_ptr_to_ref_lt, r=giraffate
Suggest `pointer::cast` when possible in `transmute_ptr_to_ref`

fixes #8924

changelog: Suggest casting the pointer for any type containing lifetimes in `transmute_ptr_to_ref`.
changelog: Suggest `pointer::cast` when possible in `transmute_ptr_to_ref`.
2022-06-27 00:05:50 +00:00
kyoto7250
676af4530f cargo dev update_lints 2022-06-27 08:21:09 +09:00
kyoto7250
3a9c0ef8a1 fix for git rebase 2022-06-27 08:11:58 +09:00
kyoto7250
dd3d0fdad3 rename use_retain => manual_retain 2022-06-27 08:11:58 +09:00
kyoto7250
4decfdec76 check msrv 2022-06-27 08:11:58 +09:00
kyoto7250
14212115c4 rewrite without if_chain macro 2022-06-27 08:11:58 +09:00
kyoto7250
fd629c0cde check method 2022-06-27 08:11:58 +09:00
kyoto7250
3953c530f4 change lint type from style to perf 2022-06-27 08:11:58 +09:00
kyoto7250
e3afc72caa remove needless return 2022-06-27 08:11:58 +09:00
kyoto7250
b20b8f10dd Update clippy_lints/src/use_retain.rs
Co-authored-by: llogiq <bogusandre@gmail.com>
2022-06-27 08:11:58 +09:00
kyoto7250
5f2b8e67b3 feat(new lint): new lint use_retain 2022-06-27 08:11:58 +09:00
bors
9b150625a9 Auto merge of #9032 - kyoto7250:issue_9018, r=llogiq
enum_variant_names should ignore when all prefixes are _

close #9018

When Enum prefix is only an underscore, we should not issue warnings.

changelog: fix false positive in enum_variant_names
2022-06-26 16:11:06 +00:00
bors
ab58276146 Auto merge of #9055 - kyoto7250:update_nodejs_in_github_action, r=Manishearth
update node.js version in `remark.yml`

Optional chain (`?.`) is available in `node v14`, but node version in CI is `node v12`, so CI is failed now.

ref:
https://github.com/rust-lang/rust-clippy/runs/7059529735?check_suite_focus=true

optional chain:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#browser_compatibility

Corresponding PR (maybe)
https://github.com/remarkjs/remark/pull/1007

changelog: None
2022-06-26 15:07:22 +00:00
kyoto7250
11bf291189 update node.js version 2022-06-26 20:19:32 +09:00
alexey semenyuk
16919143e4
STRING_ADD example 2022-06-26 08:36:50 +00:00
alexey semenyuk
4065702b1f
STRING_ADD example 2022-06-26 11:14:37 +03:00
kyoto7250
d827b834d9 use all instead of join 2022-06-26 16:11:04 +09:00
kyoto7250
bf317a83cf
treat argument as a slice.
Co-authored-by: llogiq <bogusandre@gmail.com>
2022-06-26 15:55:44 +09:00
bors
8789f4e88a Auto merge of #8985 - botahamec:single-match-option, r=llogiq
Lint `[single_match]` on `Option` matches

fixes #8928

changelog: did some cleanup of the logic for ``[`single_match`]`` and ``[`single_match_else`]`` which fixes the bug where `Option` matches were not linted unless a wildcard was used for one of the arms.
2022-06-25 16:48:34 +00:00
Jason Newcomb
7cdaabc9b7 Suggest pointer::cast when possible in transmute_ptr_to_ref
Defensively add a cast to any type with lifetimes.
2022-06-25 07:55:30 -04:00
bors
93ebd0e2db Auto merge of #9015 - kyoto7250:issue_8493, r=Jarcho
ignore item in `thread_local!` macro

close #8493

This PR ignores `thread_local` macro in `declare_interior_mutable_const`.

changelog: ignore `thread_local!` macro in `declare_interior_mutable_const`
2022-06-25 02:40:30 +00:00
Serial
aec465cabd Add test for [default_deprecation_reason] 2022-06-24 14:11:24 -04:00
bors
e17864e2ff Auto merge of #9031 - evantypanski:manual_rem_euclid, r=Jarcho
Add [`manual_rem_euclid`] lint

Closes #8883

Adds a lint for checking manual use of `rem_euclid(n)`

changelog: Add [`manual_rem_euclid`] lint
2022-06-24 17:49:53 +00:00
bors
1d1ae10876 Auto merge of #9037 - smoelius:fix-extra-unused-lifetimes-fp, r=dswij
Fix `extra_unused_lifetimes` false positive

This PR fixes #9014.

I confirmed the FP on the `crates.io` source as `@JohnTitor` mentioned, and confirmed that the FP is no longer present following this change.

I did not include a test in this PR because I think constructing one would be complicated, and the fix is pretty simple. But please let me know if this is unacceptable.

changelog: fix `extra_unused_lifetimes` FP
2022-06-24 08:39:45 +00:00
bors
3f47cd1752 Auto merge of #9036 - xFrednet:0000-force-warn-in-driver, r=dswij
Check for `--force-warn` in Clippy's driver run condition

Just a thing I've noticed while tinkering on the driver. Currently, the driver only checks for `--cap-lints=allow` to determine if Clippy should run on the code, but ignores possible `--force-warn` arguments

---

changelog: Others: Allowing all lints and only `--force-warn`ing some will now work with Clippy's driver
2022-06-24 02:26:35 +00:00
bors
f7189846be Auto merge of #8953 - DevAccentor:slow_vector_initialization, r=Manishearth
add vec.capacity() to [`slow_vec_initialization`] detection

fix #8800

for example
```rust
let mut vec1 = Vec::with_capacity(len);
vec1.resize(vec1.capacity(), 0);

let mut vec2 = Vec::with_capacity(len);
vec2.extend(repeat(0).take(vec2.capacity()));
```
will trigger the lint

---

changelog: add `vec.capacity()` to [`slow_vec_initialization`] detection
2022-06-23 22:29:52 +00:00
Evan Typanski
df26c3f551 Add external macro guard and test middle MSRV 2022-06-23 16:49:31 -04:00
Serial
ebf77f6d7e Fix ICE when deprecating lints in directories 2022-06-23 10:44:11 -04:00