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

Update Clippy #104688

Merged
merged 267 commits into from
Nov 22, 2022
Merged

Update Clippy #104688

merged 267 commits into from
Nov 22, 2022

Conversation

flip1995
Copy link
Member

r? @Manishearth

Sorry for taking so long. There were so many blockers and so little time. This situation should be mitigated with #104007 in the future.

bors and others added 30 commits October 21, 2022 12:41
Rollup of 6 pull requests

Successful merges:

 - rust-lang#102287 (Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait`)
 - rust-lang#102922 (Filtering spans when emitting json)
 - rust-lang#103051 (translation: doc comments with derives, subdiagnostic-less enum variants, more derive use)
 - rust-lang#103111 (Account for hygiene in typo suggestions, and use them to point to shadowed names)
 - rust-lang#103260 (Fixup a few tests needing asm support)
 - rust-lang#103321 (rustdoc: improve appearance of source page navigation bar)

Failed merges:

 - rust-lang#103209 (Diagnostic derives: allow specifying multiple alternative suggestions)

r? `@ghost`
`@rustbot` modify labels: rollup
[`unwrap_used`], [`expect_used`] do not lint in `test` cfg

changelog: [`unwrap_used`], [`expect_used`] do not lint in `test` cfg

fix rust-lang/rust-clippy#9612

I've updated the doc and used `cfg` acronym, not sure if `conditional compiler flag` would have been better
Enable test no_std_main_recursion

Verified that test actually works on windows
changelog: none
…p1995

Mark `let_underscore_lock` and `let_underscore_drop` as uplifted

Here I've renamed both the uplifted lints, however rustc's `let_underscore_lock` is slightly less capable than the clippy lint as it doesn't catch `parking_lot` types or `Result<Guard, ..>`, should we still remove it? The `Result` change looks like it was unintentional to me so that could probably be fixed upstream

changelog: Uplift [`let_underscore_drop`] to rustc rust-lang#97739
changelog: Remove overlap between rustc's `let_underscore_lock` and Clippy's [`let_underscore_lock`]

r? `@flip1995`
* add `rest_arg` to pass second argument from `map_or(U, F)`
* extract some procedures into closure

refac: rename rest_arg/second_arg

refac: organize function argument order

* put `second_arg` next to `arg` argument
…1995

fix: support `map_or` for `or_fun_call` lint

fixes rust-lang/rust-clippy#8993

The methods defined in `KNOW_TYPES`, except for `map_or`, accepts only one argument, so the matching `if let [arg] = args` works only for these methods.
This PR adds `rest_arg` argument to `check_general_case` method and handling of cases with two arguments to support `map_or`.

changelog: `or_fun_call` support `map_or`

* add `rest_arg` to pass second argument from `map_or(U, F)`
* extract some procedures into closure
Fix allow_attributes_without_reason applying to external crate macros

Previously the `clippy::allow_attributes_without_reason` lint would apply to external crate macros. Many macros in the Rust ecosystem include these `allow` attributes without adding a reason, making this lint pretty much unusable in any sizable Rust project.

This commit fixes that by adding a check to the lint if the attribute is from an external crate macro and returning early.

```
changelog: [`allow_attributes_without_reason`]: allow_attributes_without_reason no longer applies to external crate macros
```
…flip1995

Improvement for  `equatable_if_let`

fixes rust-lang#9221

This PR makes sure that enums or structs not implementing `PartialEq` trait but still using the `if let` patterns can be linted to be rewritten with `matches!`.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- \[ ] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[ ] Executed `cargo dev update_lints`
- \[ ] Added lint documentation
- \[x] Run `cargo dev fmt`

---

changelog: Improve [`equatable_if_let`] with additional `matches!` suggestions.
add `from_raw_with_void_ptr` lint

This PR `fixes rust-lang#9679`

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

---

changelog:  [`from_raw_with_void_ptr`]: added new lint
Changes it to be a proc_macro rather than macro_rules
Generate lint categories and explanations with `declare_clippy_lint`

This means contributors will no longer have to run `cargo dev update_lints` after changing a lints documentation or its category, which may also mean fewer merge conflicts in general

It works by swapping `declare_clippy_lint` out for a `proc_macro` of the same name. The proc macro emits a `LintInfo` alongside the generated `Lint` which are gathered into `declared_lint::LINTS`. The categories/explanations are then read from `declared_lint::LINTS` at runtime

The removal of `src/docs` is split into a separate commit to be more easily ignored

It is slightly slower though, adding a bit under a second to build time. Less noticeable in full builds or with a slower linker (benchmark uses mold)

```bash
hyperfine --warmup 2 \
    --parameter-list commit "declare-proc-macro,master" \
    --command-name "{commit}" \
    --setup "git checkout {commit}" \
    --prepare "touch clippy_lints/src/lib.rs" \
    "cargo build"
```
```
Benchmark 1: declare-proc-macro
  Time (mean ± σ):     10.731 s ±  0.154 s    [User: 7.739 s, System: 1.791 s]
  Range (min … max):   10.598 s … 11.125 s    10 runs

Benchmark 2: master
  Time (mean ± σ):      9.422 s ±  0.094 s    [User: 7.183 s, System: 1.732 s]
  Range (min … max):    9.287 s …  9.624 s    10 runs

Summary
  'master' ran
    1.14 ± 0.02 times faster than 'declare-proc-macro'
```

r? `@flip1995`
cc `@llogiq` for `--explain`

changelog: none
This PR updates the `from_raw_with_void_ptr` lint, which covered
`Box::from_raw`, to also cover the `from_raw` static method of the
`Rc`, `Arc`, `alloc::rc::Weak` and `alloc::sync::Weak` types.

It also improves the description and error messages of this lint.

---

changelog: [`from_raw_with_void_ptr`]: Now works with the `Rc`, `Arc`, `alloc::rc::Weak` and `alloc::sync::Weak` types.
Found when working on `lintcheck --fix`
- This name makes more sense and highlights the issue

Signed-off-by: Doru-Florin Blanzeanu <[email protected]>
@bors
Copy link
Contributor

bors commented Nov 22, 2022

⌛ Testing commit 2422802 with merge 39a4ef785f01329d4de9263d2e9153cdaaacc768...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 22, 2022

💔 Test failed - checks-actions

@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 Nov 22, 2022
@matthiaskrgr
Copy link
Member

Do we use if-let chains a lot? #99938 :/

@flip1995
Copy link
Member Author

Clippy is probably the main user of let_chains. Glad we can test it 😅

@flip1995
Copy link
Member Author

@bors r=Manishearth,flip1995

@klensy
Copy link
Contributor

klensy commented Nov 22, 2022

@bors ping

Ahh, typo

@bors
Copy link
Contributor

bors commented Nov 22, 2022

😪 I'm awake I'm awake

@flip1995
Copy link
Member Author

Argh, what's going on with this PR. Seems like GH ignores it and webhooks aren't working on it anymore or something. reopening it, maybe that'll help?

@flip1995 flip1995 closed this Nov 22, 2022
@flip1995 flip1995 reopened this Nov 22, 2022
@flip1995
Copy link
Member Author

@bors r=Manishearth,flip1995

@bors
Copy link
Contributor

bors commented Nov 22, 2022

📌 Commit 5e6a9a4 has been approved by Manishearth,flip1995

It is now in the queue for this repository.

@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 Nov 22, 2022
@bors
Copy link
Contributor

bors commented Nov 22, 2022

⌛ Testing commit 5e6a9a4 with merge e221616...

@bors
Copy link
Contributor

bors commented Nov 22, 2022

☀️ Test successful - checks-actions
Approved by: Manishearth,flip1995
Pushing e221616 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 22, 2022
@bors bors merged commit e221616 into rust-lang:master Nov 22, 2022
@rustbot rustbot added this to the 1.67.0 milestone Nov 22, 2022
@flip1995 flip1995 deleted the clippyup branch November 22, 2022 21:38
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e221616): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.0% [1.0%, 1.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.4%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.3% [-2.6%, -2.1%] 2
All ❌✅ (primary) - - 0

Cycles

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

flip1995 pushed a commit to flip1995/rust that referenced this pull request Dec 1, 2022
…p1995

Update Clippy

r? `@Manishearth`

Sorry for taking so long. There were so many blockers and so little time. This situation should be mitigated with rust-lang#104007 in the future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-clippy Area: Clippy 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. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.