]> git.lizzy.rs Git - rust.git/log
rust.git
21 months agoAuto merge of #9501 - xFrednet:changelog-1.64, r=llogiq
bors [Thu, 22 Sep 2022 12:10:53 +0000 (12:10 +0000)]
Auto merge of #9501 - xFrednet:changelog-1.64, r=llogiq

Changelog for Rust 1.64 :apple:

The normal release preparation dance. I've written the changelog like the version has already been released. The PR can be approved and then merged by anyone after the release of Rust 1.64 :upside_down_face:

---

changelog: none

21 months agoAuto merge of #9471 - jplatte:patch-1, r=xFrednet
bors [Wed, 21 Sep 2022 12:56:19 +0000 (12:56 +0000)]
Auto merge of #9471 - jplatte:patch-1, r=xFrednet

Add matches! checking to nonstandard_macro_braces

changelog: Enhancement: [`nonstandard_macro_braces`]: Now includes `matches!()` in the default lint config
  [#9471](https://github.com/rust-lang/rust-clippy/pull/9471)

21 months agoAuto merge of #9505 - mikerite:fix-9504-2, r=dswij
bors [Wed, 21 Sep 2022 05:53:36 +0000 (05:53 +0000)]
Auto merge of #9505 - mikerite:fix-9504-2, r=dswij

Fix ICE in `unnecessary_to_owned`

Fixes #9504

Compiler generated call `into_future` nodes return empty substs which we need when checking it's predicates. Handle this by simply exitting when we encounter one. This change introduces false negatives in place of the ICEs.

changelog: [`unnecessary_to_owned`]: fix ICE

21 months agoFix ICE in `unnecessary_to_owned`
Michael Wright [Wed, 21 Sep 2022 05:02:52 +0000 (07:02 +0200)]
Fix ICE in `unnecessary_to_owned`

Fixes #9504

Compiler generated call `into_iter` nodes return empty substs
which we need when checking it's predicates. Handle this by
simply exitting when we encounter one. This change introduces
false negatives in place of the ICEs.

21 months agoAuto merge of #9502 - c410-f3r:arith, r=Alexendoo
bors [Tue, 20 Sep 2022 16:14:54 +0000 (16:14 +0000)]
Auto merge of #9502 - c410-f3r:arith, r=Alexendoo

[arithmetic-side-effects] Add more tests

Taken from the `integer-arithmetic` lint.

changelog: [arithmetic-side-effects] Add more tests

21 months ago[arithmetic_side_effects] Add more tests
Caio [Tue, 20 Sep 2022 15:06:49 +0000 (12:06 -0300)]
[arithmetic_side_effects] Add more tests

21 months agoChangelog for Rust 1.64 :apple:
xFrednet [Tue, 20 Sep 2022 10:14:18 +0000 (12:14 +0200)]
Changelog for Rust 1.64 :apple:

21 months agoAuto merge of #9483 - c410-f3r:arith, r=Jarcho
bors [Mon, 19 Sep 2022 14:35:14 +0000 (14:35 +0000)]
Auto merge of #9483 - c410-f3r:arith, r=Jarcho

[arithmetic-side-effects] Finish non-overflowing ops

Extends https://github.com/rust-lang/rust-clippy/pull/9474 to also take into consideration "raw" binary operations. For example, `let a = b / 2` and `let a = 1 * b` won't trigger the lint.

changelog: [arithmetic-side-effects] Finish non-overflowing ops

21 months agoAdd matches! checking to nonstandard_macro_braces
Jonas Platte [Tue, 13 Sep 2022 10:08:17 +0000 (12:08 +0200)]
Add matches! checking to nonstandard_macro_braces

21 months agoAuto merge of #9488 - Alexendoo:unused, r=llogiq
bors [Sat, 17 Sep 2022 09:29:17 +0000 (09:29 +0000)]
Auto merge of #9488 - Alexendoo:unused, r=llogiq

Add `#[allow(unused)]` to test in `cargo dev new_lint`

`rustfix` tests don't automatically apply `-Aunused` which leads to some tests having `_workarounds`, add it to new test files automatically so people don't have to worry about it

changelog: none

21 months agoAdd `#[allow(unused)]` to test in `cargo dev new_lint`
Alex Macleod [Fri, 16 Sep 2022 21:04:38 +0000 (21:04 +0000)]
Add `#[allow(unused)]` to test in `cargo dev new_lint`

21 months agoChange method's name
Caio [Fri, 16 Sep 2022 20:01:29 +0000 (17:01 -0300)]
Change method's name

21 months agoAuto merge of #9409 - DesmondWillowbrook:iter_kv_map, r=xFrednet
bors [Fri, 16 Sep 2022 08:44:58 +0000 (08:44 +0000)]
Auto merge of #9409 - DesmondWillowbrook:iter_kv_map, r=xFrednet

Add `iter_kv_map` lint

fixes #9376

| before | after |
| -------------- | ------------------------- |
| `hmap.iter().map(\|(key, _)\| key)` | `hmap.keys()` |
| `hmap.iter().map(\|(_, v)\| v + 2)` | `hmap.values().map(\|v\| v + 2)` |
| `hmap.into_iter().map(\|(key, _)\| key)` | `hmap.into_keys()` |

Is `MachineApplicable`

changelog: [`iter_kv_map`]: added lint

21 months agoremove identity function tests
Kartavya Vashishtha [Fri, 16 Sep 2022 08:29:51 +0000 (13:59 +0530)]
remove identity function tests

21 months agoTypo
Caio [Thu, 15 Sep 2022 16:40:49 +0000 (13:40 -0300)]
Typo

21 months ago[arithmetic-side-effects] Finish non-overflowing ops
Caio [Thu, 15 Sep 2022 16:28:18 +0000 (13:28 -0300)]
[arithmetic-side-effects] Finish non-overflowing ops

21 months agoAuto merge of #9481 - giraffate:fix_indents, r=xFrednet
bors [Thu, 15 Sep 2022 09:03:59 +0000 (09:03 +0000)]
Auto merge of #9481 - giraffate:fix_indents, r=xFrednet

Fix indents

Markdowns are not displayed correctly.
https://github.com/rust-lang/rust-clippy/blob/master/book/src/development/common_tools_writing_lints.md#dealing-with-macros-and-expansions

changelog: none

21 months agoadded identity block test
Kartavya Vashishtha [Thu, 15 Sep 2022 04:16:01 +0000 (09:46 +0530)]
added identity block test

added binding annotations for all lines

21 months agoAdd iter_kv_map lint
Kartavya Vashishtha [Mon, 29 Aug 2022 18:39:25 +0000 (00:09 +0530)]
Add iter_kv_map lint

21 months agoFix indents
Takayuki Nakata [Thu, 15 Sep 2022 00:23:18 +0000 (09:23 +0900)]
Fix indents

21 months agoAuto merge of #9478 - Alexendoo:ra-docs, r=flip1995
bors [Wed, 14 Sep 2022 20:49:26 +0000 (20:49 +0000)]
Auto merge of #9478 - Alexendoo:ra-docs, r=flip1995

Update rust-analyzer documentation, mention linkedProjects

r-a uses the `rustc-dev` component from the rustup installed toolchain clippy specifies so it doesn't need to be manually installed. Also remove references to nightly r-a as the feature is long stable

I discovered `rust-analyzer.linkedProjects` recently and it has made working on the crates not referenced by the `clippy` crate so much nicer

changelog: none

21 months agoAuto merge of #9475 - Nemo157:mod-files-remap, r=xFrednet
bors [Wed, 14 Sep 2022 20:09:49 +0000 (20:09 +0000)]
Auto merge of #9475 - Nemo157:mod-files-remap, r=xFrednet

Make module-style lints resilient to --remap-path-prefix

changelog: [`self_named_module_files`], [`mod_module_files`]: Make module-style lints resilient to `--remap-path-prefix`

Without this if a user has configured `--remap-path-prefix` to be used for a prefix containing the current source directory the lints would silently fail to generate a warning.

21 months agoAuto merge of #9476 - Xaeroxe:bool-to-int-inverted, r=xFrednet
bors [Wed, 14 Sep 2022 19:56:12 +0000 (19:56 +0000)]
Auto merge of #9476 - Xaeroxe:bool-to-int-inverted, r=xFrednet

`bool_to_int_with_if` inverse case patch

Enhances `bool_to_int_with_if` such that it can also catch an inverse bool int conversion scenario, and makes the right suggestion for converting to int with a prefixed negation operator.

changelog: [`bool_to_int_with_if`]: Now correctly detects the inverse case, `if bool { 0 } else { 1 }`

21 months agofix: clippy_utils::Sugg should treat hir::ExprKind::DropTemps as transparent
Jacob Kiesel [Wed, 14 Sep 2022 19:29:32 +0000 (13:29 -0600)]
fix: clippy_utils::Sugg should treat hir::ExprKind::DropTemps as transparent

21 months agorefactor: use clippy_utils::Sugg instead of direct string ops
Jacob Kiesel [Wed, 14 Sep 2022 19:28:54 +0000 (13:28 -0600)]
refactor: use clippy_utils::Sugg instead of direct string ops

21 months agodogfood inverse bool_to_int_with_if
Jacob Kiesel [Wed, 14 Sep 2022 06:27:56 +0000 (00:27 -0600)]
dogfood inverse bool_to_int_with_if

21 months ago`bool_to_int_with_if` inverse case patch
Jacob Kiesel [Wed, 14 Sep 2022 05:50:47 +0000 (23:50 -0600)]
`bool_to_int_with_if` inverse case patch

21 months agoAuto merge of #8518 - Alexendoo:write-late-pass, r=flip1995
bors [Wed, 14 Sep 2022 15:58:21 +0000 (15:58 +0000)]
Auto merge of #8518 - Alexendoo:write-late-pass, r=flip1995

Migrate write.rs to a late pass

changelog: Migrates write.rs from a pre expansion pass to a late pass
changelog: [`positional_named_format_parameters`] is renamed in favour of the rustc lint `named_arguments_used_positionally`

- Macros are now identified by diagnostic items, so will no longer lint user defined macros named, e.g. a custom `print!`
- `print_literal`/`write_literal` no longer lint no longer lint literals that come from macro expansions, e.g. `env!("FOO")`
- `print_with_newline`/`write_with_newline` no longer lint strings with any internal `\r` or `\n`s

~~A false negative, `print_literal`/`write_literal` don't lint format strings that produce `FormatSpec`s, e.g. ones containing pretty print/width/align specifiers~~

Suggestion changes:
- ~~`print_literal`/`write_literal` no longer have suggestions, as the spans for the `{}`s were not easily obtainable~~
-  `print_with_newline`/`write_with_newline` has a better suggestion for a sole literal newline, but no longer has suggestions for len > 1 strings that end in a literal newline
- ~~`use_debug` spans are less precise, now point to the whole format string~~

The diff for write.rs is pretty unwieldy, other than for the `declare_clippy_lint!`s I think you'd be better off viewing it as a brand new file rather than looking at the diff, as it's mostly written from scratch

cc #6610, fixes #5721, fixes #7195, fixes #8615

21 months agoAuto merge of #9465 - Alexendoo:peekable-fp, r=flip1995
bors [Wed, 14 Sep 2022 15:03:39 +0000 (15:03 +0000)]
Auto merge of #9465 - Alexendoo:peekable-fp, r=flip1995

Fix `unused_peekable` closure and `f(&mut peekable)` false positives

changelog: Fix [`unused_peekable`] false positive when peeked in a closure or called as `f(&mut peekable)`

The `return`/`break` changes aren't part of the fix, they allow an earlier return in some cases. `break` is replaced with `return` for style purposes as they do the same thing in this case

Fixes #9456
Fixes #9462

21 months agoUpdate rust-analyzer documentation, mention linkedProjects
Alex Macleod [Wed, 14 Sep 2022 10:46:20 +0000 (10:46 +0000)]
Update rust-analyzer documentation, mention linkedProjects

21 months agoAuto merge of #9467 - pyhrr0:macro_expansion, r=giraffate
bors [Tue, 13 Sep 2022 23:45:29 +0000 (23:45 +0000)]
Auto merge of #9467 - pyhrr0:macro_expansion, r=giraffate

Fix `almost_complete_letter_range` false positive.

changelog: Fix [`almost_complete_letter_range`] false positive in an external macro

21 months agoMake module-style lints resilient to --remap-path-prefix
Wim Looman [Tue, 13 Sep 2022 19:27:01 +0000 (21:27 +0200)]
Make module-style lints resilient to --remap-path-prefix

21 months agoAuto merge of #9474 - c410-f3r:arith, r=llogiq
bors [Tue, 13 Sep 2022 19:00:24 +0000 (19:00 +0000)]
Auto merge of #9474 - c410-f3r:arith, r=llogiq

[arithmetic-side-effects] More non-overflowing ops

* Adding or Subtracting 0
* Division and Module of anything other than 0
* Multiplying 1 or 0

changelog: [arithmetic-side-effects] More non-overflowing operations

21 months ago[arithmetic-side-effects] More non-overflowing ops
Caio [Tue, 13 Sep 2022 18:50:24 +0000 (15:50 -0300)]
[arithmetic-side-effects] More non-overflowing ops

21 months agoAuto merge of #9429 - kraktus:deriv_ma, r=xFrednet
bors [Tue, 13 Sep 2022 16:43:04 +0000 (16:43 +0000)]
Auto merge of #9429 - kraktus:deriv_ma, r=xFrednet

Make `derivable_impls` machine applicable

changelog: [`derivable_impls`]: Now machine applicable

21 months agoMake `derivable_impls` machine applicable
kraktus [Mon, 5 Sep 2022 10:04:54 +0000 (12:04 +0200)]
Make `derivable_impls` machine applicable

21 months agoAuto merge of #9454 - kraktus:use_self, r=flip1995
bors [Tue, 13 Sep 2022 12:44:16 +0000 (12:44 +0000)]
Auto merge of #9454 - kraktus:use_self, r=flip1995

Do not lint `use_self` in proc macro expansion

fix https://github.com/rust-lang/rust-clippy/issues/9440
fix https://github.com/rust-lang/rust-clippy/issues/8910
fix https://github.com/rust-lang/rust-clippy/issues/6902

changelog: [`use_self`]: Do not lint in proc macro expansion

21 months agoAuto merge of #9452 - kraktus:doc, r=flip1995
bors [Tue, 13 Sep 2022 12:29:26 +0000 (12:29 +0000)]
Auto merge of #9452 - kraktus:doc, r=flip1995

Fix dev book

fix `implements_trait` and `in_external_macro` import path

Remove example using `match_trait_method` since its deprecated.

changelog: none

21 months agoOnly ignore external macros.
S. van Dijk [Tue, 13 Sep 2022 07:51:32 +0000 (09:51 +0200)]
Only ignore external macros.

21 months agoAuto merge of #9464 - lukaslueg:issue9463, r=dswij
bors [Mon, 12 Sep 2022 16:56:53 +0000 (16:56 +0000)]
Auto merge of #9464 - lukaslueg:issue9463, r=dswij

Don't panic on invalid shift while constfolding

Instead of panicking on invalid shifts while folding constants we simply give up. Fixes #9463

Notice the "attempt to shift right by `1316134912_u32`", which seems weird. AFAICS it comes from rustc itself.

changelog: none

21 months agoAuto merge of #9466 - lukaslueg:issue9460, r=dswij
bors [Mon, 12 Sep 2022 16:35:30 +0000 (16:35 +0000)]
Auto merge of #9466 - lukaslueg:issue9460, r=dswij

Don't lint `large_stack_array` inside static items

We now check if the linted `Expr` is inside an `ItemKind::Static`, which can't take the suggested `Box<[...]`. I _think_ this is the correct fix for #9460

I removed `if_chain` while I was at it.

changelog: Don't lint `large_stack_array` inside static items

21 months agoAuto merge of #9469 - Alexendoo:expr-field-visitor, r=giraffate
bors [Mon, 12 Sep 2022 13:58:53 +0000 (13:58 +0000)]
Auto merge of #9469 - Alexendoo:expr-field-visitor, r=giraffate

Fix FormatArgsExpn parsing of FormatSpec positions

Woops, forgot visitors don't walk themselves

Fixes #9468

r? `@giraffate`

changelog: none

21 months agoFix FormatArgsExpn parsing of FormatSpec positions
Alex Macleod [Mon, 12 Sep 2022 11:34:09 +0000 (11:34 +0000)]
Fix FormatArgsExpn parsing of FormatSpec positions

21 months agoAdd test.
S. van Dijk [Mon, 12 Sep 2022 08:44:44 +0000 (10:44 +0200)]
Add test.

21 months agoAuto merge of #9458 - Alexendoo:expr-field-visitor, r=giraffate
bors [Mon, 12 Sep 2022 00:21:28 +0000 (00:21 +0000)]
Auto merge of #9458 - Alexendoo:expr-field-visitor, r=giraffate

Use `visit_expr_field` for `ParamPosition`

A small change to make it a little simpler

changelog: none

21 months agoStop lint from checking code expanded from macros.
S. van Dijk [Sun, 11 Sep 2022 18:15:35 +0000 (20:15 +0200)]
Stop lint from checking code expanded from macros.

21 months agoAuto merge of #9410 - dswij:issue-9375, r=xFrednet
bors [Sun, 11 Sep 2022 15:10:00 +0000 (15:10 +0000)]
Auto merge of #9410 - dswij:issue-9375, r=xFrednet

Use macro callsite when creating `Sugg` helper

Closes #9375

changelog: Improvement: [`collapsible_if`]: Suggestions now work with macros, by taking the call site into account.

21 months agoDont lint `large_stack_array` inside static items
Lukas Lueg [Sun, 11 Sep 2022 14:24:33 +0000 (16:24 +0200)]
Dont lint `large_stack_array` inside static items

Fixes #9460

21 months agoFix `unused_peekable` closure and `f(&mut peekable)` false positives
Alex Macleod [Sun, 11 Sep 2022 12:17:51 +0000 (12:17 +0000)]
Fix `unused_peekable` closure and `f(&mut peekable)` false positives

21 months agoDon't panic on invalid shift while constfolding
Lukas Lueg [Sun, 11 Sep 2022 10:26:13 +0000 (12:26 +0200)]
Don't panic on invalid shift while constfolding

Fixes #9463

21 months agoAuto merge of #9457 - kraktus:nonminimal_bool, r=Manishearth
bors [Sat, 10 Sep 2022 19:11:08 +0000 (19:11 +0000)]
Auto merge of #9457 - kraktus:nonminimal_bool, r=Manishearth

Do not expand macro in `nonminimal_bool` suggestions

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

changelog: Do not expand macros in [`nonminimal_bool`] suggestions

21 months agoUse visit_expr_field for ParamPosition
Alex Macleod [Sat, 10 Sep 2022 18:32:05 +0000 (18:32 +0000)]
Use visit_expr_field for ParamPosition

21 months agoDo not expand macro in `nonminimal_bool` suggestions
kraktus [Sat, 10 Sep 2022 17:48:14 +0000 (19:48 +0200)]
Do not expand macro in `nonminimal_bool` suggestions

22 months agoAuto merge of #9453 - kraktus:a_on_re_state, r=Jarcho
bors [Sat, 10 Sep 2022 13:18:06 +0000 (13:18 +0000)]
Auto merge of #9453 - kraktus:a_on_re_state, r=Jarcho

[`assertions_on_result_states`]: Fix suggestion when `assert!` is not in a statement.

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

changelog: [`assertions_on_result_states`]: Fix suggestion when `assert!` is not in a statement.

22 months agoRemove duplicate context check
kraktus [Sat, 10 Sep 2022 09:47:07 +0000 (11:47 +0200)]
Remove duplicate context check

22 months agoDo not lint `use_self` in proc macro expansion
kraktus [Sat, 10 Sep 2022 09:36:31 +0000 (11:36 +0200)]
Do not lint `use_self` in proc macro expansion

22 months agorefactor: move `has_debug_impl` to `clippy_utils::ty`
kraktus [Sat, 10 Sep 2022 08:39:51 +0000 (10:39 +0200)]
refactor: move `has_debug_impl` to `clippy_utils::ty`

22 months ago`assertions_on_result_states` fix suggestion when `assert!` not in a statement
kraktus [Sat, 10 Sep 2022 08:30:19 +0000 (10:30 +0200)]
`assertions_on_result_states` fix suggestion when `assert!` not in a statement

22 months agoFix dev book
kraktus [Fri, 9 Sep 2022 20:43:19 +0000 (22:43 +0200)]
Fix dev book

fix `implements_trait` and `in_external_macro` import path

Remove example using `match_trait_method` since its deprecated

22 months agoAuto merge of #9448 - Alexendoo:large-enum-variant-u128, r=Manishearth
bors [Fri, 9 Sep 2022 17:21:53 +0000 (17:21 +0000)]
Auto merge of #9448 - Alexendoo:large-enum-variant-u128, r=Manishearth

Replace u128 with u64 in large_enum_variant uitest

A u128 has [an 8 byte alignment on x86](https://github.com/rust-lang/rust/issues/54341), but a 16 byte alignment on aarch64 which changes the size of the enums due to extra padding. This means the test fails on aarch64

changelog: none

22 months agoAuto merge of #9446 - mikerite:fix-9431-2, r=giraffate
bors [Thu, 8 Sep 2022 23:48:08 +0000 (23:48 +0000)]
Auto merge of #9446 - mikerite:fix-9431-2, r=giraffate

Fix `range_{plus,minus}_one` bad suggestions

Fixes #9431.

The current `range_plus_one` and `range_minus_one` suggestions are completely incorrect when macros are involved.

This commit resolves this by disabling the lints for any range expression that is expanded from a macro. The reasons for this are that it is very difficult to create a correct suggestion in this case and that false negatives are less important for pedantic lints.

changelog: Fix `range_{plus,minus}_one` bad suggestions

22 months agoReplace u128 with u64 in large_enum_variant uitest
Alex Macleod [Thu, 8 Sep 2022 20:42:03 +0000 (20:42 +0000)]
Replace u128 with u64 in large_enum_variant uitest

A u128 has an 8 byte alignment on x86, but a 16 byte alignment on
aarch64 which changes the size of the enums due to extra padding

22 months agoMigrate write.rs to a late pass
Alex Macleod [Tue, 30 Aug 2022 12:20:49 +0000 (12:20 +0000)]
Migrate write.rs to a late pass

22 months agoAuto merge of #9447 - flip1995:rustup, r=flip1995
bors [Thu, 8 Sep 2022 19:42:33 +0000 (19:42 +0000)]
Auto merge of #9447 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

22 months agoBump nightly version -> 2022-09-08
Philipp Krones [Thu, 8 Sep 2022 19:27:37 +0000 (21:27 +0200)]
Bump nightly version -> 2022-09-08

22 months agoMerge remote-tracking branch 'upstream/auto' into rustup
Philipp Krones [Thu, 8 Sep 2022 19:27:09 +0000 (21:27 +0200)]
Merge remote-tracking branch 'upstream/auto' into rustup

22 months agoFix `range_{plus,minus}_one` bad suggestions
Michael Wright [Thu, 8 Sep 2022 18:04:43 +0000 (20:04 +0200)]
Fix `range_{plus,minus}_one` bad suggestions

Fixes #9431.

The current `range_plus_one` and `range_minus_one` suggestions
are completely incorrect when macros are involved.

This commit resolves this by disabling the lints for any range
expression that is expanded from a macro. The reasons for this
are that it is very difficult to create a correct suggestion in
this case and that false negatives are less important for
pedantic lints.

22 months agoAuto merge of #9443 - c410-f3r:arith, r=flip1995
bors [Thu, 8 Sep 2022 17:58:57 +0000 (17:58 +0000)]
Auto merge of #9443 - c410-f3r:arith, r=flip1995

Rename the arithmetic lint

changelog: Rename the `arithmetic` lint

22 months agoAuto merge of #9444 - Alexendoo:lintcheck-cargo, r=matthiaskrgr
bors [Thu, 8 Sep 2022 16:50:52 +0000 (16:50 +0000)]
Auto merge of #9444 - Alexendoo:lintcheck-cargo, r=matthiaskrgr

Update cargo in lintcheck_crates.toml

0.49.0 depends on a version of socket2 that no longer builds due to

```
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
   --> /home/alex/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.3.11/src/sockaddr.rs:156:9
    |
156 |         mem::transmute::<SocketAddrV4, sockaddr_in>(v4);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: source type: `SocketAddrV4` (48 bits)
    = note: target type: `sockaddr_in` (128 bits)
```

changelog: none

22 months agoUpdate cargo in lintcheck_crates.toml
Alex Macleod [Thu, 8 Sep 2022 15:29:26 +0000 (15:29 +0000)]
Update cargo in lintcheck_crates.toml

22 months agoRename the `arithmetic` lint
Caio [Thu, 8 Sep 2022 15:04:55 +0000 (12:04 -0300)]
Rename the `arithmetic` lint

22 months agoAuto merge of #9365 - c410-f3r:arith, r=Alexendoo
bors [Wed, 7 Sep 2022 19:55:34 +0000 (19:55 +0000)]
Auto merge of #9365 - c410-f3r:arith, r=Alexendoo

[Arithmetic] Consider literals

Fixes https://github.com/rust-lang/rust-clippy/issues/9307 and makes the `arithmetic` lint behave like `integer_arithmetic`.

It is worth noting that literal integers of a binary operation (`1 + 1`, `i32::MAX + 1`), **regardless if they are in a constant environment**, won't trigger the lint. Assign operations also have similar reasoning.

changelog: Consider literals in the arithmetic lint

22 months agoAuto merge of #9441 - Jarcho:hang_9433, r=Alexendoo
bors [Wed, 7 Sep 2022 19:43:00 +0000 (19:43 +0000)]
Auto merge of #9441 - Jarcho:hang_9433, r=Alexendoo

Fix hang in `vec_init_then_push`

fixes #9433
changelog: Fix infinite loop in `vec_init_then_push`

22 months agoFix hang in `vec_init_then_push`
Jason Newcomb [Wed, 7 Sep 2022 19:26:44 +0000 (15:26 -0400)]
Fix hang in `vec_init_then_push`

22 months agoAuto merge of #101432 - nnethercote:shrink-PredicateS, r=lcnr
bors [Wed, 7 Sep 2022 13:49:58 +0000 (13:49 +0000)]
Auto merge of #101432 - nnethercote:shrink-PredicateS, r=lcnr

Shrink `PredicateS`

r? `@ghost`

22 months ago[Arithmetic] Consider literals
Caio [Wed, 7 Sep 2022 13:00:45 +0000 (10:00 -0300)]
[Arithmetic] Consider literals

22 months agoAuto merge of #9421 - xphoniex:fix-#9420, r=giraffate
bors [Tue, 6 Sep 2022 23:44:38 +0000 (23:44 +0000)]
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate

Suggest `unwrap_or_default` when closure returns `"".to_string`

Closes https://github.com/rust-lang/rust-clippy/issues/9420

changelog: [`unwrap_or_else_default`]: suggest `unwrap_or_default()` instead of `unwrap_or_else` with a closure that returns an empty `to_string`.

22 months agoGeneralize the Assume intrinsic statement to a general Intrinsic statement
Oli Scherer [Tue, 12 Jul 2022 10:05:00 +0000 (10:05 +0000)]
Generalize the Assume intrinsic statement to a general Intrinsic statement

22 months agoLower the assume intrinsic to a MIR statement
Oli Scherer [Thu, 30 Jun 2022 08:16:05 +0000 (08:16 +0000)]
Lower the assume intrinsic to a MIR statement

22 months agoSuggest `unwrap_or_default` when closure returns `"".to_string`
xphoniex [Tue, 6 Sep 2022 04:38:29 +0000 (04:38 +0000)]
Suggest `unwrap_or_default` when closure returns `"".to_string`

Signed-off-by: xphoniex <xphoniex@users.noreply.github.com>
22 months agoAuto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillot
bors [Tue, 6 Sep 2022 03:16:29 +0000 (03:16 +0000)]
Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillot

`BindingAnnotation` refactor

* `ast::BindingMode` is deleted and replaced with `hir::BindingAnnotation` (which is moved to `ast`)
* `BindingAnnotation` is changed from an enum to a tuple struct e.g. `BindingAnnotation(ByRef::No, Mutability::Mut)`
* Associated constants added for convenience `BindingAnnotation::{NONE, REF, MUT, REF_MUT}`

One goal is to make it more clear that `BindingAnnotation` merely represents syntax `ref mut` and not the actual binding mode. This was especially confusing since we had `ast::BindingMode`->`hir::BindingAnnotation`->`thir::BindingMode`.

I wish there were more symmetry between `ByRef` and `Mutability` (variant) naming (maybe `Mutable::Yes`?), and I also don't love how long the name `BindingAnnotation` is, but this seems like the best compromise. Ideas welcome.

22 months agoAuto merge of #101261 - TaKO8Ki:separate-receiver-from-arguments-in-hir, r=cjgillot
bors [Mon, 5 Sep 2022 16:21:40 +0000 (16:21 +0000)]
Auto merge of #101261 - TaKO8Ki:separate-receiver-from-arguments-in-hir, r=cjgillot

Separate the receiver from arguments in HIR

Related to #100232

cc `@cjgillot`

22 months agouse `propagate_through_exprs` instead of `propagate_through_expr`
Takayuki Maeda [Mon, 5 Sep 2022 05:26:00 +0000 (14:26 +0900)]
use `propagate_through_exprs` instead of `propagate_through_expr`

fix `ExprKind` static_assert_size

fix hir-stats

22 months agoAuto merge of #101228 - nnethercote:simplify-hir-PathSegment, r=petrochenkov
bors [Mon, 5 Sep 2022 13:36:54 +0000 (13:36 +0000)]
Auto merge of #101228 - nnethercote:simplify-hir-PathSegment, r=petrochenkov

Simplify `hir::PathSegment`

r? `@petrochenkov`

22 months agorefactor: remove unnecessary variables
Takayuki Maeda [Fri, 2 Sep 2022 13:48:14 +0000 (22:48 +0900)]
refactor: remove unnecessary variables

22 months agoseparate the receiver from arguments in HIR under /clippy
Takayuki Maeda [Thu, 1 Sep 2022 09:43:35 +0000 (18:43 +0900)]
separate the receiver from arguments in HIR under /clippy

22 months agoRollup merge of #101142 - nnethercote:improve-hir-stats, r=davidtwco
Dylan DPC [Mon, 5 Sep 2022 08:45:51 +0000 (14:15 +0530)]
Rollup merge of #101142 - nnethercote:improve-hir-stats, r=davidtwco

Improve HIR stats

#100398 improve the AST stats collection done by `-Zhir-stats`. This PR does the same for HIR stats collection.

r? `@davidtwco`

22 months agoPack `Term` in the same way as `GenericArg`.
Nicholas Nethercote [Mon, 5 Sep 2022 04:03:53 +0000 (14:03 +1000)]
Pack `Term` in the same way as `GenericArg`.

This shrinks the `PredicateS` type, which is instanted frequently.

22 months agoAuto merge of #9342 - relrelb:or_default, r=dswij
bors [Mon, 5 Sep 2022 04:54:31 +0000 (04:54 +0000)]
Auto merge of #9342 - relrelb:or_default, r=dswij

Suggest `Entry::or_default` for `Entry::or_insert(Default::default())`

Unlike past similar work done in #6228, expand the existing `or_fun_call`
lint to detect `or_insert` calls with a `T::new()` or `T::default()`
argument, much like currently done for `unwrap_or` calls. In that case,
suggest the use of `or_default`, which is more idiomatic.

Note that even with this change, `or_insert_with(T::default)` calls
aren't detected as candidates for `or_default()`, in the same manner
that currently `unwrap_or_else(T::default)` calls aren't detected as
candidates for `unwrap_or_default()`.

Also, as a nearby cleanup, change `KNOW_TYPES` from `static` to `const`,
since as far as I understand it's preferred (should Clippy have a lint
for that?).

Addresses #3812.

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

changelog: [`or_fun_call`]: Suggest `Entry::or_default` for `Entry::or_insert(Default::default())`

22 months agoMake `hir::PathSegment::res` non-optional.
Nicholas Nethercote [Tue, 30 Aug 2022 05:10:28 +0000 (15:10 +1000)]
Make `hir::PathSegment::res` non-optional.

22 months agoSuggest `Entry::or_default` for `Entry::or_insert(Default::default())`
relrelb [Tue, 16 Aug 2022 20:26:03 +0000 (23:26 +0300)]
Suggest `Entry::or_default` for `Entry::or_insert(Default::default())`

Unlike past similar work done in #6228, expand the existing `or_fun_call`
lint to detect `or_insert` calls with a `T::new()` or `T::default()`
argument, much like currently done for `unwrap_or` calls. In that case,
suggest the use of `or_default`, which is more idiomatic.

Note that even with this change, `or_insert_with(T::default)` calls
aren't detected as candidates for `or_default()`, in the same manner
that currently `unwrap_or_else(T::default)` calls aren't detected as
candidates for `unwrap_or_default()`.

Also, as a nearby cleanup, change `KNOW_TYPES` from `static` to `const`,
since as far as I understand it's preferred (should Clippy have a lint
for that?).

Fixes #3812.

22 months agoAuto merge of #9425 - kraktus:patch-1, r=xFrednet
bors [Sun, 4 Sep 2022 15:32:09 +0000 (15:32 +0000)]
Auto merge of #9425 - kraktus:patch-1, r=xFrednet

fix wording for `derivable_impls`

While looking at the explanation as to why this lint was not automatically applicable, found the explanation a bit clunky grammatically.

 Feel free to close if you consider the wording was correct in the first place.

changelog: none

22 months agofix wording for `derivable_impls`
kraktus [Sun, 4 Sep 2022 14:29:30 +0000 (16:29 +0200)]
fix wording for `derivable_impls`

22 months agoAuto merge of #9424 - mikerite:fix-9351-4, r=xFrednet
bors [Sun, 4 Sep 2022 15:14:58 +0000 (15:14 +0000)]
Auto merge of #9424 - mikerite:fix-9351-4, r=xFrednet

Fix `unnecessary_to_owned` false positive

Fixes #9351.

Note that this commit reworks that fix for #9317. The change
is to check that the type implements `AsRef<str>` before regarding
`to_string` as an equivalent of `to_owned`. This was suggested
by Jarcho in the #9317 issue comments.

The benefit of this is that it moves some complexity out of
`check_other_call_arg` and simplifies the module as a whole.

changelog: FP: [`unnecessary_to_owned`]: No longer lints, if type change would cause errors in the caller function

22 months agoFix `unnecessary_to_owned` false positive
Michael Wright [Sat, 3 Sep 2022 15:00:44 +0000 (17:00 +0200)]
Fix `unnecessary_to_owned` false positive

Fixes #9351.

Note that this commit reworks that fix for #9317. The change
is to check that the type implements `AsRef<str>` before regarding
`to_string` as an equivalent of `to_owned`. This was suggested
by Jarcho in the #9317 issue comments.

The benefit of this is that it moves some complexity out of
`check_other_call_arg` and simplifies the module as a whole.

22 months agoAuto merge of #9400 - lukaslueg:approx_large_enum, r=llogiq
bors [Sat, 3 Sep 2022 07:34:42 +0000 (07:34 +0000)]
Auto merge of #9400 - lukaslueg:approx_large_enum, r=llogiq

Use `approx_ty_size` for `large_enum_variant`

This builds upon #9373 to use the approximate size of each variant for `large_enum_variant`. This allows us to lint in situations where an `enum` contains generics but is still guaranteed to have a large variant on an at-least basis, e.g. with `(T, [u8; 512])`.

* I've changed the wording from "is ... bytes" to "contains at least" because
  * the size is now an approximate lower bound (e.g. `512` in the example above). The actual size is larger due to `T`, including due to `T`'s memory layout.
  * the discriminant is not taken into account in the message. This comes up with variants like `A(T)`, which are "is at least 0 bytes" otherwise, which may be misleading.
* If the second-largest variant has no fields, there is a special case "carries no data" instead of "is at least 0 bytes".
* A variant like `A(T)` is "at least 0 bytes", which is technically true, yet we don't distinguish between "indeterminate" and truly "ZST".
* The generics-tests that were there before now lint while they didn't lint before. AFAICS this is correct.

I guess the above is correct-ish. However, I use the `SubstsRef` that I got via `cx.tcx.type_of(item.def_id)` to solve for generics in the variants. Is this even applicable, since we start from an - [ ] `ItemKind`?

changelog: none

22 months agoUse `approx_ty_size` for `large_enum_variant`
Lukas Lueg [Tue, 30 Aug 2022 20:27:21 +0000 (22:27 +0200)]
Use `approx_ty_size` for `large_enum_variant`

22 months agoAuto merge of #8952 - rust-lang:explain, r=xFredNet
bors [Fri, 2 Sep 2022 20:27:42 +0000 (20:27 +0000)]
Auto merge of #8952 - rust-lang:explain, r=xFredNet

add `--explain` subcommand

This closes #8291.

---

changelog: add `cargo clippy -- --explain <lintname>` subcommand

22 months agoadd `--explain` subcommand
Andre Bogus [Sun, 5 Jun 2022 08:44:14 +0000 (10:44 +0200)]
add `--explain` subcommand

22 months agoAuto merge of #9418 - lukaslueg:issue9415, r=llogiq
bors [Fri, 2 Sep 2022 18:54:06 +0000 (18:54 +0000)]
Auto merge of #9418 - lukaslueg:issue9415, r=llogiq

Fix `mut_mutex_lock` when Mutex is behind immutable deref

I *think* the problem here is the `if let ty::Ref(_, _, Mutability::Mut) = cx.typeck_results().expr_ty(recv).kind()` line tries to check if the `Mutex` can be mutably borrowed (there already is a test for `Arc<Mutex<_>>`), but gets bamboozled by the `&mut Arc` indirection. And I *think* checking the deref-adjustment to filter immutable-adjust (the deref through the `Arc`, starting from `&mut Arc`) is the correct fix.

Fixes #9415

changelog: Fix `mut_mutex_lock` when Mutex is behind immutable deref