Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy subtree update #119387

Merged
merged 81 commits into from
Dec 29, 2023
Merged

Clippy subtree update #119387

merged 81 commits into from
Dec 29, 2023

Conversation

flip1995
Copy link
Member

hamirmahal and others added 30 commits December 10, 2023 15:44
…affleLapkin

Don't pass lint back out of lint decorator

Change the decorator function in the signature of the `emit_lint`/`span_lint`/etc family of methods from `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` to `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>)`. I consider it easier to read this way, especially when there's control flow involved.

r? nnethercote though feel free to reassign
Added the `Result` mirror of `option_filter_map` to catch

```
   .into_iter().filter(Result::is_ok).map(Result::unwrap)
```

changelog: New Lint: [`result_filter_map`]
Co-authored-by: Alex Macleod <alex@macleod.io>
[`redundant_pattern_matching`]: lint `if let true`, `while let true`, `matches!(.., true)`

Closes rust-lang#11917

This could also lint e.g. `if let (true, true, false) = (a, b, c)` and suggest `if a && b && c`, but that's a change in semantics (going from eager to lazy, so I just left it out for now. Could be a future improvement.

changelog: [`redundant_pattern_matching`]: lint `if let true`, `while let true`, `matches!(.., true)`
…n, r=llogiq

Add new `unconditional_recursion` lint

Currently, rustc `unconditional_recursion` doesn't detect cases like:

```rust
enum Foo {
    A,
    B,
}

impl PartialEq for Foo {
    fn eq(&self, other: &Self) -> bool {
        self == other
    }
}
```

This is because the lint is currently implemented only for one level, and in the above code, `self == other` will then call `impl PartialEq for &T`, escaping from the detection. The fix for it seems to be a bit tricky (I started investigating potential solution to add one extra level of recursion [here](https://github.com/rust-lang/rust/compare/master...GuillaumeGomez:rust:trait-impl-recursion?expand=1) but completely broken at the moment).

I expect that this situation will remain for a while. In the meantime, I think it's acceptable to check it directly into clippy for the time being as a lot of easy cases like this one can be easily checked (next I plan to extend it to cover other traits like `ToString`).

changelog: Add new `unconditional_recursion` lint
…hearth

don't visit nested bodies in `is_const_evaluatable`

Fixes rust-lang#11939

This ICE happened in `if_let_some_else_none`, but the root problem is in one of the utils that it uses.
It is (was) possible for `is_const_evalutable` to visit nested bodies which would lead to it trying to get the type of one of the expressions with the wrong typeck table, which won't have the type stored.

Notably, for the expression `Bytes::from_static(&[0; 256 * 1024]);` in the linked issue, the array length is an anonymous const in which type checking happens on its own, so we can't use the typeck table of the enclosing function in there.

Visiting nested bodies is also not needed for checking whether an expression can be const, so I think it's safe to ignore just ignore them altogether.

changelog: Fix ICE when checking for constness in nested bodies
…lexendoo

New Lint: `result_filter_map` / Mirror of `option_filter_map`

Added the `Result` mirror of `option_filter_map`.

changelog: New Lint: [`result_filter_map`]

I had to move around some code because the function def was too long 🙃.

I have also added some pattern checks on `option_filter_map`
…Jarcho

Do not lint `assertions_on_constants` for `const _: () = assert!(expr)`

Fixes rust-lang#8159

```rust
pub fn f() {
    // warning
    assert!(true);
    assert!(usize::BITS >= 32);

    // ok
    const _: () = assert!(usize::BITS >= 32);
}
```

changelog: Fix `const _: () = assert!(expr)` false positive on `assertions_on_constants` lint
…r=blyxyas,xFrednet

fix: broken GitHub corner

changelog: none

fixes rust-lang#11946
@bors
Copy link
Contributor

bors commented Dec 28, 2023

💔 Test failed - checks-actions

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 28, 2023
@Manishearth
Copy link
Member

@bors retry

don't see an actual failure?

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 29, 2023
@bors
Copy link
Contributor

bors commented Dec 29, 2023

⌛ Testing commit 0217ac9 with merge f3c6277...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 29, 2023
…hiaskrgr

Clippy subtree update

r? `@Manishearth`
@bors
Copy link
Contributor

bors commented Dec 29, 2023

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 29, 2023
@matthiaskrgr
Copy link
Member

@bors retry timeout

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 29, 2023
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Dec 29, 2023

⌛ Testing commit 0217ac9 with merge 1a7e97f...

@bors
Copy link
Contributor

bors commented Dec 29, 2023

☀️ Test successful - checks-actions
Approved by: matthiaskrgr
Pushing 1a7e97f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 29, 2023
@bors bors merged commit 1a7e97f into rust-lang:master Dec 29, 2023
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Dec 29, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1a7e97f): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 671.85s -> 670.236s (-0.24%)
Artifact size: 312.32 MiB -> 312.30 MiB (-0.01%)

@blyxyas
Copy link
Member

blyxyas commented Jan 4, 2024

Don't mind me, just doing an experiment

@bors try @rust-timer queue scenario=clippy

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 4, 2024
@blyxyas
Copy link
Member

blyxyas commented Jan 4, 2024

Hmmmm... It seems like bors is not even recognizing the command.
I'll try in a few days, when the new sync PR is open (before the merge) and let's see if that works.

@blyxyas blyxyas removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 4, 2024
@flip1995 flip1995 deleted the clippy-subtree-sync branch January 5, 2024 08:33
@flip1995
Copy link
Member Author

flip1995 commented Jan 5, 2024

@blyxyas bors ignores all closed/merged PRs

flip1995 pushed a commit to flip1995/rust that referenced this pull request Jan 11, 2024
…hiaskrgr

Clippy subtree update

r? `@Manishearth`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.