Commit graph

15269 commits

Author SHA1 Message Date
TennyZhuang
b10882ab91 fix dogfood
Signed-off-by: TennyZhuang <zty0826@gmail.com>
2022-10-16 16:27:36 +08:00
TennyZhuang
7ac97b69fc Add new lint partial_pub_fields
Signed-off-by: TennyZhuang <zty0826@gmail.com>
2022-10-16 16:03:50 +08:00
bors
ff33d6e712 Auto merge of #9655 - llogiq:unbox-default, r=dswij
fix `box-default` linting `no_std` non-boxes

This fixes #9653 by doing the check against the `Box` type correctly even if `Box` isn't there, as in `no_std` code. Thanks to `@lukas-code` for opening the issue and supplying a reproducer!

---

changelog: none
2022-10-16 03:11:06 +00:00
Andre Bogus
f8ae2f5807 fix box-default linting no_std non-boxes 2022-10-15 23:19:43 +02:00
bors
50f192f86a Auto merge of #9649 - Alexendoo:from-over-into-suggestion, r=llogiq
Add a suggestion and a note about orphan rules for `from_over_into`

Adds a machine applicable suggestion to convert the `Into` impl into a `From` one to `from_over_into`

Also adds a note explaining that `impl From<Local> for Foreign` is fine if the `Into` type is foreign

Closes #7444
Addresses half of #9638

changelog: [`from_over_into`] Add a suggestion and a note about orphan rules
2022-10-15 08:37:11 +00:00
Alex Macleod
4b8df8dc92 Add a suggestion and a note about orphan rules for from_over_into 2022-10-14 22:50:23 +00:00
bors
b510557f89 Auto merge of #9645 - Jarcho:ptr_arg_9542, r=llogiq
Don't lint `ptr_arg` when used as an incompatible trait object

fixes #9542
changelog: [`ptr_arg`](https://rust-lang.github.io/rust-clippy/master/#ptr_arg): Don't lint when used as an incompatible trait object
2022-10-14 17:44:03 +00:00
Jason Newcomb
344b7bca86 Don't lint ptr_arg when used as an incompatible trait object 2022-10-14 13:21:59 -04:00
bors
efa361bf56 Auto merge of #9643 - icecream17:patch-1, r=flip1995
Book: Small grammar + link a11y change

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

changelog: none

---

Very minor

For the link accessibility change, `here` and related don't provide context for screen readers who are reading a list of links.
(Random supporting google links)
https://www.w3.org/QA/Tips/noClickHere
https://usability.yale.edu/web-accessibility/articles/links
2022-10-14 16:28:57 +00:00
bors
8e0da62409 Auto merge of #9644 - hkBst:patch-1, r=flip1995
add missing comma

changelog: none
2022-10-14 16:15:19 +00:00
Marijn Schouten
950f5fa945
add missing comma 2022-10-14 16:57:06 +02:00
Steven Nguyen
135a2730eb
Book: Small grammar + link a11y change 2022-10-13 23:48:05 -05:00
bors
9a6eca5f85 Auto merge of #9641 - Alexendoo:sparse-registry, r=flip1995
Enable cargo sparse registry in CI

https://blog.rust-lang.org/2022/06/22/sparse-registry-testing.html

The initial registry update takes around 1 minute currently, so this gives quite a nice speed boost to CI build times

r? `@flip1995`

changelog: none
2022-10-13 12:58:31 +00:00
Alex Macleod
a31462a072 Enable cargo sparse registry in CI 2022-10-13 12:33:04 +00:00
bors
4e89ffa656 Auto merge of #9640 - Alexendoo:edition-revisions, r=llogiq
Fix edition revision ui tests

#9605 had me wondering how the edition revision tests were working for `manual_assert` but not for `@nyurik,` but it turns out `manual_assert`'s tests weren't working either. I checked how `rust-lang/rust` does it and apparently it comes down to whitespace, `//[rev] edition:X` works 😬

Removes the revisions from `match_wild_err_arm` as I couldn't find any edition dependant behaviour there

r? `@llogiq`

changelog: none
2022-10-13 12:18:20 +00:00
bors
fe3200c038 Auto merge of #9584 - royrustdev:implicit_saturating_sub, r=llogiq
add tests in `implicit_saturating_sub` lint

This adds more tests to the `implicit_saturating_sub` lint to rule out certain false positives that have appeared in the past.

Now with those false positives out of the equation, we can move the lint to `style`.

---

changelog: promote [`implicit-saturating-sub`] to the `style` category
2022-10-13 12:04:23 +00:00
bors
58ef56e39b Auto merge of #9600 - nyurik:inline-fmt-style, r=llogiq
Change uninlined_format_args into a style lint

As [previously discussed](https://github.com/rust-lang/rust-clippy/pull/9233#issuecomment-1256361205), the `uninlined_format_args` should probably be a part of the default style because `println!("{}", foo)` is not as concise or easy to understand as `println!("{foo}")`

changelog: [`uninlined_format_args`]: change to be the default `style`
2022-10-13 11:51:20 +00:00
Alex Macleod
124caeb9a2 Fix edition revision ui tests 2022-10-13 11:40:13 +00:00
bors
42bdfa23d3 Auto merge of #9590 - nyurik:fix-parens, r=Alexendoo
Fix to_string_in_format_args in parens

Fix suggestions like

```
print!("error: something failed at {}", (Location::caller().to_string()));
```

where the parenthesis enclose some portion of the value.

Fixes #9540

changelog: [`to_string_in_format_args`]: fix incorrect fix when value is enclosed in parenthesis
2022-10-12 22:53:48 +00:00
Yuri Astrakhan
7717904043 Fix to_string_in_format_args in parens
Fix suggestions like

```
print!("error: something failed at {}", (Location::caller().to_string()));
```

where the parenthesis enclose some portion of the value.
2022-10-12 18:47:49 -04:00
bors
45dd9f31f3 Auto merge of #9627 - Jarcho:ice-9625, r=xFrednet
Use the correct type when comparing nested constants.

fixes #9625

changelog: `manual_range_contains`: fix ICE when the values are behind a reference
2022-10-12 18:49:34 +00:00
bors
b8a9a507bf Auto merge of #9617 - llogiq:cast-nan-to-int, r=Alexendoo
add `cast-nan-to-int` lint

This fixes #371.

r? `@Alexendoo`

---

changelog: add [`cast-nan-to-int`] lint
2022-10-12 11:48:30 +00:00
bors
6354d1275d Auto merge of #9633 - royrustdev:fix_rc_buffer, r=llogiq
update Applicability of `rc_buffer` lint from `MachineApplicable` to `Unspecified`

`Unspecified`

This changes `rc_buffer` from MachineApplicable to Unspecified

```
changelog: change [`rc_buffer`] to Unspecified.
```

fixes #6241

---

changelog: change [`rc_buffer`] to Unspecified.
2022-10-12 11:31:38 +00:00
Andre Bogus
e4c80f2bba add cast-nan-to-int lint 2022-10-12 13:29:27 +02:00
royrustdev
31006b4227 update Applicability of rc_buffer from MachineApplicable to
`Unspecified`
2022-10-12 16:41:48 +05:30
bors
2d588175ca Auto merge of #9605 - nyurik:fix-inline-edition, r=llogiq
fix: uninlined_format_args shouldn't inline panic! before 2021ed

Before 2021 edition, `panic!("...")` was not treated as a format string.
Clippy autofix of `panic!("{}", foo)` into `panic!("{foo}")` is incorrect.

changelog: [`uninlined_format_args`]: Do not inline panic! macros before 2021 edition
2022-10-12 07:16:23 +00:00
royrustdev
ac6d2ba11e add tests in implicit_saturating_sub lint 2022-10-12 09:28:17 +05:30
Yuri Astrakhan
74ba7e1b99 Handle panic! inline_format-arg before ed2021 2022-10-11 21:27:41 -04:00
bors
854015c33c Auto merge of #9629 - est31:let_else, r=Jarcho
Replace manual let else patterns with let else

Clears the codebase from places where the lint added by #8437 is firing, by adopting let else.

changelog: none
2022-10-11 14:26:04 +00:00
bors
122ae22897 Auto merge of #9616 - unvalley:add-default-to-lint-groups, r=xFrednet
Add Default to Clippy Lints Lint groups

- related to #7958

This PR adds a default (reset) button to Clippy Lints Lint groups. (change for website)
[The page](https://rust-lang.github.io/rust-clippy/master/index.html) sets only `Deprecated` to false by default.
Certainly it is easy to set only `deprecated` to false, but it may be a bit lazy for beginners.

https://user-images.githubusercontent.com/38400669/194831117-3ade7e0d-c4de-4189-9daf-3be8ea3cdd18.mov

changelog: none
2022-10-11 08:35:12 +00:00
bors
8e87d39f99 Auto merge of #9572 - Nilstrieb:as-ptr-cast-mut, r=dswij
Add `as_ptr_cast_mut` lint

This lint detects calls to a `&self`-taking `as_ptr` method, where the result is then immediately cast to a `*mut T`. Code like this is probably invalid, as that pointer will not have write permissions, and `*mut T` is usually used to write through.

Examples of broken code with this pattern:
https://miri.saethlin.dev/ub?crate=lol_alloc&version=0.1.3
https://miri.saethlin.dev/ub?crate=sophon-wasm&version=0.19.0
https://miri.saethlin.dev/ub?crate=polars-core&version=0.24.2
https://miri.saethlin.dev/ub?crate=ach-cell&version=0.1.17

changelog: Add [`as_ptr_cast_mut`]
2022-10-11 08:08:17 +00:00
est31
f48d13f8d1 Replace manual let else patterns with let else 2022-10-11 00:12:16 +02:00
Jason Newcomb
0cc749296f Use the correct type when comparing nested constants. 2022-10-10 15:33:49 -04:00
bors
cf72565a12 Auto merge of #9610 - Jarcho:fix-9608, r=Alexendoo
Don't suggest moving tuple structs with a significant drop to late evaluation

fixes #9608

changelog: Don't suggest moving tuple structs with a significant drop to late evaluation
2022-10-10 12:29:15 +00:00
unvalley
178799f9c1 fix: change command order and remove waste condition 2022-10-10 18:00:15 +09:00
unvalley
1688368b33 feat: add Default to Lint groups 2022-10-09 23:35:52 +09:00
bors
272bbfb857 Auto merge of #9386 - smoelius:further-enhance-needless-borrow, r=Jarcho
Further enhance `needless_borrow`, mildly refactor `redundant_clone`

This PR does the following:
* Moves some code from `redundant_clone` into a new `clippy_utils` module called `mir`, and wraps that code in a function called `dropped_without_further_use`.
* Relaxes the "is copyable" condition condition from #9136 by also suggesting to remove borrows from values dropped without further use. The changes involve the just mentioned function.
* Separates `redundant_clone` into modules.

Strictly speaking, the last bullet is independent of the others. `redundant_clone` is somewhat hairy, IMO. Separating it into modules makes it slightly less so, by helping to delineate what depends upon what.

I've tried to break everything up into digestible commits.

r? `@Jarcho`

(`@Jarcho` I hope you don't mind.)

changelog: continuation of #9136
2022-10-08 21:24:54 +00:00
bors
292e313259 Auto merge of #9451 - kraktus:manual_filter2, r=dswij
Add `manual_filter` lint for `Option`

Share much of its implementation with `manual_map` and should greatly benefit from its previous feedback.
I'm sure it's possible to even more refactor both and would gladly take input on that as well as any clippy idiomatic usage, since this is my first lint addition.

I've added the lint to the complexity section for now, I don't know if every new lint needs to go in nursery first.

The matching could be expanded to more than `Some(<value>)` to lint on arbitrary struct matching inside the `Some` but I've left it like it was for `manual_map` for now. `needless_match::pat_same_as_expr` provides a more generic match example.

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

changelog: Add lint [`manual_filter`] for `Option`
2022-10-08 15:58:51 +00:00
Jason Newcomb
39a7d000b6 Don't suggest moving tuple structs with a significant drop to late evaluation. 2022-10-08 11:23:05 -04:00
bors
2c8e473ffe Auto merge of #9585 - rust-lang:extend-box-default, r=Alexendoo
extend `box-default` lint, add suggestion

This extends the recently added `box-default` lint to also cover `Box::new(vec![])`, `Box::new(String::from(""))` and `Box::new(Vec::from([]))`. Also the lint now suggests a suitable replacement. I did not find a simple way to check whether the type is fully determined by the outside, so I at least checked for some variations to remove the turbofish in those cases.

---

changelog: none
2022-10-07 14:49:54 +00:00
Samuel Moelius
9cc8da222b Fix adjacent code 2022-10-07 05:07:44 -04:00
Samuel Moelius
037f698147 needless_borrow uses used_exactly_once 2022-10-07 05:07:44 -04:00
bors
65ae6666c8 Auto merge of #9595 - Alexendoo:author-let-chains, r=Jarcho
Replace if_chain with let chains in `clippy::author` output

Should help nudge new contributors towards let chains

changelog: none
2022-10-07 02:52:47 +00:00
bors
36901992b9 Auto merge of #9601 - evantypanski:et/issue9575, r=Manishearth
[`match_single_binding`] Add curlies for more cases to fix suggestion causes error

Fixes #9575

changelog: [`match_single_binding`]: Add curlies for scrutinees with side effects for more cases
2022-10-06 21:55:56 +00:00
Evan Typanski
39164acf6e Fix flipped variable that made it through 2022-10-06 15:36:28 -04:00
Evan Typanski
23b16998c3 Add curlies to scrutinees with side effects 2022-10-06 15:14:55 -04:00
Yuri Astrakhan
493684888f Change uninlined_format_args into a style lint 2022-10-06 12:12:55 -04:00
bors
8f1ebdd18b Auto merge of #9593 - Andy-Python-Programmer:master, r=llogiq
lint::unsafe_removed_from_name: fix false positive result when allowed

changelog: [`unsafe_removed_from_name`] Fix allowing on imports produces a false positive on `useless_attribute`.

Fixes: #9197

Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
2022-10-06 14:39:26 +00:00
bors
6dd0c3a9e8 Auto merge of #9599 - nyurik:inline-crash, r=flip1995
Add a temporary workaround for  multiline formart arg inlining

per suggestion in
https://github.com/rust-lang/rust/pull/102729#discussion_r988990080

workaround for an internal crash when handling multi-line format argument inlining.

changelog: none

(no point for changelog because it is still a new lint being introduced)
2022-10-06 14:12:29 +00:00
Andre Bogus
d3c041a086 extend box-default lint, add suggestion 2022-10-06 16:00:45 +02:00