]> git.lizzy.rs Git - rust.git/log
rust.git
19 months agoMigrate from highfive to triagebot
Eric Huss [Mon, 24 Oct 2022 23:33:53 +0000 (16:33 -0700)]
Migrate from highfive to triagebot

20 months agoAuto merge of #8437 - est31:let_else_lint, r=flip1995
bors [Mon, 24 Oct 2022 20:21:08 +0000 (20:21 +0000)]
Auto merge of #8437 - est31:let_else_lint, r=flip1995

Add lint to tell about let else pattern

Adds a lint to tell the user if the let_else pattern should be used.

~~The PR is blocked probably on rustfmt support, as clippy shouldn't suggest features that aren't yet fully supported by all tools.~~ Edit: I guess adding it as a restriction lint for now is the best option, it can be turned into a style lint later.

---

changelog: addition of a new lint to check for manual `let else`

20 months agoAlso consider match guards for divergence check
est31 [Sun, 16 Oct 2022 01:56:40 +0000 (03:56 +0200)]
Also consider match guards for divergence check

Plus, add some tests for the divergence check.

20 months agoFix dogfooding
est31 [Tue, 11 Oct 2022 22:04:09 +0000 (00:04 +0200)]
Fix dogfooding

20 months agoDon't fire the lint if there is a type annotation
est31 [Mon, 10 Oct 2022 19:51:24 +0000 (21:51 +0200)]
Don't fire the lint if there is a type annotation

Sometimes type annotations are needed for type inferrence to work,
or because of coercions. We don't know this, and we also don't
want users to possibly repeat the entire pattern.

20 months agoDon't lint if the let is already a let-else
oxalica [Mon, 10 Oct 2022 14:00:33 +0000 (16:00 +0200)]
Don't lint if the let is already a let-else

We cannot apply the lint for 3-branches like in the added example.

20 months agoMake an attempt of creating suggestions
est31 [Mon, 10 Oct 2022 05:17:04 +0000 (07:17 +0200)]
Make an attempt of creating suggestions

They aren't perfect but better than nothing

20 months agoMake the match checking configurable
est31 [Sat, 8 Oct 2022 00:50:30 +0000 (02:50 +0200)]
Make the match checking configurable

20 months agoReplace from_different_macros with equivalent and simpler check
est31 [Thu, 6 Oct 2022 21:07:58 +0000 (23:07 +0200)]
Replace from_different_macros with equivalent and simpler check

20 months agoDon't suggest let else in match if the else arm explicitly mentions non obvious paths
est31 [Sat, 19 Feb 2022 06:15:20 +0000 (07:15 +0100)]
Don't suggest let else in match if the else arm explicitly mentions non obvious paths

20 months agoSupport tuples
est31 [Fri, 18 Feb 2022 04:43:48 +0000 (05:43 +0100)]
Support tuples

20 months agoAlso support linting for match
est31 [Wed, 16 Feb 2022 01:10:42 +0000 (02:10 +0100)]
Also support linting for match

20 months agoAdd lint to tell about let else pattern
est31 [Sun, 13 Feb 2022 02:11:06 +0000 (03:11 +0100)]
Add lint to tell about let else pattern

20 months agoAuto merge of #9541 - Alexendoo:declare-proc-macro, r=flip1995
bors [Sun, 23 Oct 2022 22:18:04 +0000 (22:18 +0000)]
Auto merge of #9541 - Alexendoo:declare-proc-macro, r=flip1995

Generate lint categories and explanations with `declare_clippy_lint`

This means contributors will no longer have to run `cargo dev update_lints` after changing a lints documentation or its category, which may also mean fewer merge conflicts in general

It works by swapping `declare_clippy_lint` out for a `proc_macro` of the same name. The proc macro emits a `LintInfo` alongside the generated `Lint` which are gathered into `declared_lint::LINTS`. The categories/explanations are then read from `declared_lint::LINTS` at runtime

The removal of `src/docs` is split into a separate commit to be more easily ignored

It is slightly slower though, adding a bit under a second to build time. Less noticeable in full builds or with a slower linker (benchmark uses mold)

```bash
hyperfine --warmup 2 \
    --parameter-list commit "declare-proc-macro,master" \
    --command-name "{commit}" \
    --setup "git checkout {commit}" \
    --prepare "touch clippy_lints/src/lib.rs" \
    "cargo build"
```
```
Benchmark 1: declare-proc-macro
  Time (mean ± σ):     10.731 s ±  0.154 s    [User: 7.739 s, System: 1.791 s]
  Range (min … max):   10.598 s … 11.125 s    10 runs

Benchmark 2: master
  Time (mean ± σ):      9.422 s ±  0.094 s    [User: 7.183 s, System: 1.732 s]
  Range (min … max):    9.287 s …  9.624 s    10 runs

Summary
  'master' ran
    1.14 ± 0.02 times faster than 'declare-proc-macro'
```

r? `@flip1995`
cc `@llogiq` for `--explain`

changelog: none

20 months agoRemove `src/docs`
Alex Macleod [Sun, 23 Oct 2022 20:32:40 +0000 (20:32 +0000)]
Remove `src/docs`

20 months agoGenerate lint categories and explanations with `declare_clippy_lint`
Alex Macleod [Sun, 23 Oct 2022 20:32:26 +0000 (20:32 +0000)]
Generate lint categories and explanations with `declare_clippy_lint`

Changes it to be a proc_macro rather than macro_rules

20 months agoAuto merge of #9690 - royrustdev:boxed_void, r=flip1995
bors [Sun, 23 Oct 2022 17:17:32 +0000 (17:17 +0000)]
Auto merge of #9690 - royrustdev:boxed_void, r=flip1995

add `from_raw_with_void_ptr` lint

This PR `fixes #9679`

- \[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:  [`from_raw_with_void_ptr`]: added new lint

20 months agoadd `boxed_void` lint
royrustdev [Sat, 22 Oct 2022 10:03:12 +0000 (15:33 +0530)]
add `boxed_void` lint

20 months agoAuto merge of #9368 - nahuakang:improve-equatable-if-let, r=flip1995
bors [Sun, 23 Oct 2022 15:31:46 +0000 (15:31 +0000)]
Auto merge of #9368 - nahuakang:improve-equatable-if-let, r=flip1995

Improvement for  `equatable_if_let`

fixes #9221

This PR makes sure that enums or structs not implementing `PartialEq` trait but still using the `if let` patterns can be linted to be rewritten with `matches!`.

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

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

---

changelog: Improve [`equatable_if_let`] with additional `matches!` suggestions.

20 months agoAuto merge of #9630 - CatDevz:fix-aawr-lint, r=flip1995
bors [Sun, 23 Oct 2022 15:08:47 +0000 (15:08 +0000)]
Auto merge of #9630 - CatDevz:fix-aawr-lint, r=flip1995

Fix allow_attributes_without_reason applying to external crate macros

Previously the `clippy::allow_attributes_without_reason` lint would apply to external crate macros. Many macros in the Rust ecosystem include these `allow` attributes without adding a reason, making this lint pretty much unusable in any sizable Rust project.

This commit fixes that by adding a check to the lint if the attribute is from an external crate macro and returning early.

```
changelog: [`allow_attributes_without_reason`]: allow_attributes_without_reason no longer applies to external crate macros
```

20 months agoAuto merge of #9689 - koka831:fix/or_fun_call_map_or, r=flip1995
bors [Sun, 23 Oct 2022 14:23:08 +0000 (14:23 +0000)]
Auto merge of #9689 - koka831:fix/or_fun_call_map_or, r=flip1995

fix: support `map_or` for `or_fun_call` lint

fixes https://github.com/rust-lang/rust-clippy/issues/8993

The methods defined in `KNOW_TYPES`, except for `map_or`, accepts only one argument, so the matching `if let [arg] = args` works only for these methods.
This PR adds `rest_arg` argument to `check_general_case` method and handling of cases with two arguments to support `map_or`.

changelog: `or_fun_call` support `map_or`

* add `rest_arg` to pass second argument from `map_or(U, F)`
* extract some procedures into closure

20 months agofix: support `map_or` for `or_fun_call` lint
koka [Sat, 22 Oct 2022 07:36:36 +0000 (16:36 +0900)]
fix: support `map_or` for `or_fun_call` lint

* add `rest_arg` to pass second argument from `map_or(U, F)`
* extract some procedures into closure

refac: rename rest_arg/second_arg

refac: organize function argument order

* put `second_arg` next to `arg` argument

20 months agoAuto merge of #9697 - Alexendoo:let-underscore-uplift, r=flip1995
bors [Sun, 23 Oct 2022 14:11:38 +0000 (14:11 +0000)]
Auto merge of #9697 - Alexendoo:let-underscore-uplift, r=flip1995

Mark `let_underscore_lock` and `let_underscore_drop` as uplifted

Here I've renamed both the uplifted lints, however rustc's `let_underscore_lock` is slightly less capable than the clippy lint as it doesn't catch `parking_lot` types or `Result<Guard, ..>`, should we still remove it? The `Result` change looks like it was unintentional to me so that could probably be fixed upstream

changelog: Uplift [`let_underscore_drop`] to rustc https://github.com/rust-lang/rust/pull/97739
changelog: Remove overlap between rustc's `let_underscore_lock` and Clippy's [`let_underscore_lock`]

r? `@flip1995`

20 months agoRemove overlap between rustc and clippy `let_underscore_lock` lint
Alex Macleod [Sun, 23 Oct 2022 14:04:50 +0000 (14:04 +0000)]
Remove overlap between rustc and clippy `let_underscore_lock` lint

20 months agoMark `let_underscore_drop` as uplifted
Alex Macleod [Sun, 23 Oct 2022 13:45:26 +0000 (13:45 +0000)]
Mark `let_underscore_drop` as uplifted

20 months agoAuto merge of #9654 - alex-semenyuk:enable_test, r=Alexendoo
bors [Sun, 23 Oct 2022 13:35:20 +0000 (13:35 +0000)]
Auto merge of #9654 - alex-semenyuk:enable_test, r=Alexendoo

Enable test no_std_main_recursion

Verified that test actually works on windows
changelog: none

20 months agoAuto merge of #9686 - kraktus:unwrap_in_test_cfg, r=flip1995
bors [Sun, 23 Oct 2022 13:23:38 +0000 (13:23 +0000)]
Auto merge of #9686 - kraktus:unwrap_in_test_cfg, r=flip1995

[`unwrap_used`], [`expect_used`] do not lint in `test` cfg

changelog: [`unwrap_used`], [`expect_used`] do not lint in `test` cfg

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

I've updated the doc and used `cfg` acronym, not sure if `conditional compiler flag` would have been better

20 months agoAuto merge of #9622 - llogiq:box-dyn-default, r=Alexendoo
bors [Sun, 23 Oct 2022 11:15:19 +0000 (11:15 +0000)]
Auto merge of #9622 - llogiq:box-dyn-default, r=Alexendoo

fix `box-default` ignoring trait objects' types

This avoids removing the turbofish when the `Box` type is a `dyn` or `impl _`.

This fixes #9621.

---

changelog: none

20 months agoAuto merge of #9688 - Alexendoo:msrv-tests, r=Manishearth
bors [Sun, 23 Oct 2022 05:05:23 +0000 (05:05 +0000)]
Auto merge of #9688 - Alexendoo:msrv-tests, r=Manishearth

Move MSRV tests into the lint specific test files

There are currently two ways MSRV tests are done in the ui test suite, adding a case to the `#![clippy::msrv = "1.0"]` `tests/ui/min_rust_version_attr.rs` or adding the two `msrv_1_xx` functions to the test file of the lint in question

This updates the clippy book to suggest the `msrv_1_xx` style, and replaces the tests in `tests/ui/min_rust_version_attr.rs` with ones of that style

Almost the entire diff is just moving stuff around as a result, I made sure to check the line numbers the lints are emitted at correspond with the right `msrv` case, so feel free to only skim that part

changelog: none

20 months agoExplicitly mention [cfg(test)]
kraktus [Sat, 22 Oct 2022 19:07:05 +0000 (21:07 +0200)]
Explicitly mention [cfg(test)]

Co-authored-by: llogiq <bogusandre@gmail.com>
20 months agoAuto merge of #9691 - smoelius:lint-lintcheck, r=llogiq
bors [Sat, 22 Oct 2022 18:42:12 +0000 (18:42 +0000)]
Auto merge of #9691 - smoelius:lint-lintcheck, r=llogiq

Add `lintcheck` to packages linted by `dogfood` test

Currently, `lintcheck` is not checked by the `dogfood` test. I assume that is not intentional. If it is intentional, then this PR can be ignored.

changelog: Add `lintcheck` to packages linted by `dogfood` test

20 months agoApply manual fixes
Samuel Moelius [Sat, 22 Oct 2022 11:12:07 +0000 (07:12 -0400)]
Apply manual fixes

20 months agoApply `--fix` fixes
Samuel Moelius [Sat, 22 Oct 2022 11:37:23 +0000 (07:37 -0400)]
Apply `--fix` fixes

20 months agoAdd `lintcheck` to packages linted by `dogfood` test
Samuel Moelius [Sat, 22 Oct 2022 11:37:10 +0000 (07:37 -0400)]
Add `lintcheck` to packages linted by `dogfood` test

20 months agoMove MSRV tests into the lint specific test files
Alex Macleod [Fri, 21 Oct 2022 21:35:39 +0000 (21:35 +0000)]
Move MSRV tests into the lint specific test files

20 months agoAuto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
bors [Fri, 21 Oct 2022 20:19:30 +0000 (20:19 +0000)]
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet

`ref_option_ref` do not lint when inner reference is mutable

changelog: FP: [`ref_option_ref`]: No longer lints if the inner reference is mutable

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

20 months agoAuto merge of #9685 - kraktus:collapsible_match, r=llogiq
bors [Fri, 21 Oct 2022 19:27:35 +0000 (19:27 +0000)]
Auto merge of #9685 - kraktus:collapsible_match, r=llogiq

[`collapsible_match`] specify field name when destructuring structs

changelog: [`collapsible_match`] specify field name when destructuring structs

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

I wasn't the sure about the best way to convey the message in the lint message since it does not use suggestion. Because I liked the former output highlighting both spans, I've left it as before, only modifying the span label.

20 months ago[`unwrap_used`], [`expect_used`] do not lint in `test` cfg
kraktus [Fri, 21 Oct 2022 13:27:25 +0000 (15:27 +0200)]
[`unwrap_used`], [`expect_used`] do not lint in `test` cfg

20 months ago[`collapsible_match`] specify field name when destructuring structs
kraktus [Fri, 21 Oct 2022 12:51:13 +0000 (14:51 +0200)]
[`collapsible_match`] specify field name when destructuring structs

20 months ago`ref_option_ref` do not lint when inner reference is mutable
kraktus [Fri, 21 Oct 2022 11:48:41 +0000 (13:48 +0200)]
`ref_option_ref` do not lint when inner reference is mutable

As it makes the `Option` Non Copy

20 months agoAuto merge of #9635 - smoelius:fix-9386-bug, r=Jarcho
bors [Thu, 20 Oct 2022 15:18:31 +0000 (15:18 +0000)]
Auto merge of #9635 - smoelius:fix-9386-bug, r=Jarcho

Fix bug introduced by #9386

#9386 introduced a potential out-of-bounds array access. Specifically, a location returned by `local_assignments` could have  [`location.statement_index` equal to `mir.basic_blocks[location.block].statements.len()`](https://github.com/rust-lang/rust-clippy/blob/b8a9a507bf9e3149d287841454842116c72d66c4/clippy_utils/src/mir/mod.rs#L129), in which case the location would refer to the block terminator:
https://github.com/rust-lang/rust-clippy/blob/b8a9a507bf9e3149d287841454842116c72d66c4/clippy_lints/src/dereference.rs#L1204-L1206
I suspect the bug is not triggerable now, because of checks leading up to where it occurs. But a future code change could make it triggerable. Hence, it should be fixed.

r? `@Jarcho`

changelog: none

20 months agoAuto merge of #9670 - Alexendoo:missing-trait-methods, r=Jarcho
bors [Thu, 20 Oct 2022 15:05:06 +0000 (15:05 +0000)]
Auto merge of #9670 - Alexendoo:missing-trait-methods, r=Jarcho

Add `missing_trait_methods` lint

Closes #9661

changelog: new lint: [`missing_trait_methods`]

20 months agoAuto merge of #9680 - flip1995:rustup, r=flip1995
bors [Thu, 20 Oct 2022 14:43:03 +0000 (14:43 +0000)]
Auto merge of #9680 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

I ran out of time and will have to do the Clippy->Rust sync tomorrow.

changelog: none

20 months agoBump nightly version -> 2022-10-20
Philipp Krones [Thu, 20 Oct 2022 14:39:44 +0000 (16:39 +0200)]
Bump nightly version -> 2022-10-20

20 months agoMerge remote-tracking branch 'upstream/master' into rustup
Philipp Krones [Thu, 20 Oct 2022 14:39:27 +0000 (16:39 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

20 months agoAdd `missing_trait_methods` lint
Alex Macleod [Mon, 17 Oct 2022 21:59:27 +0000 (21:59 +0000)]
Add `missing_trait_methods` lint

20 months agoAuto merge of #9634 - royrustdev:fix_redundant_allocation, r=Manishearth
bors [Wed, 19 Oct 2022 13:58:48 +0000 (13:58 +0000)]
Auto merge of #9634 - royrustdev:fix_redundant_allocation, r=Manishearth

Update Applicability of `redundant_allocation` lint from `MachineApplicable` to `MaybeIncorrect`

This changes `redundant_allocation` lint from MachineApplicable to MaybeIncorrect

```
changelog: [`redundant_allocation]: Change Applicability from MachineApplicable to MaybeIncorrect

```

fixes #6243

---
changelog: [`redundant_allocation`]: Change Applicability from MachineApplicable to MaybeIncorrect

20 months agoUpdate Applicability of `redundant_allocation` lint from
royrustdev [Wed, 12 Oct 2022 12:31:08 +0000 (18:01 +0530)]
Update Applicability of `redundant_allocation` lint from
`MachineApplicable` to `Unspecified`

20 months agoAuto merge of #9637 - Alexendoo:unused-format-specs, r=xFrednet
bors [Mon, 17 Oct 2022 11:51:32 +0000 (11:51 +0000)]
Auto merge of #9637 - Alexendoo:unused-format-specs, r=xFrednet

Add `unused_format_specs` lint

Currently catches two cases:

An empty precision specifier:

```rust
// the same as {}
println!("{:.}", x);
```

And using formatting specs on `format_args!()`:

```rust
// prints `x.`, not `x    .`
println("{:5}.", format_args!("x"));
```

changelog: new lint: [`unused_format_specs`]

20 months agoAdd `unused_format_specs` lint
Alex Macleod [Thu, 13 Oct 2022 12:13:54 +0000 (12:13 +0000)]
Add `unused_format_specs` lint

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 agoEnable test no_std_main_recursion
alex-semenyuk [Sat, 15 Oct 2022 20:52:40 +0000 (23:52 +0300)]
Enable test no_std_main_recursion

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 agoRemove CastCheckResult since it's unused
Michael Goulet [Wed, 14 Sep 2022 23:42:25 +0000 (23:42 +0000)]
Remove CastCheckResult since it's unused

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

20 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

20 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.

20 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

20 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

20 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

20 months agoFix bug in `referent_used_exactly_once`
Samuel Moelius [Tue, 11 Oct 2022 23:41:44 +0000 (19:41 -0400)]
Fix bug in `referent_used_exactly_once`

20 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

20 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.

20 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

20 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`

20 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

20 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

20 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

20 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

20 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

20 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`]