Commit graph

16480 commits

Author SHA1 Message Date
blyxyas
a37eb4dfc9
Fix false negative on Result<(), ()> 2023-04-03 16:07:17 +02:00
blyxyas
d602743558
only focus on double_must_use + Add Result<(), ()> test 2023-04-03 15:16:18 +02:00
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
bors
8d83c15d20 Auto merge of #10585 - c410-f3r:aaaaaaaaaaaa, r=Jarcho
[arithmetic_side_effects] Fix #10583

Fixes #10583

```
changelog: [`arithmetic_side_effects`]: Correctly handle division and module when the right-hand-side is unknown
```
2023-04-02 16:39:38 +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
bors
89160b6de2 Auto merge of #10487 - nyurik:readme-fixes, r=dswij
Gramar, and spelin kleanup

A few minor cleanups in various markdown files, mostly focusing on spelling and ignoring non-compilable codeblocks. Also a few markdown tables, etc.

P.S. I'm no grammar expert, do take with a grain of salt.

changelog: none
2023-03-31 08:11:41 +00:00
Yuri Astrakhan
41b367fa5f Gramar, and spelin kleanup
A few minor cleanups in various markdown files, mostly focusing on spelling and ignoring non-compilable codeblocks.
2023-03-30 15:31:14 -04:00
bors
d43714a101 Auto merge of #10573 - Alexendoo:print-literal-file-macro, r=Jarcho
Ignore `file!()` macro in `print_literal`, `write_literal`

changelog: [`print_literal`], [`write_literal`]: Ignore the `file!()` macro

`file!()` expands to a string literal with its span set to that of the `file!()` callsite, but isn't marked as coming from an expansion. To fix this we make sure we actually find a string/char literal instead of assuming it's one and slicing

It would also ignore any other macros that result in the same situation, but that shouldn't be common as `proc_macro::Span::call_site()` returns a span that is marked as from expansion

Fixes #10544
2023-03-30 16:38:50 +00: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
xFrednet
6e87ae0f1a
Run metadata collection 2023-03-30 10:49:29 +02: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
58fb801414 Auto merge of #10561 - Alexendoo:format-args-ast-3, r=Manishearth
Replace remaining usage of `FormatArgsExpn`

Closes #10233

Removes `FormatArgsExpn` & friends now that they're unused

changelog: none

r? `@Manishearth`
2023-03-28 21:43:15 +00:00
Alex Macleod
6589d79492 Replace remaining usage of FormatArgsExpn 2023-03-28 21:28:57 +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
bors
70db22648b Auto merge of #10528 - bluthej:clear-with-drain, r=llogiq
Clear with drain

changelog: [`clear_with_drain`]: Add new lint

Fixes #9339
2023-03-27 11:41:48 +00:00
bluthej
df65d21f4c Include tests where the iterator is used later 2023-03-27 11:11:40 +02:00
bors
5698f43f94 Auto merge of #10552 - Alexendoo:unnecessary-struct-initialization-nursery, r=flip1995
Move unnecessary_struct_initialization to nursery

changelog: none, assuming it makes into the same release as #10489

Mostly because of #10547 but there is also #10548
2023-03-27 09:11:05 +00: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
2493be2196 Improve is_range_full implementation
Make this function work with signed integer types by extracting the
underlying type and finding the min and max values.

Change the signature to make it more consistent:
- The range is now given as an `Expr` in order to extract the type
- The container's path is now passed, and only as an `Option` so that
  the function can be called in the general case without a container
2023-03-26 19:12:36 +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
Alex Macleod
a6f56cbdba Move unnecessary_struct_initialization to nursery 2023-03-26 14:21:58 +00: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
27edc2af06 Auto merge of #10531 - Nilstrieb:linklink, r=giraffate
Add explanation on how to run `cargo-clippy` and `clippy-driver`

I don't know how this would be done on Windows or MacOS, feedback appreciated.

I did find this snippet for MacOS but it seems a little sketchy.

1d1e72308e/.github/workflows/clippy_bors.yml (L98-L102)

changelog: none
2023-03-25 03:30:44 +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
bors
ed6c15a64b Auto merge of #10541 - FixedThink:patch-1, r=llogiq
docs fix: unknown field `allowed-locales`

changelog: [`DISALLOWED_SCRIPT_IDENTS`]: Replace the nonexistent `allowed-locales` in the docs with `allowed-scripts`.
2023-03-24 22:33:05 +00:00
Nilstrieb
b782a071ad Add explanation on how to run cargo-clippy and clippy-driver 2023-03-24 16:26:22 +00:00
Alex Macleod
b13f99c7e7 Fix allow attribute, items from macros in items_after_statements 2023-03-24 15:33:14 +00:00
FixedThink
982c81ad28
docs fix: unknown field allowed-locales
changelog: fix: Replace the nonexistent `allowed-locales` in the `DISALLOWED_SCRIPT_IDENTS` docs with `allowed-scripts`.
2023-03-24 16:08:27 +01:00
bors
00e9372987 Auto merge of #10516 - Alexendoo:split-debuginfo, r=flip1995
Use `split-debuginfo = "unpacked"` for debug builds

On Windows this has no effect as it's unsupported. On macOS the default set by cargo is already unpacked so no effect there either

For Linux it shaves a bit off the rebuild time, for me in the case of a simple `touch` + `cargo build` it goes from 12s to 10s

It saves a good amount of disk space too, on `aarch64-unknown-linux-gnu` it saves 1.2GB for a plain `cargo build`, 3GB when also running `cargo dev` and `cargo test --no-run -F internal`

r? `@flip1995`

changelog: none
2023-03-24 12:53:04 +00:00
bors
d5e2a7aca5 Auto merge of #10539 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`
changelog: none
2023-03-24 12:40:28 +00:00
Philipp Krones
8134414e03
Bump nightly version -> 2023-03-24 2023-03-24 13:36:15 +01:00