Commit Graph

18111 Commits

Author SHA1 Message Date
xFrednet
948355586f
sudo CI=green 2023-10-04 01:19:38 +02:00
xFrednet
8d920a8b03
Changelog for Rust 1.73 🖊️ 2023-10-04 01:09:46 +02:00
xFrednet
eab0a75ff9
Update version attribute for 1.73 lints 2023-10-04 01:08:45 +02:00
bors
b437069f59 Auto merge of #11603 - koka831:fix/11599, r=y21
Fix: avoid changing drop order

Fixes https://github.com/rust-lang/rust-clippy/issues/11599

changelog: [`redundant_locals`] No longer lints which implements Drop trait to avoid reordering
2023-10-03 15:49:28 +00:00
koka
c7152679ef
Apply review suggestions from @y21 2023-10-04 00:13:53 +09:00
bors
29958f0764 Auto merge of #11602 - koka831:fix/11601, r=xFrednet
Avoid invoking `ignored_unit_patterns` in macro definition

Fixes https://github.com/rust-lang/rust-clippy/issues/11601

The reported problem occured in [a derive macro](https://github.com/mpalmer/ct-structs/actions/runs/6386980382/job/17334587328#step:6:239). This PR avoid linting in macros.

changelog: [`ignored_unit_patterns`] No longer lints inside macro definitions
2023-10-03 13:07:13 +00:00
koka
1a56f90ee5
Fix: avoid changing drop order 2023-10-03 21:28:01 +09:00
koka
e465264d47
Avoid invoking ignored_unit_patterns in macro definition 2023-10-03 20:36:35 +09:00
bors
81400e2db8 Auto merge of #11589 - koka831:fix/10198, r=giraffate
std_instead_of_core: avoid lint inside of proc-macro

- fixes https://github.com/rust-lang/rust-clippy/issues/10198

note: The lint for the reported `thiserror::Error` has been suppressed by [Don't lint unstable moves in std_instead_of_core](https://github.com/rust-lang/rust-clippy/pull/9545/files#diff-2cb8a24429cf9d9898de901450d640115503a10454d692dddc6a073a299fbb7eR29) because `thiserror::Error`  internally implements `std::error::Error for (derived struct)`.

changelog: [`std_intead_of_core`]: avoid linting inside proc-macro

I confirmed this change fixes the problem:
<details>
<summary>test result without the change</summary>

```console
error: used import from `std` instead of `core`
  --> tests/ui/std_instead_of_core.rs:65:14
   |
LL |     #[derive(ImplStructWithStdDisplay)]
   |              ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the derive macro `ImplStructWithStdDisplay` (in Nightly builds, run with -Z macro-backtrace for more info)
```
</details>
2023-10-03 01:26:29 +00:00
bors
08c429f241 Auto merge of #11596 - blyxyas:fix-fp-needless_pass_by_ref_mut, r=Jarcho
Move `needless_pass_by_ref_mut`: `suspicious` -> `nursery`

[Related to [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/needless_pass_by_ref_mut.20isn't.20ready.20for.20stable)]

`needless_pass_by_ref_mut` has been released with some important bugs (notably having a lot of reported false positives and an ICE). So it may not be really ready for being in stable until these problems are solved. This PR changes the lint's category from `suspicious` to `nursery`, just that.
changelog: none
2023-10-02 18:40:32 +00:00
blyxyas
07e63291ec
Modify tests to account for the new allow-by-default needless_pass_by_ref_mut 2023-10-02 20:14:43 +02:00
blyxyas
3f0da4dda2
Move needless_pass_by_ref_mut: suspicious -> nursery 2023-10-02 13:28:45 +02:00
bors
331d01e2bf Auto merge of #11265 - Alexendoo:print-literal-unicode-escapes, r=llogiq
Don't escape unicode escape braces in `print_literal`

Fixes #11264

changelog: none
2023-10-01 22:17:18 +00:00
Alex Macleod
258b9a8562 Don't escape unicode escape braces in print_literal 2023-10-01 21:43:09 +00:00
bors
aee3daf90b Auto merge of #11593 - koka831:fix/10511, r=xFrednet
Use Span#from_expansion instead of in_external_macro

- fixes #10511

I checked [the reported repository](https://github.com/rust-lang/rust-clippy/issues/10511#issuecomment-1474271205) and found that clippy hangs at [py_sync.rs#L85](842094068e/crates/python/src/py_sync.rs (L85)), where a macro(`py_function_sync_async`) defines type parameters. this macro is used in the same crate, so `in_external_macro` wouldn't catch them.

This PR fixes the problem by using `Span#from_expansion`.

---

changelog: ICE: [`implicit_hasher`]: No longer lints inside macros, which could cause ICEs
[#11593](https://github.com/rust-lang/rust-clippy/pull/11593)
2023-10-01 16:33:04 +00:00
bors
ec15630c5d Auto merge of #11592 - schubart:fix_documentation_link, r=flip1995
Fix documentation link

The file pointed to by the old link

    557f6848bd/clippy_lints/src/lib.rs (L110)

did not talk about categories and levels.

The new link (hopefully) points here

    https://doc.rust-lang.org/stable/clippy/

which has a nice table explaining the mappings.

changelog: none
2023-10-01 16:20:24 +00:00
bors
cbe67bc2d6 Auto merge of #11590 - Tyrubias:non_ex_false_positive, r=Alexendoo
Don't lint `manual_non_exhaustive` when enum is `#[non_exhaustive]`

Fixes #11583

changelog: Fix [`manual_non_exhaustive`] false positive for unit enum variants when enum is explicitly `non_exhaustive`.
2023-10-01 16:06:57 +00:00
Michael Schubart
0f8b8625bd Fix documentation link
The file pointed to by the old link

557f6848bd/clippy_lints/src/lib.rs (L110)

did not talk about categories and levels.

The new link (hopefully) points here

https://doc.rust-lang.org/stable/clippy/

which has a nice table explaining the mappings.
2023-10-01 16:44:30 +01:00
koka
6f1a78ffa8
Use Span#from_expansion instead of in_external_macro 2023-10-02 00:38:01 +09:00
Victor Song
9dfd60cf4f Remove extraneous #[non_exhaustive] check in lint 2023-10-01 09:54:45 -05:00
Victor Song
e683e3eeac Don't lint manual_non_exhaustive when enum explicitly marked as non_exhaustive
There are cases where users create a unit variant for the purposes
of tracking the number of variants for an nonexhaustive enum.
We should check if an enum is explicitly marked as nonexhaustive
before reporting `manual_non_exhaustive` in these cases. Fixes #11583
2023-09-30 22:57:54 -05:00
bors
0e43a04fab Auto merge of #11587 - y21:into_iter_without_iter, r=Jarcho
new lint: `into_iter_without_iter`

Closes #9736 (part 2)

This implements the other lint that my earlier PR missed: given an `IntoIterator for &Type` impl, check that there exists an inherent `fn iter(&self)` method.

changelog: new lint: `into_iter_without_iter`

r? `@Jarcho` since you reviewed #11527 I figured it makes sense for you to review this as well?
2023-09-30 18:43:37 +00:00
y21
8eb586d154 new lint: into_iter_without_iter 2023-09-30 19:38:16 +02:00
koka
d5cc97e32c
Add macro for test which use std internally 2023-10-01 00:47:57 +09:00
koka
44b6aca96b
Avoid linting in external/proc macro 2023-09-30 23:56:11 +09:00
bors
b00236d7f0 Auto merge of #11580 - y21:issue11579, r=Jarcho
[`manual_let_else`]: only omit block if span is from same ctxt

Fixes #11579.

The lint already had logic for omitting a block in `else` if a block is already present, however this didn't handle the case where the block is from a different expansion/syntax context. E.g.
```rs
macro_rules! panic_in_block {
  () => { { panic!() } }
}

let _ = match Some(1) {
  Some(v) => v,
  _ => panic_in_block!()
};
```
It would see this in its expanded form as `_ => { panic!() }` and think it doesn't have to include a block in its suggestion because it is already there, however that's not true if it's from a different expansion like in this case.

changelog: [`manual_let_else`]: only omit block in suggestion if the block is from the same expansion
2023-09-29 18:49:57 +00:00
y21
2d2017942a [manual_let_else]: only omit block if span is from same ctxt 2023-09-29 16:54:50 +02:00
bors
67a83ff057 Auto merge of #11582 - DaniPopes:missing-headers, r=xFrednet
Add missing lint description headers

Discovered in https://github.com/rust-lang/rust-analyzer/pull/15680/files#diff-7cb229b5139c72b6c230e3c195be375724c92226421fd57d5cf08872503e8c27L214-R226

changelog: none
2023-09-29 09:09:52 +00:00
bors
d38fa1a32d Auto merge of #11527 - y21:iter_without_into_iter, r=Jarcho
new lint: `iter_without_into_iter`

Closes #9736

A new lint that looks for `iter` (and `iter_mut`) method implementations without the type implementing `IntoIterator` for `&Type`.
Imo this seems rather pedantic, so I went with that, but I can be convinced to change it to `style` like the linked issue asked for.
Writing a machine applicable suggestion seems a bit tricky and tedious, so for now this relies on the user adding remaining lifetimes.

changelog: new lint: `iter_without_into_iter`
2023-09-29 01:58:42 +00:00
DaniPopes
ad5653b296
Add missing lint description headers 2023-09-29 03:08:34 +02:00
y21
330ebbb9f9 new lint: iter_without_into_iter 2023-09-28 22:22:36 +02:00
bors
91997a4df4 Auto merge of #11565 - RalfJung:mir_to_const, r=Jarcho
mir_to_const improvements

This simplifies some code and also fixes the float array handling to properly take into account the `offset`, and to work with little-endian targets.

Fixes https://github.com/rust-lang/rust-clippy/issues/11488
changelog: none
2023-09-28 17:59:05 +00:00
bors
d18d01a8b1 Auto merge of #11576 - koka831:fix/10128, r=llogiq
write_literal: Fix index of the remaining positional arguments

- fixes https://github.com/rust-lang/rust-clippy/issues/10128
- `clippy --fix` replaces multiple warnings at once
   e.g.)
   ```rust
   writeln!(v, "{0} {1}", "hello", "world");
   // before: `writeln!(v, "hello {1}", "world");`
   // now: `writeln!(v, "hello world");`
   ```

changelog: [`print_literal`], [`write_literal`]: Now handles positional argument properly
2023-09-28 13:40:05 +00:00
bors
29ed6fa119 Auto merge of #11415 - Alexendoo:needless-raw-string-hashes-pedantic, r=flip1995
Move `needless_raw_string_hashes` to `pedantic`

IMO it doesn't improve code enough to be warn by default. [It seems to be unclear to some also](https://github.com/rust-lang/rust-clippy/issues/11402), but that can probably be remedied separately

changelog: Moved [`needless_raw_string_hashes`] to `pedantic` (Now allow-by-default)
[#11415](https://github.com/rust-lang/rust-clippy/pull/11415)

r? `@flip1995`
2023-09-28 10:34:33 +00:00
koka
b413bf6c4e
Fix index of the remaining positional arguments 2023-09-28 17:34:02 +09:00
bors
124f1b0659 Auto merge of #11574 - unexge:missing-assert-message-docs, r=Alexendoo
Mention that `missing_assert_message` lint ignores test functions

Updates `missing_assert_message`'s docs to reflect that it ignores test functions as pointed out by `@mickvangelderen` in https://github.com/rust-lang/rust-clippy/pull/10362#issuecomment-1732288652

---

changelog: [`missing_assert_message`]: Update docs to reflect this lint ignores test functions
2023-09-28 00:41:36 +00:00
unexge
62b8ef304a Mention that missing_assert_message lint ignores test functions 2023-09-27 22:06:01 +01:00
bors
4494b6947f Auto merge of #11569 - Alexendoo:needless-raw-string-descr, r=llogiq
Describe the type of string in raw_strings lints

changelog: none
2023-09-26 21:16:33 +00:00
bors
493ab53f5b Auto merge of #11556 - Alexendoo:manual-hash-one, r=Manishearth
Add `manual_hash_one` lint

Adds a lint to suggest using [`BuildHasher::hash_one`](https://doc.rust-lang.org/std/hash/trait.BuildHasher.html#method.hash_one)

changelog: [`manual_hash_one`]: new lint
2023-09-26 16:05:59 +00:00
Alex Macleod
ec2f62677f Add manual_hash_one lint 2023-09-26 13:49:15 +00:00
Alex Macleod
6cdff10778 Describe the type of string in raw_strings lints 2023-09-26 11:49:44 +00:00
bors
585b56f35f Auto merge of #10300 - koka831:fix/9942, r=xFrednet
Do not lint when imported item contains underscore

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

changelog: [`wildcard_imports`]: No longer lints when imported items contain an item with the name `_`
2023-09-26 08:46:51 +00:00
koka
fab90003b8
Do not lint when imported item contains underscore 2023-09-26 12:58:48 +09:00
bors
bf4c998179 Auto merge of #11564 - Alexendoo:config-test-test, r=giraffate
Test that each config value exists in a test clippy.toml

Inspired by #11560, adds a test that each config option exists in some form in a `clippy.toml` in `tests/` (currently some are in `ui-toml`, some in `ui-cargo`)

changelog: none
2023-09-26 01:38:08 +00:00
bors
6c48ef3fc1 Auto merge of #11557 - Alexendoo:dev-new-lint-msrv-test, r=Manishearth
Add msrv test template for `cargo dev new_lint --msrv`

changelog: none
2023-09-25 19:48:31 +00:00
Ralf Jung
0f198579d0 mir_to_const: fix handling of float arrays 2023-09-25 17:02:07 +02:00
Ralf Jung
ce45221163 simply some valtree-to-const conversion 2023-09-25 16:23:47 +02:00
Ralf Jung
84d6894f26 it's not Miri but MIR constants 2023-09-25 16:19:02 +02:00
Alex Macleod
1972cc89c4 Test that each config value exists in a test clippy.toml 2023-09-25 12:38:23 +00:00
bors
78ddc8d17d Auto merge of #11495 - blyxyas:help_message_reformat, r=flip1995
Add colored help to be consistent with Cargo

On rust-lang/cargo#12578, a new colored help message format was introduced. This PR introduces the same styling from that `cargo help` message to our `cargo clippy --help` message.

More information is provided in the original PR, fixes #11482. The perfect reviewing process would be that the reviewer installs this branch and checks for themselves, but here are some screenshots, there are some more screenshots in the original issue.

![image](https://github.com/rust-lang/rust-clippy/assets/73757586/0c4d1b6d-5aa2-4146-a401-9ae88f6dedf5)

(Note that the actual text may change in the actual commit, that screenshot is just to test the colors).
Also note that the `color-print` version **should always** be synced with Cargo's `color-print` version to avoid increasing build times in the rust-lang/rust repo.

changelog:Add colors to the `cargo clippy --help` output 🎉.
2023-09-25 11:35:33 +00:00