]> git.lizzy.rs Git - rust.git/log
rust.git
20 months agoAuto merge of #9609 - kraktus:hexa_f32, r=giraffate
bors [Mon, 17 Oct 2022 00:46:36 +0000 (00:46 +0000)]
Auto merge of #9609 - kraktus:hexa_f32, r=giraffate

[`unnecessary_cast`] Do not lint negative hexadecimal literals when cast as floats

fix https://github.com/rust-lang/rust-clippy/issues/9603

changelog: [`unnecessary_cast`] Do not lint negative hexadecimal literals when cast as floats

20 months agoAuto merge of #9652 - kraktus:octo_89, r=xFrednet
bors [Sun, 16 Oct 2022 21:18:54 +0000 (21:18 +0000)]
Auto merge of #9652 - kraktus:octo_89, r=xFrednet

[`zero_prefixed_literal`] Do not advise to use octal form if not possible

fix https://github.com/rust-lang/rust-clippy/issues/9651

changelog: [`zero_prefixed_literal`] Do not advise to use octal form if not possible

20 months agoAuto merge of #9658 - TennyZhuang:partial-pub-fields, r=llogiq
bors [Sun, 16 Oct 2022 14:06:56 +0000 (14:06 +0000)]
Auto merge of #9658 - TennyZhuang:partial-pub-fields, r=llogiq

Add new lint `partial_pub_fields`

Signed-off-by: TennyZhuang <zty0826@gmail.com>
*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: `partial_pub_fields`: new lint to disallow partial fields of a struct be pub

Resolve #9604

20 months agofix a doctest
TennyZhuang [Sun, 16 Oct 2022 09:10:27 +0000 (17:10 +0800)]
fix a doctest

Signed-off-by: TennyZhuang <zty0826@gmail.com>
20 months agoadd many tests
TennyZhuang [Sun, 16 Oct 2022 08:57:31 +0000 (16:57 +0800)]
add many tests

Signed-off-by: TennyZhuang <zty0826@gmail.com>
20 months agofix dogfood
TennyZhuang [Sun, 16 Oct 2022 08:21:48 +0000 (16:21 +0800)]
fix dogfood

Signed-off-by: TennyZhuang <zty0826@gmail.com>
20 months agoAdd new lint `partial_pub_fields`
TennyZhuang [Sun, 16 Oct 2022 08:02:23 +0000 (16:02 +0800)]
Add new lint `partial_pub_fields`

Signed-off-by: TennyZhuang <zty0826@gmail.com>
20 months agoAuto merge of #9566 - smoelius:diagnostic-item-path, r=dswij
bors [Sun, 16 Oct 2022 05:56:19 +0000 (05:56 +0000)]
Auto merge of #9566 - smoelius:diagnostic-item-path, r=dswij

Expand internal lint `unnecessary_def_path`

This PR does essentially two things:
* Separates the internal lints into modules by pass. (`internal_lints.rs` was over 1400 lines, which is a little unruly IMHO.)
* ~Adds a new~ Expands the `unnecessary_def_path` internal lint to flag hardcoded paths to diagnostic and language items.

My understanding is that the latter is currently done by reviewers. Automating this process should make things easier for both reviewers and contributors.

I could make the first bullet a separate PR, or remove it entirely, if desired.

changelog: Add internal lint `diagnostic_item_path`

20 months agoAuto merge of #9636 - kraktus:numeric-fallback, r=dswij
bors [Sun, 16 Oct 2022 05:32:19 +0000 (05:32 +0000)]
Auto merge of #9636 - kraktus:numeric-fallback, r=dswij

[`default_numeric_fallback`] do not lint on constants

fix https://github.com/rust-lang/rust-clippy/issues/9632

changelog:[`default_numeric_fallback`] do not lint on constants

20 months agoAuto merge of #9655 - llogiq:unbox-default, r=dswij
bors [Sun, 16 Oct 2022 03:11:06 +0000 (03:11 +0000)]
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

20 months agofix `box-default` linting `no_std` non-boxes
Andre Bogus [Sat, 15 Oct 2022 21:19:43 +0000 (23:19 +0200)]
fix `box-default` linting `no_std` non-boxes

20 months ago[`zero_prefixed_literal`] Do not advise to use octal form if not possible
kraktus [Sat, 15 Oct 2022 13:10:50 +0000 (15:10 +0200)]
[`zero_prefixed_literal`] Do not advise to use octal form if not possible

20 months ago`explicit_ty_bound` code golf
kraktus [Sat, 15 Oct 2022 12:57:08 +0000 (14:57 +0200)]
`explicit_ty_bound` code golf

20 months agoFormat affected files
Samuel Moelius [Sun, 9 Oct 2022 11:01:49 +0000 (07:01 -0400)]
Format affected files

20 months agoFix adjacent code
Samuel Moelius [Sat, 1 Oct 2022 08:56:55 +0000 (04:56 -0400)]
Fix adjacent code

20 months agoExpand `unnecessary_def_path` lint
Samuel Moelius [Sat, 1 Oct 2022 08:48:01 +0000 (04:48 -0400)]
Expand `unnecessary_def_path` lint

20 months agoMove some things around
Samuel Moelius [Sat, 1 Oct 2022 01:10:10 +0000 (21:10 -0400)]
Move some things around

20 months agoSeparate internal lints by pass
Samuel Moelius [Sat, 1 Oct 2022 01:10:10 +0000 (21:10 -0400)]
Separate internal lints by pass

20 months agoAuto merge of #9649 - Alexendoo:from-over-into-suggestion, r=llogiq
bors [Sat, 15 Oct 2022 08:37:11 +0000 (08:37 +0000)]
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

20 months agoAdd a suggestion and a note about orphan rules for `from_over_into`
Alex Macleod [Fri, 14 Oct 2022 22:50:23 +0000 (22:50 +0000)]
Add a suggestion and a note about orphan rules for `from_over_into`

20 months agoAuto merge of #9645 - Jarcho:ptr_arg_9542, r=llogiq
bors [Fri, 14 Oct 2022 17:44:03 +0000 (17:44 +0000)]
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

20 months agoDon't lint `ptr_arg` when used as an incompatible trait object
Jason Newcomb [Fri, 14 Oct 2022 17:21:59 +0000 (13:21 -0400)]
Don't lint `ptr_arg` when used as an incompatible trait object

20 months agoAuto merge of #9643 - icecream17:patch-1, r=flip1995
bors [Fri, 14 Oct 2022 16:28:57 +0000 (16:28 +0000)]
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

20 months agoAuto merge of #9644 - hkBst:patch-1, r=flip1995
bors [Fri, 14 Oct 2022 16:15:19 +0000 (16:15 +0000)]
Auto merge of #9644 - hkBst:patch-1, r=flip1995

add missing comma

changelog: none

20 months agoadd missing comma
Marijn Schouten [Fri, 14 Oct 2022 14:57:06 +0000 (16:57 +0200)]
add missing comma

20 months agoBook: Small grammar + link a11y change
Steven Nguyen [Fri, 14 Oct 2022 04:48:05 +0000 (23:48 -0500)]
Book: Small grammar + link a11y change

20 months agoAuto merge of #9641 - Alexendoo:sparse-registry, r=flip1995
bors [Thu, 13 Oct 2022 12:58:31 +0000 (12:58 +0000)]
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

20 months agoEnable cargo sparse registry in CI
Alex Macleod [Thu, 13 Oct 2022 12:33:04 +0000 (12:33 +0000)]
Enable cargo sparse registry in CI

20 months agoAuto merge of #9640 - Alexendoo:edition-revisions, r=llogiq
bors [Thu, 13 Oct 2022 12:18:20 +0000 (12:18 +0000)]
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

20 months agoAuto merge of #9584 - royrustdev:implicit_saturating_sub, r=llogiq
bors [Thu, 13 Oct 2022 12:04:23 +0000 (12:04 +0000)]
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

20 months agoAuto merge of #9600 - nyurik:inline-fmt-style, r=llogiq
bors [Thu, 13 Oct 2022 11:51:20 +0000 (11:51 +0000)]
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`

20 months agoFix edition revision ui tests
Alex Macleod [Thu, 13 Oct 2022 11:40:13 +0000 (11:40 +0000)]
Fix edition revision ui tests

21 months agoAuto merge of #9590 - nyurik:fix-parens, r=Alexendoo
bors [Wed, 12 Oct 2022 22:53:48 +0000 (22:53 +0000)]
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

21 months agoFix to_string_in_format_args in parens
Yuri Astrakhan [Tue, 4 Oct 2022 04:07:12 +0000 (00:07 -0400)]
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.

21 months agorefactor `default_numeric_fallback`
kraktus [Wed, 12 Oct 2022 21:00:52 +0000 (23:00 +0200)]
refactor `default_numeric_fallback`

We only need to store if the literal binding has an explicit type bound or not

21 months ago`default_numeric_fallback` do not lint on constants
kraktus [Wed, 12 Oct 2022 10:04:41 +0000 (12:04 +0200)]
`default_numeric_fallback` do not lint on constants

21 months agoAuto merge of #9627 - Jarcho:ice-9625, r=xFrednet
bors [Wed, 12 Oct 2022 18:49:34 +0000 (18:49 +0000)]
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

21 months agoAuto merge of #9617 - llogiq:cast-nan-to-int, r=Alexendoo
bors [Wed, 12 Oct 2022 11:48:30 +0000 (11:48 +0000)]
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

21 months agoAuto merge of #9633 - royrustdev:fix_rc_buffer, r=llogiq
bors [Wed, 12 Oct 2022 11:31:38 +0000 (11:31 +0000)]
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.

21 months agoadd `cast-nan-to-int` lint
Andre Bogus [Sat, 8 Oct 2022 21:33:23 +0000 (23:33 +0200)]
add `cast-nan-to-int` lint

21 months agoupdate Applicability of `rc_buffer` from `MachineApplicable` to
royrustdev [Wed, 12 Oct 2022 11:11:48 +0000 (16:41 +0530)]
update Applicability of `rc_buffer` from `MachineApplicable` to
`Unspecified`

21 months agoAuto merge of #9605 - nyurik:fix-inline-edition, r=llogiq
bors [Wed, 12 Oct 2022 07:16:23 +0000 (07:16 +0000)]
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

21 months agoadd tests in `implicit_saturating_sub` lint
royrustdev [Mon, 3 Oct 2022 14:59:59 +0000 (20:29 +0530)]
add tests in `implicit_saturating_sub` lint

21 months agoHandle panic! inline_format-arg before ed2021
Yuri Astrakhan [Sat, 8 Oct 2022 08:49:00 +0000 (04:49 -0400)]
Handle panic! inline_format-arg before ed2021

21 months agoAuto merge of #9629 - est31:let_else, r=Jarcho
bors [Tue, 11 Oct 2022 14:26:04 +0000 (14:26 +0000)]
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

21 months agoAuto merge of #9616 - unvalley:add-default-to-lint-groups, r=xFrednet
bors [Tue, 11 Oct 2022 08:35:12 +0000 (08:35 +0000)]
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

21 months agoAuto merge of #9572 - Nilstrieb:as-ptr-cast-mut, r=dswij
bors [Tue, 11 Oct 2022 08:08:17 +0000 (08:08 +0000)]
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`]

21 months agoReplace manual let else patterns with let else
est31 [Mon, 10 Oct 2022 20:37:42 +0000 (22:37 +0200)]
Replace manual let else patterns with let else

21 months agoUse the correct type when comparing nested constants.
Jason Newcomb [Mon, 10 Oct 2022 19:33:49 +0000 (15:33 -0400)]
Use the correct type when comparing nested constants.

21 months agoAuto merge of #9610 - Jarcho:fix-9608, r=Alexendoo
bors [Mon, 10 Oct 2022 12:29:15 +0000 (12:29 +0000)]
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

21 months agofix: change command order and remove waste condition
unvalley [Mon, 10 Oct 2022 09:00:15 +0000 (18:00 +0900)]
fix: change command order and remove waste condition

21 months agofeat: add Default to Lint groups
unvalley [Sun, 9 Oct 2022 14:35:52 +0000 (23:35 +0900)]
feat: add Default to Lint groups

21 months agoAuto merge of #9386 - smoelius:further-enhance-needless-borrow, r=Jarcho
bors [Sat, 8 Oct 2022 21:24:54 +0000 (21:24 +0000)]
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

21 months agoAuto merge of #9451 - kraktus:manual_filter2, r=dswij
bors [Sat, 8 Oct 2022 15:58:51 +0000 (15:58 +0000)]
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`

21 months agoDon't suggest moving tuple structs with a significant drop to late evaluation.
Jason Newcomb [Sat, 8 Oct 2022 15:23:05 +0000 (11:23 -0400)]
Don't suggest moving tuple structs with a significant drop to late evaluation.

21 months ago[`unnecessary_cast`] Do not lint negative hexadecimal literals when cast as float
kraktus [Sat, 8 Oct 2022 14:15:18 +0000 (16:15 +0200)]
[`unnecessary_cast`] Do not lint negative hexadecimal literals when cast as float

Floats cannot be expressed as hexadecimal literals

21 months agoAuto merge of #9585 - rust-lang:extend-box-default, r=Alexendoo
bors [Fri, 7 Oct 2022 14:49:54 +0000 (14:49 +0000)]
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

21 months agoFix adjacent code
Samuel Moelius [Fri, 7 Oct 2022 09:07:09 +0000 (05:07 -0400)]
Fix adjacent code

21 months ago`needless_borrow` uses `used_exactly_once`
Samuel Moelius [Thu, 25 Aug 2022 00:14:21 +0000 (00:14 +0000)]
`needless_borrow` uses `used_exactly_once`

21 months agoAuto merge of #9595 - Alexendoo:author-let-chains, r=Jarcho
bors [Fri, 7 Oct 2022 02:52:47 +0000 (02:52 +0000)]
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

21 months agoAuto merge of #9601 - evantypanski:et/issue9575, r=Manishearth
bors [Thu, 6 Oct 2022 21:55:56 +0000 (21:55 +0000)]
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

21 months agoFix flipped variable that made it through
Evan Typanski [Thu, 6 Oct 2022 19:36:28 +0000 (15:36 -0400)]
Fix flipped variable that made it through

21 months agoAdd curlies to scrutinees with side effects
Evan Typanski [Thu, 6 Oct 2022 19:14:55 +0000 (15:14 -0400)]
Add curlies to scrutinees with side effects

21 months agoChange uninlined_format_args into a style lint
Yuri Astrakhan [Thu, 6 Oct 2022 16:12:55 +0000 (12:12 -0400)]
Change uninlined_format_args into a style lint

21 months agoAuto merge of #9593 - Andy-Python-Programmer:master, r=llogiq
bors [Thu, 6 Oct 2022 14:39:26 +0000 (14:39 +0000)]
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>
21 months agoAuto merge of #9599 - nyurik:inline-crash, r=flip1995
bors [Thu, 6 Oct 2022 14:12:29 +0000 (14:12 +0000)]
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)

21 months agoextend `box-default` lint, add suggestion
Andre Bogus [Mon, 3 Oct 2022 15:29:38 +0000 (17:29 +0200)]
extend `box-default` lint, add suggestion

21 months agoAdd a temporary workaround for multiline formart arg inlining
Yuri Astrakhan [Thu, 6 Oct 2022 13:12:37 +0000 (09:12 -0400)]
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.

21 months agoAuto merge of #9598 - nyurik:fix-comment, r=Alexendoo
bors [Thu, 6 Oct 2022 12:56:27 +0000 (12:56 +0000)]
Auto merge of #9598 - nyurik:fix-comment, r=Alexendoo

lint: fix a few comments

minor cleanup per `@Alexendoo` [comment](https://github.com/rust-lang/rust-clippy/pull/9586#discussion_r988991976)

changelog: none

21 months agolint: fix a few comments
Yuri Astrakhan [Thu, 6 Oct 2022 12:54:07 +0000 (08:54 -0400)]
lint: fix a few comments

21 months agoAuto merge of #9596 - flip1995:rustup, r=flip1995
bors [Thu, 6 Oct 2022 07:23:08 +0000 (07:23 +0000)]
Auto merge of #9596 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

21 months agoBump nightly version -> 2022-10-06
Philipp Krones [Thu, 6 Oct 2022 07:19:51 +0000 (09:19 +0200)]
Bump nightly version -> 2022-10-06

21 months agoMerge remote-tracking branch 'upstream/master' into rustup
Philipp Krones [Thu, 6 Oct 2022 07:19:29 +0000 (09:19 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

21 months agoReplace if_chain with let chains in `clippy::author` output
Alex Macleod [Wed, 5 Oct 2022 17:17:57 +0000 (17:17 +0000)]
Replace if_chain with let chains in `clippy::author` output

21 months agoAuto merge of #9586 - Alexendoo:format-args-commas, r=Manishearth
bors [Wed, 5 Oct 2022 16:27:03 +0000 (16:27 +0000)]
Auto merge of #9586 - Alexendoo:format-args-commas, r=Manishearth

FormatArgsExpn: Find comma spans and ignore weird proc macro spans

Fixes the following cases:

A missing `, 1` from the `expect_fun_call` suggestion:

```rust
Some(()).expect(&format!("{x} {}", 1));
```
```
warning: use of `expect` followed by a function call
 --> t.rs:7:14
  |
7 |     Some(()).expect(&format!("{x} {}", 1));
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{x} {}"))`
```

The suggestion removing from the comma in the comment rather than the one after the format string:

```rust
println!(
    "{}",
    // a comment, with a comma in it
    x
);
```
```
warning: variables can be used directly in the `format!` string
  --> t.rs:9:5
   |
9  | /     println!(
10 | |         "{}",
11 | |         // a comment, with a comma in it
12 | |         x
13 | |     );
   | |_____^
   |
help: change this to
   |
10 ~         "{x}",
11 ~         // a comment
   |
```

It also no longer accepts expansions where a format string or argument has a "weird" proc macro span, that is one where the literal/expression it outputs has the span of one of its inputs. Kind of like a `format_args` specific `clippy_utils::is_from_proc_macro`, e.g. `format!(indoc! {" ... "})`

changelog: [`expect_fun_call`]: Fix suggestion for `format!` using captured variables
changelog: [`print_literal`], [`write_literal`], [`uninlined_format_args`]: Fix suggestion when following a comment including a comma

21 months agoFormatArgsExpn: Find comma spans and ignore weird proc macro spans
Alex Macleod [Wed, 5 Oct 2022 16:10:52 +0000 (16:10 +0000)]
FormatArgsExpn: Find comma spans and ignore weird proc macro spans

21 months agoAuto merge of #9495 - Alexendoo:disallowed-macros, r=Jarcho
bors [Wed, 5 Oct 2022 14:49:31 +0000 (14:49 +0000)]
Auto merge of #9495 - Alexendoo:disallowed-macros, r=Jarcho

Add `disallowed_macros` lint

Closes #7790
Fixes #9558

`clippy_utils::def_path_res` already resolved macro definitions which is nice, it just needed a tweak to be able to disambiguate e.g. `std::vec` the module & `std::vec` the macro, and `serde::Serialize` the trait & `serde::Serialize` the derive macro

changelog: new lint: [`disallowed_macros`]
changelog: [`disallowed_methods`], [`disallowed_types`]: Fix false negative when a type/fn/macro share the same path

21 months agoAdd `disallowed_macros` lint
Alex Macleod [Wed, 5 Oct 2022 13:44:01 +0000 (13:44 +0000)]
Add `disallowed_macros` lint

21 months agolint::unsafe_removed_from_name: fix false positive result when allowed
Andy-Python-Programmer [Wed, 5 Oct 2022 07:59:01 +0000 (18:59 +1100)]
lint::unsafe_removed_from_name: fix false positive result when allowed

* Allowing `unsafe_removed_from_name` on imports produces a false
positive on `useless_attribute`.

Fixes: #9197
Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
21 months agoIt's not about types or consts, but the lack of regions
Oli Scherer [Tue, 4 Oct 2022 09:43:34 +0000 (09:43 +0000)]
It's not about types or consts, but the lack of regions

21 months agoAuto merge of #9587 - c410-f3r:arith, r=Alexendoo
bors [Tue, 4 Oct 2022 11:05:24 +0000 (11:05 +0000)]
Auto merge of #9587 - c410-f3r:arith, r=Alexendoo

[arithmetic-side-effects] Do not ignore literal references

To my utter surprise, `rustc` does does not warn stuff like `let n: u8 = &255 + &1` or `let n: u8 = 255 + &1`.

changelog: [arithmetic-side-effects] Do not ignore literal references

21 months agoAuto merge of #9547 - nyurik:capt, r=flip1995
bors [Tue, 4 Oct 2022 07:20:24 +0000 (07:20 +0000)]
Auto merge of #9547 - nyurik:capt, r=flip1995

fallout: fix tests to allow uninlined_format_args

In order to switch `clippy::uninlined_format_args` from pedantic to style, all existing tests must not raise a warning. I did not want to change the actual tests, so this is a relatively minor change that:

* add `#![allow(clippy::uninlined_format_args)]` where needed
* normalizes all allow/deny/warn attributes
   * all allow attributes are grouped together
   * sorted alphabetically
   * the `clippy::*` attributes are listed separate from the other ones.
   * deny and warn attributes are listed before the allowed ones

See also https://github.com/rust-lang/rust-clippy/pull/9233, https://github.com/rust-lang/rust-clippy/pull/9525, https://github.com/rust-lang/rust-clippy/pull/9527

cc: `@llogiq` `@Alexendoo`

changelog: none

21 months agoDogfood
Caio [Mon, 3 Oct 2022 23:10:00 +0000 (20:10 -0300)]
Dogfood

21 months ago[arithmetic-side-effects] Do not ignore literal references
Caio [Mon, 3 Oct 2022 22:49:03 +0000 (19:49 -0300)]
[arithmetic-side-effects] Do not ignore literal references

21 months agoAuto merge of #9559 - c410-f3r:arith, r=Alexendoo
bors [Mon, 3 Oct 2022 21:54:08 +0000 (21:54 +0000)]
Auto merge of #9559 - c410-f3r:arith, r=Alexendoo

Fix #9544

Fix #9544

r? `@Alexendoo`

changelog: [`arithmetic_side_effects`]: Fix false negative for `CustomType / usize`, `CustomType * float` and similar

21 months agoAddress comments
Caio [Mon, 3 Oct 2022 21:36:12 +0000 (18:36 -0300)]
Address comments

21 months agoAuto merge of #9581 - ebobrow:mul-add-negative, r=Manishearth
bors [Mon, 3 Oct 2022 17:12:10 +0000 (17:12 +0000)]
Auto merge of #9581 - ebobrow:mul-add-negative, r=Manishearth

`suboptimal_flops` lint for multiply and subtract

fixes #9526

changelog: [`suboptimal_flops`] lint for multiply and subtract

21 months agoAuto merge of #9549 - royrustdev:manual_saturating_add, r=llogiq
bors [Mon, 3 Oct 2022 11:32:06 +0000 (11:32 +0000)]
Auto merge of #9549 - royrustdev:manual_saturating_add, r=llogiq

new `implicit_saturating_add` lint

This fixes #9393

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- \[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: add [`manual_saturating_add`] lint

21 months agoadd `implicit_saturating_add` lint
royrustdev [Wed, 28 Sep 2022 14:17:13 +0000 (19:47 +0530)]
add `implicit_saturating_add` lint

21 months agoAuto merge of #9580 - TennyZhuang:upper_case_acronyms-enum, r=llogiq
bors [Mon, 3 Oct 2022 09:01:05 +0000 (09:01 +0000)]
Auto merge of #9580 - TennyZhuang:upper_case_acronyms-enum, r=llogiq

let `upper_case_acronyms` check the enum name

Signed-off-by: TennyZhuang <zty0826@gmail.com>
Fix #9579

changelog: [`upper_case_acronyms`]: check the enum name

21 months agoMerge branch 'master' into mul-add-negative
Elliot Bobrow [Mon, 3 Oct 2022 04:27:57 +0000 (21:27 -0700)]
Merge branch 'master' into mul-add-negative

21 months ago`suboptimal_flops` lint for multiply and subtract
Elliot Bobrow [Mon, 3 Oct 2022 04:00:51 +0000 (21:00 -0700)]
`suboptimal_flops` lint for multiply and subtract

21 months agolet upper_case_acronyms check the enum name
TennyZhuang [Mon, 3 Oct 2022 02:11:57 +0000 (10:11 +0800)]
let upper_case_acronyms check the enum name

Signed-off-by: TennyZhuang <zty0826@gmail.com>
21 months agoAuto merge of #8762 - Jarcho:visitor, r=Jarcho
bors [Mon, 3 Oct 2022 00:05:05 +0000 (00:05 +0000)]
Auto merge of #8762 - Jarcho:visitor, r=Jarcho

Replace `expr_visitor` with  `for_each_expr`

This is a minor change which uses `ControlFlow` rather than a boolean. This also runs the visitor rather than returning the visitor, which results in a small readability win as well.

changelog: None

21 months agoWorkaround rustc bug
Jason Newcomb [Sun, 2 Oct 2022 21:11:10 +0000 (17:11 -0400)]
Workaround rustc bug

21 months agoUse `for_each_expr` in place of some visitors
Jason Newcomb [Fri, 29 Apr 2022 04:09:55 +0000 (00:09 -0400)]
Use `for_each_expr` in place of some visitors

21 months agoReplace `expr_visitor` with `for_each_expr`
Jason Newcomb [Thu, 28 Apr 2022 17:29:44 +0000 (13:29 -0400)]
Replace `expr_visitor` with `for_each_expr`

21 months agoAuto merge of #7962 - Jarcho:fix_match_type_on_diagnostic_items, r=llogiq
bors [Sun, 2 Oct 2022 19:46:46 +0000 (19:46 +0000)]
Auto merge of #7962 - Jarcho:fix_match_type_on_diagnostic_items, r=llogiq

Fix and improve `match_type_on_diagnostic_item`

This extracts the fix for the lint out of #7647. There's still a couple of other functions to check, but at least this will get lint working again.

The two added util functions (`is_diagnostic_item` and `is_lang_item`) are needed to handle `DefId` for unit and tuple struct/variant constructors. The `rustc_diagnostic_item` and `lang` attributes are attached to the struct/variant `DefId`, but most of the time they are used through their constructors which have a different `DefId`. The two utility functions will check if the `DefId` is for a constructor and switch to the associated struct/variant `DefId`.

There does seem to be a bug on rustc's side where constructor `DefId`s from external crates seem to be returning `DefKind::Variant` instead of `DefKind::Ctor()`. There's a workaround put in right.

changelog: None

21 months agofallout: fix tests to allow uninlined_format_args
Yuri Astrakhan [Sun, 2 Oct 2022 19:13:22 +0000 (15:13 -0400)]
fallout: fix tests to allow uninlined_format_args

In order to switch `clippy::uninlined_format_args` from pedantic to
style, all existing tests must not raise a warning. I did not want to
change the actual tests, so this is a relatively minor change that:

* add `#![allow(clippy::uninlined_format_args)]` where needed
* normalizes all allow/deny/warn attributes
   * all allow attributes are grouped together
   * sorted alphabetically
   * the `clippy::*` attributes are listed separate from the other ones.
   * deny and warn attributes are listed before the allowed ones

changelog: none

21 months agoAuto merge of #9574 - Alexendoo:unused-fixed, r=Jarcho
bors [Sun, 2 Oct 2022 19:06:58 +0000 (19:06 +0000)]
Auto merge of #9574 - Alexendoo:unused-fixed, r=Jarcho

Remove unused `.fixed` files, only run asm_syntax doctests on x86

Two small changes, removes some unused `.fixed` and makes `clippy_lints` doctests pass on non x86 arches

changelog: none