Commit graph

1343 commits

Author SHA1 Message Date
bors
d487579efd Auto merge of #11792 - y21:issue11764, r=llogiq
[`map_identity`]: respect match ergonomics

Fixes #11764

Note: the original tests before this were slightly wrong themselves already and had to be changed. They were calling `map` on an iterator of `&(i32, i32)`s, so this PR would stop linting there, but they were meant to test something else unrelated to binding modes, so I just changed them to remove the references so that it iterates over owned values and they all bind by value. This way they continue to test what they checked for before: the identity function for tuple patterns.

changelog: [`map_identity`]: respect match ergonomics
2023-11-11 14:58:00 +00:00
y21
b2cf8f7a24 [map_identity]: respect match ergonomics 2023-11-11 13:48:26 +01:00
Alex Macleod
13b4bb12ad Clean up after if chain removal 2023-11-10 18:03:13 +00:00
Alex Macleod
9681b4afe0 Run if-to-let-chain clippy*/**/*.rs
https://github.com/Alexendoo/if-to-let-chain
2023-11-10 17:29:28 +00:00
Jacherr
483b109e6e cargo dev fmt 2023-11-08 21:17:40 +00:00
Jacherr
67bb503f26 add support for std::alloc::Global, add more tests 2023-11-08 21:10:27 +00:00
bors
ba43632808 Auto merge of #11736 - gernot-ohner:issue-10267, r=flip1995
Make SpanlessEq more consistent

1) Remove wildcard as requested in https://github.com/rust-lang/rust-clippy/issues/10267.
2) Implement `hir_utils::eq_expr` for `ExprKind::Closure`, `ExprKind::ConstBlock`, `ExprKind::InlineAsm` and `ExprKind::Yield`.
3) Reorder branches of `hir_utils::eq_expr` to be in alphabetical order.

---
changelog: none
2023-11-08 09:58:56 +00:00
Gernot Ohner
171845d5a8 Reorder ExprKinds in hash_expr alphabetically 2023-11-06 11:51:07 -07:00
Philipp Krones
62a82b361c
Format let-chains across the code base
In the updated nightly version, it seems that rustfmt now supports formatting
let-chains. Since we're using them a lot, it's a lot of reformatting.
2023-11-02 17:24:30 +01:00
Philipp Krones
95dc7be92f
Merge remote-tracking branch 'upstream/master' into rustup 2023-11-02 17:24:19 +01:00
Dinu Blanovschi
bb9cc6d47c refactor: extract common pat_is_wild to clippy_utils
This function was previously defined for the iter_kv_map,
for_kw_map, and unused_enumerate_index lints. This commit extracts
it into clippy_utils.
2023-11-01 14:19:23 +01:00
Gernot Ohner
6d840652dc Add branches in eq_expr 2023-10-30 18:04:36 -06:00
Gernot Ohner
67d379ba42 Reorder ExprKinds in eq_expr to alphabetical 2023-10-30 15:54:53 -06:00
Gernot Ohner
ed982afc8f Expliticly specify else branches in hir_utils::hash_expr 2023-10-30 15:16:23 -06:00
bors
325e9fd339 Auto merge of #11723 - Alexendoo:clippy-utils-internal, r=Jarcho
Remove internal feature from clippy_utils

It's only used to gate a few `const`s, removing the feature gate means it doesn't have to be recompiled when moving between a normal and `-F internal` build/test/etc

changelog: none
2023-10-30 17:11:53 +00:00
David Tolnay
2e907aa90c Rename Since -> StableSince in preparation for a DeprecatedSince 2023-10-29 21:39:57 -07:00
bors
f2a0776f77 Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errors
Implement `gen` blocks in the 2024 edition

Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122
`gen` block tracking issue https://github.com/rust-lang/rust/issues/117078

This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically.

An example usage of `gen` blocks is

```rust
fn foo() -> impl Iterator<Item = i32> {
    gen {
        yield 42;
        for i in 5..18 {
            if i.is_even() { continue }
            yield i * 2;
        }
    }
}
```

The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-29 00:03:52 +00:00
Andre Bogus
1ed1001440 Fix missing parenthesis in suboptimal floating point help 2023-10-27 16:28:10 +02:00
Alex Macleod
f4b4e2ca1b Remove internal feature from clippy_utils 2023-10-27 13:13:26 +00:00
Oli Scherer
0c8caee7b9 Add gen blocks to ast and do some broken ast lowering 2023-10-27 13:05:48 +00:00
David Tolnay
d736992ac9 Parse rustc version at compile time 2023-10-26 18:55:05 -07:00
bors
2f0f4ddcf7 Auto merge of #11698 - a1phyr:waker_clone_and_wake, r=y21
Add `waker_clone_and_wake` lint to check needless `Waker` clones

Check for patterns of `waker.clone().wake()` and replace them with `waker.wake_by_ref()`.

An alternative name could be `waker_clone_then_wake`

changelog: [ `waker_clone_wake`]: new lint
2023-10-26 21:01:40 +00:00
David Tolnay
76d7af0df1 Expose a non-Symbol way to access current rustc version string 2023-10-24 18:11:20 -07:00
David Tolnay
f4f5b05cbb Handle structured stable attribute 'since' version in clippy 2023-10-24 18:00:26 -07:00
Benoît du Garreau
f8790963d9 Add a lint to check needless Waker clones 2023-10-24 09:58:23 +02:00
Gernot Ohner
a799249766 Add additional branches to hir_utils::eq_expr 2023-10-23 23:22:30 -06:00
Alex Macleod
4622203c9b Move configuration to new clippy_config crate 2023-10-23 20:05:10 +00:00
Alex Macleod
7347c1803f Set existing doc-tests to no_run 2023-10-23 15:28:26 +00:00
y21
d6fc606259 [map_identity]: recognize tuples 2023-10-21 15:40:34 +02:00
Philipp Krones
8e7d1678c4 Merge commit '2b030eb03d9e5837440b1ee0b98c50b97c0c5889' into clippyup 2023-10-21 14:16:11 +02:00
Philipp Krones
5f031561ef
Merge remote-tracking branch 'upstream/master' into rustup 2023-10-21 13:41:46 +02:00
Oli Scherer
d9259fdedd s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer
868e513935 s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
bors
e230f19e18 Auto merge of #11521 - y21:issue9122, r=llogiq
[`map_identity`]: allow closure with type annotations

Fixes #9122

`.map(|a: u32| a)` can help type inference, so we should probably allow this and not warn about "unnecessary map of the identity function"

changelog: [`map_identity`]: allow closure with type annotations
2023-10-20 13:28:30 +00:00
bors
9574d28cb6 Auto merge of #11683 - Alexendoo:msrv-config, r=Manishearth,flip1995
Deserialize `Msrv` directly in `Conf`

Gives the error a span pointing to the invalid config value

Also puts `Conf` itself in the `OnceLock` rather than just the `Msrv` for [the `register_late_mod_pass` work](https://github.com/rust-lang/rust/pull/116731) since it will be used from two different callbacks

changelog: none
2023-10-19 11:51:08 +00:00
Alex Macleod
1528c1db47 Deserialize Msrv directly in Conf 2023-10-18 20:35:09 +00:00
jonboh
8b02dac542 add lint for struct field names
side effect for `enum_variants`:
use .first() instead of .get(0) in enum_variants lint
move to_camel_case to str_util module
move module, enum and struct name repetitions check to a single file `item_name_repetitions`
rename enum_variants threshold config option
2023-10-18 19:20:08 +02:00
lcnr
d9dc5ee072 AliasTy::new instead of tcx method 2023-10-18 13:57:19 +02:00
Arthur Lafrance
9ee26d078d fix lint failures in clippy 2023-10-16 19:50:31 -07:00
bors
ef95be517c Auto merge of #11609 - y21:get_first_non_primitives, r=giraffate
[`get_first`]: lint on non-primitive slices

Fixes #11594

I left the issue open for a couple days before making the PR to see if anyone has something to say, but it looks like there aren't any objections to removing this check that prevented linting on non-primitive slices, so here's the PR now.
There's a couple of instances in clippy itself where we now emit the lint. The actual relevant change is in the first commit and fixing the `.get(0)` instances in clippy itself is in the 2nd commit.

changelog: [`get_first`]: lint on non-primitive slices
2023-10-15 23:53:22 +00:00
y21
bba155ea9d move changed logic to into its own util function 2023-10-09 21:57:44 +02:00
y21
0b60531e42 [map_identity]: allow closure with type annotations 2023-10-09 21:39:28 +02:00
Philipp Krones
8ebed4cc1a Merge commit 'b105fb4c39bc1a010807a6c076193cef8d93c109' into clippyup 2023-10-06 17:35:45 +02:00
Philipp Krones
b8677e54d4
Bump Clippy version -> 0.1.75 2023-10-06 17:32:44 +02:00
Philipp Krones
82c3064c47
Merge remote-tracking branch 'upstream/master' into rustup 2023-10-06 17:31:44 +02:00
Alex Macleod
dcc400191e Fix items_after_test_module for non root modules, add applicable suggestion 2023-10-06 12:46:04 +00:00
Jason Newcomb
9de3e6c928 Add more diagnostic items for clippy 2023-10-05 18:21:47 -04:00
y21
e6f29f1900 dogfood 2023-10-04 18:08:30 +02:00
bors
f107a50b23 Auto merge of #115025 - ouz-a:ouz_testing, r=lcnr
Make subtyping explicit in MIR

This adds new mir-opt that pushes new `ProjectionElem` called `ProjectionElem::Subtype(T)` to `Rvalue` of a subtyped assignment so we can unsoundness issues like https://github.com/rust-lang/rust/issues/107205

Addresses https://github.com/rust-lang/rust/issues/112651

r? `@lcnr`
2023-10-03 10:02:52 +00:00
ouz-a
ea4b38820b subtyping_projections 2023-10-02 23:37:49 +03:00