Commit Graph

18089 Commits

Author SHA1 Message Date
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
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
blyxyas
6ad218ceef
Add colored help 2023-09-25 13:33:35 +02:00
bors
7671c283a5 Auto merge of #11563 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-09-25 08:36:06 +00:00
Philipp Krones
903add0c11
Fix dogfood fallout 2023-09-25 10:31:51 +02:00
Philipp Krones
5eb7604482
Bump nightly version -> 2023-09-25 2023-09-25 10:26:33 +02:00
Philipp Krones
81fe8dc084
Merge remote-tracking branch 'upstream/master' into rustup 2023-09-25 10:26:11 +02:00
bors
aa137a7e57 Auto merge of #11552 - jonboh:ice_threshold_0_enum_variants, r=y21
prevent ice when threshold is 0 and enum has no variants

changelog: [`enum_variant_names`]: prevent ice when threshold is 0 and enum has no variants

r? `@y21`

Fixes the same ice issue raised during review of https://github.com/rust-lang/rust-clippy/pull/11496
2023-09-24 20:58:58 +00:00
Jon
0433e458da
use first instead of get(0)
Co-authored-by: Timo <30553356+y21@users.noreply.github.com>
2023-09-24 21:37:56 +02:00
jonboh
b3e262acfd add ui-toml test 2023-09-24 18:25:20 +02:00
bors
94fc43121f Auto merge of #11560 - y21:ui-toml-tests, r=Alexendoo
Add missing tests for configuration options

I noticed that a lot of lints didn't have test(s) for their configuration. This leads to issues like #11481 where the lint just does nothing with it.

This PR adds tests for *almost*[^1] all of the lints with a configuration that didn't have a test in ui-toml.
The tests that I wrote here are usually two cases: one for where it's right above or under the limit set by the config where it shouldn't lint and another one for right above where it should.

changelog: none

[^1]: allow-one-hash-in-raw-strings is ignored by needless_raw_string_hashes
2023-09-24 15:09:33 +00:00
y21
6e80db96ea use a smaller number in test that fits in usize for 32 bit 2023-09-24 16:29:26 +02:00
y21
6ce61d543a add missing configuration tests 2023-09-24 15:19:18 +02:00
Alex Macleod
39f7f695da Add msrv test template for cargo dev new_lint --msrv 2023-09-23 18:12:20 +00:00
Camille GILLOT
e2669b27f3 Remove GeneratorWitness and rename GeneratorWitnessMIR. 2023-09-23 13:47:30 +00:00
Camille GILLOT
19e160fe2f Bless clippy. 2023-09-23 13:47:30 +00:00
Camille GILLOT
0a2d39de2e Enable drop_tracking_mir by default. 2023-09-23 13:34:09 +00:00
bors
3da69c7041 Auto merge of #116052 - oli-obk:ceci_nest_pas_une_query, r=WaffleLapkin
Add a way to decouple the implementation and the declaration of a TyCtxt method.

properly addresses https://github.com/rust-lang/rust/pull/115819

accepted MCP: https://github.com/rust-lang/compiler-team/issues/395
2023-09-23 04:41:09 +00:00
bors
d732cce0d3 Auto merge of #11553 - mickvangelderen:fix-large-futures-example, r=xFrednet
Fix large_futures example

The value used in the large_futures example was not large enough to trigger the lint given the default threshold. The example also contained more code than necessary. This PR changes the value size from 1kB to 16kB and reduces the example in size.

changelog: [`large_futures`]: Fix and simplify example
2023-09-22 21:19:28 +00:00
bors
50139e6ad2 Auto merge of #11551 - Meczka:fix-fp-needless-pass-by-ref-mut, r=xFrednet
fixed fp caused by moving &mut reference inside of a closure

changelog: [`needless_pass_by_ref mut`]: fixes false positive caused by not covering mutable references passed to a closure inside of a fuction
fixes #11545
2023-09-22 21:07:46 +00:00
Mick van Gelderen
7e46fb9a65
Fix large_futures example
The value used in the large_futures example was not large enough to
trigger the lint given the default threshold.

The example also contained more code than necessary.

This PR changes the value size from 1kB to 16kB and reduces the example
in size.
2023-09-22 19:41:00 +02:00
pc-linux
ab51f66ec0 added tests 2023-09-22 18:04:57 +02:00
bors
835d7d923b Auto merge of #115696 - RalfJung:closure-ty-print, r=oli-obk
adjust how closure/generator types are printed

I saw `&[closure@$DIR/issue-20862.rs:2:5]` and I thought it is a slice type, because that's usually what `&[_]` is... it took me a while to realize that this is just a confusing printer and actually there's no slice. Let's use something that cannot be mistaken for a regular type.
2023-09-22 15:19:38 +00:00
jonboh
f3a27d20f6 prevent ice when threshold is 0 and enum has no variants 2023-09-22 17:18:49 +02:00