Commit graph

13272 commits

Author SHA1 Message Date
Jason Newcomb
e4f45c22e2 Fix ICE in ptr_arg 2022-02-01 15:05:20 -05:00
bors
7bb69c0ae0 Auto merge of #8369 - Jarcho:ptr_arg_8366, r=flip1995
Don't lint `ptr_arg` for `&mut _` types in trait items

fixes #8366

changelog: Don't lint `ptr_arg` for `&mut _` types in trait items
2022-01-31 15:17:38 +00:00
bors
0ed8ca45f4 Auto merge of #8322 - jubnzv:8282-single-match, r=llogiq
single_match: Don't lint non-exhaustive matches; support tuples

`single_match` lint:
* Don't lint exhaustive enum patterns without a wild.
  Rationale: The definition of the enum could be changed, so the user can get non-exhaustive match after applying the suggested lint (see https://github.com/rust-lang/rust-clippy/issues/8282#issuecomment-1013566068 for context).
* Lint `match` constructions with tuples (as suggested at https://github.com/rust-lang/rust-clippy/issues/8282#issuecomment-1015621148)

Closes #8282

---

changelog: [`single_match`]: Don't lint exhaustive enum patterns without a wild.
changelog: [`single_match`]: Lint `match` constructions with tuples
2022-01-30 22:00:36 +00:00
Jason Newcomb
66bb7263b5 Don't lint ptr_arg for &mut _ types in trait items 2022-01-29 12:03:54 -05:00
bors
7ceffdee9b Auto merge of #8289 - jubnzv:unspecified-layout-union, r=camsteffen
Add `default_union_representation` lint

Closes #8235

changelog: Added a new lint  [`default_union_representation`]
2022-01-29 10:58:16 +00:00
Georgy Komarov
b7000b2a53 Add default_union_representation lint
Closes #8235
2022-01-29 07:02:28 +03:00
bors
8d5d9e0103 Auto merge of #8250 - pr2502:fix_repeat_underflow, r=giraffate
Fix underflow in `manual_split_once` lint

Hi, a friend found clippy started crashing on a suspiciously large allocation of `u64::MAX` memory on their code.

The mostly minimized repro is:
```rust
fn _f01(title: &str) -> Option<()> {
    let _ = title[1..].splitn(2, '[').next()?;
    Some(())
}
```

The underflow happens in this case on line 57 of the patch but I've changed the other substraction to saturating as well since it could potentially cause the same issue.

I'm not sure where to put a regression test, or if it's even worth for such a thing.

Aside, has it been considered before to build clippy with overflow checks enabled?

changelog: fix ICE of underflow in `manual_split_once` lint
2022-01-28 13:31:51 +00:00
bors
fb94992c39 Auto merge of #8354 - dswij:8345, r=giraffate
Update docs for `map_flatten` on `Option` case

closes #8345

changelog: [`map_flatten`] Add docs info for `Option` case
2022-01-28 05:11:09 +00:00
dswij
515ed80b9d Update docs for map_flatten on Option 2022-01-28 12:00:30 +08:00
max
23fd95a5e9 fix underflow in check_manual_split_once lint 2022-01-27 17:54:40 +01:00
bors
a98e7ab8b9 Auto merge of #8359 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-01-27 13:48:23 +00:00
flip1995
b96e76869d
Bump nightly version -> 2022-01-27 2022-01-27 14:23:42 +01:00
flip1995
d037b28025
Merge remote-tracking branch 'upstream/master' into rustup 2022-01-27 14:23:31 +01:00
bors
ea4db3a6c6 Auto merge of #8350 - dswij:8331, r=Manishearth
fix bad suggestion on `numeric_literal`

closes #8331

changelog: [`numeric_literal`]  fix suggestion not showing sign
2022-01-26 19:19:28 +00:00
Georgy Komarov
a8fdf5ca8a matches: Remove extra comment 2022-01-26 19:50:27 +03:00
Georgy Komarov
467a0bfdea matches: Restore match_type logic; add tests for these cases 2022-01-26 18:20:35 +03:00
Georgy Komarov
81015870df matches: Improve naming. NFC. 2022-01-26 18:02:32 +03:00
Georgy Komarov
4aee3b1f1e matches: Clarify the behavior of exhaustive check 2022-01-26 14:46:48 +03:00
Georgy Komarov
5416a71dae Merge remote-tracking branch 'origin/master' into 8282-single-match 2022-01-26 14:16:15 +03:00
Dharma Saputra Wijaya
0d7273fef6 fix bad suggestion on numeric_literal 2022-01-26 15:02:13 +08:00
bors
02516c47ab Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot
Store a `Symbol` instead of an `Ident` in `AssocItem`

This is the same idea as #92533, but for `AssocItem` instead
of `VariantDef`/`FieldDef`.

With this change, we no longer have any uses of
`#[stable_hasher(project(...))]`
2022-01-25 18:53:45 +00:00
bors
a26c412e28 Auto merge of #8343 - robjtede:patch-1, r=giraffate
Autofocus search input

changelog: autofocus filter input on Clippy Lints page
2022-01-25 13:08:10 +00:00
Rob Ede
a8e1352d78
Autofocus search input 2022-01-25 00:15:11 +00:00
bors
60d3597cd2 Auto merge of #8315 - dswij:8306, r=giraffate
`trait_duplication_in_bounds` checks path segments for trait items

closes #8306

changelog: [`trait_duplication_in_bounds`] Fix FP when path segments exists for trait items
2022-01-24 00:03:40 +00:00
bors
d976d8ad87 Auto merge of #8311 - dswij:8277, r=llogiq
fix `needless_question_mark` not considering async fn

closes #8277

changelog: [`needless_question_mark`] Fix FN on async functions
2022-01-23 12:59:52 +00:00
dswij
a05276620c fix needless_question_mark not considering async fn 2022-01-23 20:31:27 +08:00
Vadim Petrochenkov
aee89cdff1 Update clippy 2022-01-23 19:31:32 +08:00
Vadim Petrochenkov
245d559a90 rustc_lint: Reuse the set of registered tools from resolver 2022-01-23 18:51:51 +08:00
bors
788a8bc740 Auto merge of #8217 - Jarcho:needless_borrow_8191, r=camsteffen
Fix `needless_borrow` causing mutable borrows to be moved

fixes #8191

changelog: Fix `needless_borrow` causing mutable borrows to be moved
changelog: Rename `ref_in_deref` to `needless_borrow`
changelog: Suggest removing the borrow on method call receivers in `needless_borrow`
2022-01-23 03:01:39 +00:00
Jason Newcomb
c61514086d Subsume ref_in_deref into needless_borrow 2022-01-22 21:22:33 -05:00
Jason Newcomb
9e9110e4f3 Remove final reference on fields and method calls in needless_borrow 2022-01-22 20:35:32 -05:00
bors
1e546c5d79 Auto merge of #8278 - Alexendoo:needless-lifetime-explicit-self-ty, r=xFrednet
`needless_lifetimes`: ignore lifetimes in explicit self types

changelog: false positive fix: [`needless_lifetimes`] no longer lints lifetimes in explicit self types

They're not currently elidable (https://github.com/rust-lang/rust/issues/69064)

Fixes #7296
2022-01-22 13:00:39 +00:00
Alex Macleod
9ef6e2199c needless_lifetimes: ignore lifetimes in explicit self types 2022-01-22 12:27:57 +00:00
bors
acfc161fa6 Auto merge of #8332 - Jarcho:clear_test_results, r=camsteffen
Don't bless outdated files on windows

changelog: None
2022-01-22 04:49:41 +00:00
Jason Newcomb
7ed29c0051 Don't bless outdated files on windows 2022-01-21 23:13:09 -05:00
bors
4992548f28 Auto merge of #8271 - Jarcho:ptr_arg_214, r=flip1995
Check usages in `ptr_arg`

fixes #214
fixes #1981
fixes #3381
fixes #6406
fixes #6964

This does not take into account the return type of the function currently, so `(&Vec<_>) -> &Vec<_>` functions may still be false positives.

The name given for the type also has to match the real type name, so `type Foo = Vec<u32>` won't trigger the lint, but `type Vec = Vec<u32>` will. I'm not sure if this is the best way to handle this, or if a note about the actual type should be added instead.

changelog: Check if the argument is used in a way which requires the original type in `ptr_arg`
changelog: Lint mutable references in `ptr_arg`
2022-01-21 15:43:57 +00:00
Jason Newcomb
15c068ed0f Fix needless_borrow causing mutable borrows to be moved 2022-01-21 09:50:11 -05:00
Jason Newcomb
048297b5b2 ptr_arg cleanup 2022-01-21 09:43:41 -05:00
Cameron Steffen
82f613ee3b Remove a span from hir::ExprKind::MethodCall 2022-01-21 07:48:10 -06:00
bors
f4709e6f1d Auto merge of #8329 - Alexendoo:enum-variant-names, r=giraffate
Don't suggest an empty variant name in `enum_variant_names`

changelog: false positive fix: [`enum_variant_names`]: No longer suggests an empty variant name

Fixes #8324
2022-01-21 13:37:18 +00:00
Alex Macleod
7c563175c7 Don't suggest an empty variant name in enum_variant_names 2022-01-21 13:10:19 +00:00
bors
ec00cf80a3 Auto merge of #91359 - dtolnay:args, r=Mark-Simulacrum
Emit simpler code from format_args

I made this PR so that `cargo expand` dumps a less overwhelming amount of formatting-related code.

<br>

`println!("rust")` **Before:**

```rust
{
    ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"],
                                                     &match () {
                                                          _args => [],
                                                      }));
};
```

**After:**

```rust
{ ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &[])); };
```

`println!("{}", x)` **Before:**

```rust
{
    ::std::io::_print(::core::fmt::Arguments::new_v1(
        &["", "\n"],
        &match (&x,) {
            _args => [::core::fmt::ArgumentV1::new(
                _args.0,
                ::core::fmt::Display::fmt,
            )],
        },
    ));
};
```

**After:**

```rust
{
    ::std::io::_print(::core::fmt::Arguments::new_v1(
        &["", "\n"],
        &[::core::fmt::ArgumentV1::new(&x, ::core::fmt::Display::fmt)],
    ));
};
```
2022-01-21 06:20:18 +00:00
Georgy Komarov
49ae73b450 matches: Simplify code 2022-01-21 07:28:40 +03:00
Georgy Komarov
a0c5087520 single_match: Clarify the don't lint test case 2022-01-21 07:28:26 +03:00
Georgy Komarov
a5a07e503f single_match: Don't lint non-exhaustive matches; support tuples
This commit changes the behavior of `single_match` lint.

After that, we won't lint non-exhaustive matches like this:

```rust
match Some(v) {
    Some(a) => println!("${:?}", a),
    None => {},
}
```

The rationale is that, because the type of `a` could be changed, so the
user can get non-exhaustive match after applying the suggested lint (see
https://github.com/rust-lang/rust-clippy/issues/8282#issuecomment-1013566068
for context).

We also will lint `match` constructions with tuples. When we see the
tuples on the both arms, we will check them both at the same time, and
if they form exhaustive match, we could display the warning.

Closes #8282
2022-01-20 15:14:25 +03:00
dswij
4c1549ecc8 trait_duplication_in_bounds checks path segments for trait items 2022-01-20 13:38:48 +08:00
Aaron Hill
a35c1e7c84 Store a Symbol instead of an Ident in AssocItem
This is the same idea as #92533, but for `AssocItem` instead
of `VariantDef`/`FieldDef`.

With this change, we no longer have any uses of
`#[stable_hasher(project(...))]`
2022-01-19 17:13:21 -05:00
bors
8bb4690487 Auto merge of #8280 - xFrednet:8276-map-clone-msrv, r=flip1995
Add `msrv` config for `map_clone`

Just a small PR to have some fun with Clippy and to clear my head a bit 😅

---

changelog: [`map_clone`]: The suggestion takes `msrv` into account
changelog: Track `msrv` attribute for `manual_bits` and `borrow_as_prt`

fixes: #8276
2022-01-19 16:33:10 +00:00
bors
0b143e347c Auto merge of #8304 - camsteffen:test-tweaks, r=flip1995
Remove __CLIPPY_INTERNAL_TESTS env var

changelog: none

It doesn't have any effect AFAICT.
2022-01-19 08:55:40 +00:00
bors
16032c53c9 Auto merge of #8310 - camelid:rm-stringification, r=Manishearth
Remove unnecessary `Symbol` stringification

This should (slightly) improve performance and enhance code quality.

changelog: none
2022-01-19 01:23:15 +00:00