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 #101609

Merged
merged 61 commits into from
Sep 10, 2022
Merged

Update Clippy #101609

merged 61 commits into from
Sep 10, 2022

Conversation

flip1995
Copy link
Member

@flip1995 flip1995 commented Sep 9, 2022

tmiasko and others added 30 commits August 26, 2022 14:27
For consistency, and because it makes HIR measurement simpler and more
accurate.
For consistency, and because it makes HIR measurement simpler and more
accurate.
This reverts commit 3266460.

This is the revert against master, the beta revert was already done in rust-lang#100538.
…fJung

Strengthen invalid_value lint to forbid uninit primitives, adjust docs to say that's UB

For context: rust-lang#66151 (comment)

This does not make it a FCW, but it does explicitly state in the docs that uninit integers are UB.

This also doesn't affect any runtime behavior, uninit u32's will still successfully be created through mem::uninitialized.
match_wild_err_arm: Fix typo in note text

changelog: [`match_wild_err_arm`]: fix typo in note text
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#100787 (Pretty printing give proper error message without panic)
 - rust-lang#100838 (Suggest moving redundant generic args of an assoc fn to its trait)
 - rust-lang#100844 (migrate rustc_query_system to use SessionDiagnostic)
 - rust-lang#101140 (Update Clippy)
 - rust-lang#101161 (Fix uintended diagnostic caused by `drain(..)`)
 - rust-lang#101165 (Use more `into_iter` rather than `drain(..)`)
 - rust-lang#101229 (Link “? operator” to relevant chapter in The Book)
 - rust-lang#101230 (lint: avoid linting diag functions with diag lints)
 - rust-lang#101236 (Avoid needless buffer zeroing in `std::sys::windows::fs`)
 - rust-lang#101240 (Fix a typo on `wasm64-unknown-unknown` doc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Correctly handle unescape warnings

fixes rust-lang#9405

changelog: Fix ICE when format literals raise compiler warnings
Fix `suboptimal_float` not linting on `{const}.powf({const})`

There used to be an early return if the receiver was an effective const but the method was not linted, not taking into account later cases where the receiver and the arguments are both effective consts for different methods. Removed the early return.

Fixes rust-lang#9402
Fixes rust-lang#9201

changelog: Fix `suboptimal_flops`, `imprecise_flops` not linting on `{const}.powf({const})` et al
…ednet

New lint `bool_to_int_with_if`

This is a rebased version of rust-lang/rust-clippy#9086 I could sadly not push directly push to the PR branch as it's protected.

The lint implementation comes from `@jst-r.` Thank you for the work you put into this :)

---

Closes: rust-lang/rust-clippy#8131
Closes: rust-lang/rust-clippy#9086

changelog: Add lint [`bool_to_int_with_if`]

r? `@ghost`
Don't use `hir_ty_to_ty` in `result_large_err`

fixes rust-lang#9414

This occurs starting with 2022-09-01. I checked that this does fix the ICE on rust-lang/rust@9353538. Not sure which pr caused the late-bound region to leak through `hir_ty_to_ty`.

changelog: None
Fix `mut_mutex_lock` when Mutex is behind immutable deref

I *think* the problem here is the `if let ty::Ref(_, _, Mutability::Mut) = cx.typeck_results().expr_ty(recv).kind()` line tries to check if the `Mutex` can be mutably borrowed (there already is a test for `Arc<Mutex<_>>`), but gets bamboozled by the `&mut Arc` indirection. And I *think* checking the deref-adjustment to filter immutable-adjust (the deref through the `Arc`, starting from `&mut Arc`) is the correct fix.

Fixes rust-lang#9415

changelog: Fix `mut_mutex_lock` when Mutex is behind immutable deref
add `--explain` subcommand

This closes rust-lang#8291.

---

changelog: add `cargo clippy -- --explain <lintname>` subcommand
Use `approx_ty_size` for `large_enum_variant`

This builds upon rust-lang#9373 to use the approximate size of each variant for `large_enum_variant`. This allows us to lint in situations where an `enum` contains generics but is still guaranteed to have a large variant on an at-least basis, e.g. with `(T, [u8; 512])`.

* I've changed the wording from "is ... bytes" to "contains at least" because
  * the size is now an approximate lower bound (e.g. `512` in the example above). The actual size is larger due to `T`, including due to `T`'s memory layout.
  * the discriminant is not taken into account in the message. This comes up with variants like `A(T)`, which are "is at least 0 bytes" otherwise, which may be misleading.
* If the second-largest variant has no fields, there is a special case "carries no data" instead of "is at least 0 bytes".
* A variant like `A(T)` is "at least 0 bytes", which is technically true, yet we don't distinguish between "indeterminate" and truly "ZST".
* The generics-tests that were there before now lint while they didn't lint before. AFAICS this is correct.

I guess the above is correct-ish. However, I use the `SubstsRef` that I got via `cx.tcx.type_of(item.def_id)` to solve for generics in the variants. Is this even applicable, since we start from an - [ ] `ItemKind`?

changelog: none
Fixes rust-lang#9351.

Note that this commit reworks that fix for rust-lang#9317. The change
is to check that the type implements `AsRef<str>` before regarding
`to_string` as an equivalent of `to_owned`. This was suggested
by Jarcho in the rust-lang#9317 issue comments.

The benefit of this is that it moves some complexity out of
`check_other_call_arg` and simplifies the module as a whole.
Fix `unnecessary_to_owned` false positive

Fixes rust-lang#9351.

Note that this commit reworks that fix for rust-lang#9317. The change
is to check that the type implements `AsRef<str>` before regarding
`to_string` as an equivalent of `to_owned`. This was suggested
by Jarcho in the rust-lang#9317 issue comments.

The benefit of this is that it moves some complexity out of
`check_other_call_arg` and simplifies the module as a whole.

changelog: FP: [`unnecessary_to_owned`]: No longer lints, if type change would cause errors in the caller function
Michael Wright and others added 6 commits September 8, 2022 20:04
Fixes rust-lang#9431.

The current `range_plus_one` and `range_minus_one` suggestions
are completely incorrect when macros are involved.

This commit resolves this by disabling the lints for any range
expression that is expanded from a macro. The reasons for this
are that it is very difficult to create a correct suggestion in
this case and that false negatives are less important for
pedantic lints.
Rustup

r? `@ghost`

changelog: none
Fix `range_{plus,minus}_one` bad suggestions

Fixes rust-lang#9431.

The current `range_plus_one` and `range_minus_one` suggestions are completely incorrect when macros are involved.

This commit resolves this by disabling the lints for any range expression that is expanded from a macro. The reasons for this are that it is very difficult to create a correct suggestion in this case and that false negatives are less important for pedantic lints.

changelog: Fix `range_{plus,minus}_one` bad suggestions
@rustbot
Copy link
Collaborator

rustbot commented Sep 9, 2022

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 9, 2022
@Manishearth
Copy link
Member

@bors r+ p=1

@bors
Copy link
Contributor

bors commented Sep 9, 2022

📌 Commit ce03f15 has been approved by Manishearth

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 Sep 9, 2022
@bors
Copy link
Contributor

bors commented Sep 9, 2022

⌛ Testing commit ce03f15 with merge 0687bc2c8b2ba329fb7e5db12fe6a69634ec2f98...

@bors
Copy link
Contributor

bors commented Sep 9, 2022

💥 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 Sep 9, 2022
@matthiaskrgr
Copy link
Member

@bors retry arm 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 Sep 9, 2022
@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)

@Manishearth
Copy link
Member

@bors retry 🦾

@bors
Copy link
Contributor

bors commented Sep 10, 2022

⌛ Testing commit ce03f15 with merge 87eb3e2...

@bors
Copy link
Contributor

bors commented Sep 10, 2022

☀️ Test successful - checks-actions
Approved by: Manishearth
Pushing 87eb3e2 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 10, 2022
@bors bors merged commit 87eb3e2 into rust-lang:master Sep 10, 2022
@rustbot rustbot added this to the 1.65.0 milestone Sep 10, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (87eb3e2): 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)

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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.0% [0.6%, 1.3%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

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.

mean1 range count2
Regressions ❌
(primary)
8.6% [8.6%, 8.6%] 1
Regressions ❌
(secondary)
5.5% [5.5%, 5.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 8.6% [8.6%, 8.6%] 1

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

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.