Commit graph

6829 commits

Author SHA1 Message Date
blyxyas
e2742a0ea2
Fix double_must_use for async functions 2023-04-03 01:27:53 +02:00
bors
7fe83edc11 Auto merge of #10588 - blyxyas:fix-allow_nonminimal_bool, r=llogiq
Fix `nonminimal_bool` `#[allow]` attributes.

Closes #10435
changelog: [`nonminimal_bool`]: Fix false-positive where the lint ignore `#[allow]` attributes.

r? `@llogiq`
2023-04-02 22:12:46 +00:00
bors
8f0ba1f2e0 Auto merge of #10563 - nyurik:handle-all-fmt2, r=llogiq
Partial no-op refactoring of #9948

This contains some prep work for #9948 to keep that change to the minimum, and make it easier to review it.

This should be a noop, but it has some tests from that PR discussion, and should help in the future with the corner case format handling.

cc: `@Alexendoo` `@llogiq` `@xFrednet`  as the 3 people who reviewed the parent PR

----

changelog: none
2023-04-02 17:08:20 +00:00
blyxyas
36047b0216
Fix nonminimal_bool #[allow] attributes. 2023-04-02 16:18:03 +02:00
Caio
05650b7215 [arithmetic_side_effects] Fix #10583 2023-04-02 07:50:25 -03:00
bors
ac4838c554 Auto merge of #10534 - samueltardieu:lines-filter-map-ok, r=llogiq
Flag `bufreader.lines().filter_map(Result::ok)` as suspicious

This lint detects a problem that happened recently in https://github.com/uutils/coreutils and is described in https://github.com/rust-lang/rust/issues/64144.

changelog: [`lines_filter_map_ok`]: new lint
2023-04-01 12:41:08 +00:00
bors
29987062d9 Auto merge of #10536 - mkrasnitski:suggestions, r=flip1995
Add suggestions to `extra_unused_type_parameters`

Change the `extra_unused_type_parameters` lint to provide machine applicable suggestions rather than just help messages. Exception to this are cases when any unused type parameters appear bounded in where clauses - for now I've deemed these cases unfixable and separated them out. Future work might be able to provide suggestions in these cases.

Also, added a test case for the `avoid_breaking_exported_api` config option.

r? `@flip1995`

changelog: [`extra_unused_type_parameters`]: Now provides fixable suggestions.
2023-03-31 16:16:36 +00:00
Samuel "Sam" Tardieu
6601d85c22 Flag bufreader.lines().filter_map(Result::ok) as suspicious 2023-03-31 14:43:30 +02:00
Alex Macleod
17f80456d1 Ignore file!() macro in print_literal, write_literal 2023-03-30 16:20:04 +00:00
bors
799732cbd8 Auto merge of #10414 - csmoe:large-future, r=xFrednet
add large future lint

Closes #5263

---

changelog: new lint: [`large_futures`]
[#10414](https://github.com/rust-lang/rust-clippy/pull/10414)
<!-- changelog_checked -->
2023-03-30 08:51:29 +00:00
bors
ef3867f394 Auto merge of #9102 - botahamec:unused-box, r=xFrednet
Added the `[unnecessary_box_returns]` lint

fixes #5

I'm not confident in the name of this lint. Let me know if you can think of something better

---

changelog: New lint: ``[`unnecessary_box_returns`]``
[#9102](https://github.com/rust-lang/rust-clippy/pull/9102)
<!-- changelog_checked -->
2023-03-30 08:22:16 +00:00
bors
c5011e9d42 Auto merge of #10553 - Nilstrieb:better-uninit, r=Alexendoo
In uninit checking, add fallback for polymorphic types

After #10520, we always assumed that polymorphic types do not allow to be left uninitialized. But we can do better, by peeking into polymorphic types and adding a few special cases for going through tuples, arrays (because the length may be polymorphic) and blanket allowing all unions (like MaybeUninit).

fixes #10551

changelog: [uninit_vec]: fix false positive for polymorphic types
changelog: [uninit_assumed_init]: fix false positive for polymorphic types
2023-03-29 18:26:35 +00:00
Nilstrieb
51b4d2a1e8 In uninit checking, add fallback for polymorphic types 2023-03-29 19:46:44 +02:00
csmoe
4f5a019d6e Update clippy_lints/src/large_futures.rs
Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
2023-03-29 08:47:32 +00:00
Yuri Astrakhan
783879e6fe Partial no-op refactoring of #9948
This contains preparatory work for #9948 to keep that change to the
minimum, and make it easier to review it.
2023-03-28 21:08:06 -04:00
bors
84e42fb363 Auto merge of #10484 - Alexendoo:format-args-ast-2, r=Manishearth
Migrate `format_args.rs` to `rustc_ast::FormatArgs`

changelog: none

Part of https://github.com/rust-lang/rust-clippy/issues/10233

Empty precision specifiers are no longer linted as the span for that isn't present in [`FormatOptions`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/format/struct.FormatOptions.html)

```rust
format!("{:.}", ...)
```

That could be fixed later with some hackery or a change upstream

r? `@flip1995`
2023-03-28 18:33:02 +00:00
bors
d9821e1d9d Auto merge of #10542 - Alexendoo:items-after-statements, r=giraffate
Fix allow attribute, items from macros in `items_after_statements`

Fixes #10540

changelog: [`items_after_statements`]: Fixes `#[allow(clippy::items_after_statements)]` when applied to an item, and ignores items after statements from different macro contexts
2023-03-28 13:21:14 +00:00
Alex Macleod
3259b48568 Migrate format_args.rs to rustc_ast::FormatArgs
No longer lints empty precisions `{:.}` as the spans aren't available
2023-03-28 12:22:22 +00:00
bluthej
df65d21f4c Include tests where the iterator is used later 2023-03-27 11:11:40 +02:00
Micha White
76d13bb7fa
Don't lint functions with "box" in their name 2023-03-26 17:49:57 -04:00
Micha White
a143fb7a11
Avoid breaking exported API 2023-03-26 17:49:57 -04:00
Micha White
1b55c81db5
Lint on trait declarations, not implementations 2023-03-26 17:49:56 -04:00
Micha White
022f76d432
Added the new lint with some docs and tests 2023-03-26 17:49:46 -04:00
bluthej
3966580c9d Add tests with usize::MIN 2023-03-26 19:12:37 +02:00
bluthej
ee0de538d4 Add some tests 2023-03-26 19:12:36 +02:00
bluthej
1d168b31c3
Merge branch 'rust-lang:master' into clear-with-drain 2023-03-26 19:11:38 +02:00
bors
5ed64d4c61 Auto merge of #10496 - J-ZhengLi:issue_10366, r=Alexendoo
fix [`cast_possible_truncation`] offering wrong suggestion for casting float to integer

fixes: #10366

---

changelog: [`cast_possible_truncation`] Fix incorrect suggestions when casting from float types or to `_`
2023-03-25 13:11:46 +00:00
bors
f1b9105f87 Auto merge of #10454 - Alexendoo:transmutes-expressible-as-ptr-casts-parens, r=Jarcho
Wrap `transmutes_expressible_as_ptr_casts` suggestions in parentheses

changelog: [`transmutes_expressible_as_ptr_casts`]: Fix suggestion missing wrapping parentheses

Fixes #10449

r? `@Jarcho`

Is this the best way to go about this? `unused_parens` will catch the unnecessary ones but emitting them in the first place isn't ideal
2023-03-25 02:29:54 +00:00
J-ZhengLi
52c4dc65d9 fix [cast_possible_truncation] offering wrong suggestion when casting from float
suggest `try_into` when casting to wildcard type;
fix [`cast_possible_truncation`] suggesting useless parenthesis;

remove suggesting for float to float conversion in [`cast_possible_truncation`]

style nit
2023-03-25 09:26:43 +08:00
Alex Macleod
b13f99c7e7 Fix allow attribute, items from macros in items_after_statements 2023-03-24 15:33:14 +00:00
Philipp Krones
62cba5d971
Merge remote-tracking branch 'upstream/master' into rustup 2023-03-24 13:36:09 +01:00
Michael Krasnitski
50d92d0b60 Add suggestions to extra_unused_type_parameters 2023-03-23 23:56:31 -04:00
bors
c72c914d21 Auto merge of #10489 - samueltardieu:issue-10476, r=giraffate
New lint: detect unnecessary struct building

Fixes #10476.

Running this lint on the top 500 crates produced one hit (in `rust-lang/rust-bindgen`) and [a PR has been submitted there](https://github.com/rust-lang/rust-bindgen/pull/2440).

changelog: [`unnecessary_struct_initialization`]: new lint
2023-03-24 00:12:02 +00:00
Samuel "Sam" Tardieu
d7d3dbf060 New lint: detect unnecessary struct building 2023-03-23 20:56:45 +01:00
Alex Macleod
ecc201253e Wrap transmutes_expressible_as_ptr_casts suggestions in parentheses 2023-03-23 18:58:10 +00:00
bors
1d1e72308e Auto merge of #10527 - samueltardieu:issue-10523, r=dswij
Do not propose to simplify a not expression coming from a macro

Fixes #10523

changelog: FP [`nonminimal_bool`]: do not propose to change code coming from a macro
2023-03-22 15:46:08 +00:00
bluthej
d56c941792
Merge branch 'rust-lang:master' into clear-with-drain 2023-03-22 11:15:23 +01:00
bluthej
e8ec242a61 Finish tests - add rustfix 2023-03-22 11:01:57 +01:00
bluthej
1d0acce984 Add test for partial range 2023-03-22 11:01:57 +01:00
bluthej
589d7e1ab4 Add tests to cover all cases 2023-03-22 11:01:57 +01:00
bors
583962150b Auto merge of #10490 - samueltardieu:issue-10482, r=xFrednet
Do not propose to remove `async move` if variables are captured by ref

Fixes #10482

changelog: FP [`redundant_async_block`] Do not propose to remove `async move` if variables are captured by ref
2023-03-22 08:19:39 +00:00
Samuel "Sam" Tardieu
b138bb587b Do not propose to simplify a not expression coming from a macro 2023-03-22 01:12:52 +01:00
Samuel "Sam" Tardieu
349708655e Do not propose to remove async move if variables are captured by ref 2023-03-22 00:29:17 +01:00
bluthej
7f44530f54 Create clear_with_drain lint 2023-03-21 22:51:51 +01:00
bors
6cebe58dfe Auto merge of #10526 - samueltardieu:dogfood-clippy, r=flip1995
Really dogfood clippy

The dogfood success condition was inverted in `tests/dogfood.rs`:

```rust
  assert!(!failed_packages.is_empty(), …);
```

while instead the `failed_packages` collection must be empty:

```rust
  assert!(failed_packages.is_empty(), …);
```

And indeed, several clippy lint source files were not clean and had to be fixed in the process.

changelog: none
2023-03-21 21:04:37 +00:00
Samuel "Sam" Tardieu
728ee6f8cd Really dogfood clippy
The dogfood success condition was inverted in `tests/dogfood.rs`:

```rust
  assert!(!failed_packages.is_empty(), …);
```

while instead the `failed_packages` collection must be empty:

```rust
  assert!(failed_packages.is_empty(), …);
```

And indeed, several clippy lint source files were not clean and had to be
fixed in the process.
2023-03-21 22:00:58 +01:00
Nilstrieb
84b6049eb9 Use uninit checking from rustc
rustc has proper heuristics for actually checking whether a type allows
being left uninitialized (by asking CTFE). We can now use this for our
helper instead of rolling our own bad version with false positives.
2023-03-21 18:28:06 +01:00
csmoe
4fdae81c70 add large future lint 2023-03-20 22:51:01 +08:00
bors
e64c5961dc Auto merge of #10456 - samueltardieu:issue-10450, r=Manishearth
Issue function modifiers in the right order in manual_async_fn lint

Fixes #10450

changelog: [`manual_async_fn`] output function modifiers in correct order
2023-03-18 15:19:27 +00:00
bors
d3c8442d4d Auto merge of #10483 - samueltardieu:issue-10480, r=llogiq
New lint to detect `&std::path::MAIN_SEPARATOR.to_string()`

Fixes #10480

changelog: [`manual_main_separator_str`] new lint
2023-03-17 13:49:53 +00:00