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

Merged
merged 56 commits into from
Dec 29, 2022
Merged

Update Clippy #106259

merged 56 commits into from
Dec 29, 2022

Conversation

flip1995
Copy link
Member

r? @Manishearth

I think this was the very first sync with no conflicts whatsoever. I love this time of the year :D

koka831 and others added 30 commits December 10, 2022 21:05
fix rust-lang#9993
changlog: [`match_wildcard_for_single_variants`] avoid suggestion on wildcard with guard
do explicit checks for the other branch being None
The related issue is rust-lang#9766 where the `manual_filter`
lint would remove side effects
If the type of the result of a call to `IntoIterator::into_iter()`
and the type of the receiver are the same, then the receiver
implements `Iterator` and `into_iter()` is the identity function.

The call to `into_iter()` may be removed in all but two cases:

- If the receiver implements `Copy`, `into_iter()` will produce
  a copy of the receiver and cannot be removed. For example,
  `x.into_iter().next()` will not advance `x` while `x.next()` will.
- If the receiver is an immutable local variable and the call to
  `into_iter()` appears in a larger expression, removing the call to
  `into_iter()` might cause mutability issues. For example, if `x`
  is an immutable local variable, `x.into_iter().next()` will
  compile while `x.next()` will not as `next()` receives
  `&mut self`.
… r=xFrednet

Identify more cases of useless `into_iter()` calls

changelog: Sugg: [`useless_conversion`]: Now suggests removing calls to `into_iter()` on an expression implementing `Iterator`
[rust-lang#10020](rust-lang/rust-clippy#10020)
<!-- changelog_checked -->
…dnet

Move manual_clamp to nursery

As discussed in rust-lang/rust-clippy#9484 (comment) and decided in the [Zulip meeting](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202022-12-13/near/315626226)

changelog: Moved [`manual_clamp`] to `nursery` (Now allow-by-default)
[rust-lang#10101](rust-lang/rust-clippy#10101)
<!-- changelog_checked -->
Null fn lints

Adds lints to check for code, that assumes nullable `fn()`.

### Lint examples:

`transmute_null_to_fn`:
```rust
error: transmuting a known null pointer into a function pointer
  --> $DIR/transmute_null_to_fn.rs:9:23
   |
LL |         let _: fn() = std::mem::transmute(std::ptr::null::<()>());
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior
   |
   = help: try wrapping your function pointer type in `Option<T>` instead, and using `None` as a null pointer value
```

`fn_null_check`:
```rust
error: function pointer assumed to be nullable, even though it isn't
  --> $DIR/fn_null_check.rs:13:8
   |
LL |     if (fn_ptr as *mut ()).is_null() {}
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: try wrapping your function pointer type in `Option<T>` instead, and using `is_none` to check for null pointer value
```

Closes rust-lang#1644

---

changelog: Improvement: [`transmuting_null`]: Now detects `const` pointers to all types
[rust-lang#10099](rust-lang/rust-clippy#10099)
changelog: New lint: [`transmute_null_to_fn`]
[rust-lang#10099](rust-lang/rust-clippy#10099)
changelog: New lint: [`fn_null_check`]
[rust-lang#10099](rust-lang/rust-clippy#10099)
<!-- changelog_checked (This is just a flag for me, please don't add it manually) -->
Fix overflow ICE in large_stack/const_arrays

Change `maximum_allowed_size` config variable type from `u64` to `u128`, and converting total array sizes to `u128` to avoid overflow during multiplication.

Fixes rust-lang#10044

changelog: Fix: [`large_const_arrays`] and [`large_stack_arrays`]: avoid integer overflow when calculating total array size
rust-lang#10103
Add 2018/2021 edition tests for wildcard_imports

Fixes rust-lang#7943

---

changelog: none
<!-- changelog_checked -->
tgross35 and others added 11 commits December 25, 2022 07:30
`not_unsafe_ptr_arg_deref` update documentation

changelog: [`not_unsafe_ptr_arg_deref`]: strengthened documentation wording, fixes rust-lang#7714
This patch not only improves visibility, but also fixes a potential bug.
When a lint description ends with code block, the string will have three
backquotes at the end.
Since the current implementation prints the default value immediately
after that, the markdown renderer is unable to properly close the code
block.
There was an error when trying to negate an expression
like `x - 1.0`. We used to format it as `-x - 1.0` whereas
a proper negation would be `-(x - 1.0)`.

Therefore, we add parentheses around the expression when it is a
Binary ExprKind.

We also add parentheses around multiply and divide expressions,
even though this is not strictly necessary.
…_suggestion, r=Jarcho

fix incorrect suggestion in `suboptimal_flops`

fixes rust-lang#10003

There was an error when trying to negate an expression like `x - 1.0`. We used to format it as `-x - 1.0` whereas a proper negation would be `-(x - 1.0)`.

Therefore, we add parentheses around the expression when it is `ExprKind::Binary`.

We also add parentheses around multiply and divide expressions, even though this is not strictly necessary.

changelog: [`suboptimal_flops`]: fix incorrect suggestion caused by an incorrect negation of floating point expressions.
…Frednet

fix codeblocks in the document

While I've looked into rust-lang/rust-clippy#9990, I found broken code blocks in the document.

This patch not only improves visibility, but also fixes a potential bug. When a lint description ends with code block, the string will have three backquotes at the end.
Since the current implementation prints the default value immediately after that, the markdown renderer is unable to properly close the code block.

e.g. `arithmetic_side_effects`, we can see code block is not rendered properly, and (I think) it's bit hard to understand what ``"defaults to `[]`"`` is meant.

![2022-12-26_01-51](https://user-images.githubusercontent.com/14945055/209476342-4d0b2e18-44b6-4c74-8c3c-4f4f0904e8ca.png)

In this PR, it will be rendered as:

![image](https://user-images.githubusercontent.com/14945055/209476353-07587b86-1100-445f-946d-41f62f741e51.png)

changelog: none

r? `@xFrednet`
…x, r=llogiq

 Fix [match_single_binding] suggestion introduced an extra semicolon

Fix rust-lang#9725

---

changelog: [`match_single_binding`]: suggestion no longer introduces unneeded semicolons
[rust-lang#10060](rust-lang/rust-clippy#10060)
<!-- changelog_checked -->
Rustup

r? `@ghost`

Love this time of the year. No conflicts, because no one merges anything.

changelog: none
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 29, 2022
@rustbot
Copy link
Collaborator

rustbot commented Dec 29, 2022

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@matthiaskrgr
Copy link
Member

r? matthiaskrgr
@bors r+ p=1

@bors
Copy link
Contributor

bors commented Dec 29, 2022

📌 Commit 56ab392 has been approved by matthiaskrgr

It is now in the queue for this repository.

@rustbot rustbot assigned matthiaskrgr and unassigned Manishearth Dec 29, 2022
@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, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 29, 2022
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#104531 (Provide a better error and a suggestion for `Fn` traits with lifetime params)
 - rust-lang#105899 (`./x doc library --open` opens `std`)
 - rust-lang#106190 (Account for multiple multiline spans with empty padding)
 - rust-lang#106202 (Trim more paths in obligation types)
 - rust-lang#106234 (rustdoc: simplify settings, help, and copy button CSS by not reusing)
 - rust-lang#106236 (docs/test: add docs and a UI test for `E0514` and `E0519`)
 - rust-lang#106259 (Update Clippy)
 - rust-lang#106260 (Fix index out of bounds issues in rustdoc)
 - rust-lang#106263 (Formatter should not try to format non-Rust files)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented Dec 29, 2022

⌛ Testing commit 56ab392 with merge ad8ae05...

@bors bors merged commit b75b0a8 into rust-lang:master Dec 29, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 29, 2022
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#104531 (Provide a better error and a suggestion for `Fn` traits with lifetime params)
 - rust-lang#105899 (`./x doc library --open` opens `std`)
 - rust-lang#106190 (Account for multiple multiline spans with empty padding)
 - rust-lang#106202 (Trim more paths in obligation types)
 - rust-lang#106234 (rustdoc: simplify settings, help, and copy button CSS by not reusing)
 - rust-lang#106236 (docs/test: add docs and a UI test for `E0514` and `E0519`)
 - rust-lang#106259 (Update Clippy)
 - rust-lang#106260 (Fix index out of bounds issues in rustdoc)
 - rust-lang#106263 (Formatter should not try to format non-Rust files)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jan 12, 2023
Update Clippy

r? `@Manishearth`

I think this was the very first sync with no conflicts whatsoever. I love this time of the year :D
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jan 12, 2023
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#104531 (Provide a better error and a suggestion for `Fn` traits with lifetime params)
 - rust-lang#105899 (`./x doc library --open` opens `std`)
 - rust-lang#106190 (Account for multiple multiline spans with empty padding)
 - rust-lang#106202 (Trim more paths in obligation types)
 - rust-lang#106234 (rustdoc: simplify settings, help, and copy button CSS by not reusing)
 - rust-lang#106236 (docs/test: add docs and a UI test for `E0514` and `E0519`)
 - rust-lang#106259 (Update Clippy)
 - rust-lang#106260 (Fix index out of bounds issues in rustdoc)
 - rust-lang#106263 (Formatter should not try to format non-Rust files)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.