Commit graph

6819 commits

Author SHA1 Message Date
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
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
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
bors
5c4040e9bb Auto merge of #10502 - blyxyas:fix-almost_swapped, r=giraffate
fix `almost_swapped`: Ignore external macros

Fixes #10421 ; Related to #10499 (Fixing points *1* and *3* from #10421)
changelog: [`almost_swapped`]: Add a check to ignore external macros
2023-03-17 00:03:45 +00:00
Samuel "Sam" Tardieu
ffabdab8cf New lint to detect &std::path::MAIN_SEPARATOR.to_string() 2023-03-16 21:42:04 +01:00
blyxyas
9546517a84
Add external macro test + Now it works 2023-03-16 20:22:39 +01:00
Samuel Tardieu
afe27ba1a2 Issue function modifiers in the right order in manual_async_fn lint 2023-03-16 18:59:14 +01:00
bors
5afa93bd8e Auto merge of #10481 - blyxyas:allow_attribute, r=xFrednet
Add `allow_attribute` lint

Fixes #10468

changelog: new lint: [`allow_attributes`]
[#10481](https://github.com/rust-lang/rust-clippy/pull/10481)
2023-03-16 10:18:19 +00:00
blyxyas
4b9cb857f9
Rename lint 2023-03-15 23:18:25 +01:00
blyxyas
e2ba75d69d
Add macro test 2023-03-15 16:27:46 +01:00
bors
c465bf7f67 Auto merge of #10499 - blyxyas:fix-almost_swapped, r=giraffate
Fix `almost_swapped` false positive (`let mut a = b; a = a`)

Fixes `2` in #10421
changelog: [`almost_swapped`]: Fix false positive when a variable is changed to itself. (`a = a`)
2023-03-14 13:30:21 +00:00
bors
491f63214a Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errors
Remove `identity_future` indirection

This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm.

Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation.

Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-14 10:12:58 +00:00
bors
ff843ac9ae Auto merge of #10350 - J-ZhengLi:issue_10272, r=xFrednet
enhance [`ifs_same_cond`] to warn same immutable method calls as well

fixes: #10272

---

changelog: Enhancement: [`ifs_same_cond`]: Now also detects immutable method calls.
[#10350](https://github.com/rust-lang/rust-clippy/pull/10350)
<!-- changelog_checked -->
2023-03-14 08:16:58 +00:00