Skip to content

Clippy subtree update #136209

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

Merged
merged 166 commits into from
Jan 29, 2025
Merged

Clippy subtree update #136209

merged 166 commits into from
Jan 29, 2025

Conversation

flip1995
Copy link
Member

r? @Manishearth

Quite a bit late, as I was on vacation and then we had an issue in MacOS CI after the sync.

SpriteOvO and others added 30 commits December 15, 2024 03:59
This removes the last call to `LateContext::match_def_path()` in
Clippy's code. The `LateContext::match_def_path()` in the compiler
sources was only kept for Clippy's usage.
Some lifetimes in function return types are not bound to concrete
content and can be set arbitrarily. Clippy should not propose to replace
them by the default `'_` lifetime if such a lifetime cannot be
determined unambigously.
We are checking that we are calling the `as_bytes()` method of `String`
or `str`. Checking that it returns a `slice()` does not add anything.
This builds upon the lint for `str::as_bytes()`, and also covers
needless uses of the iterator version `str::bytes()`.
It claims to be in 1.83 but in fact will not be until 1.85.

Evidence: <rust-lang#134788> is where it was merged into rust-lang/rust, and has a milestone of 1.85.
…13972)

I ran Clippy on some projects after upgrading to 1.84, which found a
[needless use of
`as_bytes()`](rust-lang/rust-clippy#13437). It
made me notice that the code was also using `bytes()` needlessly in
other places. This PR improves on the `as_bytes()` lint to also lint
`bytes()`.

----

changelog: none
The code should not attempt to obtain a snippet by capping the
function signature span with its identifier span without checking that
they are in the same context.
…ang#13929)

Some lifetimes in function return types are not bound to concrete
content and can be set arbitrarily. Clippy should not propose to replace
them by the default `'_` lifetime if such a lifetime cannot be
determined unambigously.

I added a field to the `LifetimeChecker` and `Usage` to flag lifetimes
that cannot be replaced by default ones, but it feels a bit hacky.

Fix rust-lang#13923

changelog: [`needless_lifetimes`]: remove false positives by checking
that lifetimes can indeed be elided
The code should not attempt to obtain a snippet by capping the function
signature span with its identifier span without checking that they are
in the same context.

This is the only instance I could identify where placeholders were used
instead of the real snippet when running the CI lintcheck. Moreover, the
placeholders were not even used, as they snippet was obtained
prematurely.

Found in the context of rust-lang#13941

changelog: none
Checking it only in the merge queue leads to deferred failures once the
decision to merge has been taken already.
…ust-lang#13976)

Checking it only in the merge queue leads to deferred failures once the
decision to merge has been taken already.

- [X] Testing first without changelog line
- [x] Now that that has failed, adding the changelog line and
force-pushing

changelog: none
…#13949)

This removes the last call to `LateContext::match_def_path()` in
Clippy's code. The `LateContext::match_def_path()` in the compiler
sources was only kept for Clippy's usage.

Once this PR is merged and after the rustup, I will submit one to remove
`LateContext::match_def_path()` from the compiler.

changelog: none

r? @flip1995
Rerunning the PR checks when a PR is synchronized (new commits added, or
force-pushed) seems to remove the changelog checks from the UI while
keeping the PR mergeable from the maintainer's interface.

This PR reruns the cheap changelog check when a PR is synchronized.
lapla-cogito and others added 11 commits January 28, 2025 06:29
I opened rust-lang/rust-clippy#13896 before.
However, I found that there're more cases where Clippy suggests to use
modules that belong to the `std` crate even in a `no_std` environment.
Therefore, this PR include the changes I've made in rust-lang#13896 and new
changes to fix cases I found this time to prevent wrong suggestions in
`no_std` environments as well.

changelog: [`redundant_closure`]: correct suggestion in `no_std`
changelog: [`repeat_vec_with_capacity`]: correct suggestion in `no_std`
changelog: [`single_range_in_vec_init`]: don't emit suggestion to use
`Vec` in `no_std`
changelog: [`drain_collect`]: correct suggestion in `no_std`
changelog: [`map_with_unused_argument_over_ranges`]: correct suggestion
in `no_std`

also close rust-lang#13895
fix rust-lang#14034

The currect implementation of `obfuscated_if_else` sometimes makes
incorrect suggestions when the original code have side effects (see the
example in the above issue). I think this can be fixed by changing the
applicability depending on whether it can have side effects or not.

changelog: [`obfuscated_if_else`]: change applicability when the
original code can have side effects
Add a new lint `doc_overindented_list_items` to detect and fix list items
in docs that are overindented.

For example,

```rs
/// - first line
///      second line
fn foo() {}
```

this would be fixed to:

```rs
/// - first line
///   second line
fn foo() {}
```

This lint improves readabiliy and consistency in doc.
Add a new lint `doc_overindented_list_items` to detect and fix list
items
in docs that are overindented.

For example,

```rs
/// - first line
///      second line
fn foo() {}
```

this would be fixed to:

```rs
/// - first line
///   second line
fn foo() {}
```

This lint improves readabiliy and consistency in doc.

---

- \[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`

[lint_naming]:
https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

changelog: [`doc_overindented_list_items`]: Added a new lint that
detects overindented list items in docs
fixes: rust-lang#13601
Currently, the CI pipeline triggers `Lintcheck` for all PRs. However,
this check takes significant amount of time and seems unnecessary for
some certain directories that are frequently updated.

r? flip1995

changelog: none
r? @ghost

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

rustbot commented Jan 28, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@flip1995 flip1995 force-pushed the clippy-subtree-update branch from 3bf2035 to 4288227 Compare January 28, 2025 18:34
@Manishearth
Copy link
Member

@bors r+ p=1 rollup=never

@bors
Copy link
Collaborator

bors commented Jan 28, 2025

📌 Commit 4288227 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 Jan 28, 2025
@bors
Copy link
Collaborator

bors commented Jan 28, 2025

⌛ Testing commit 4288227 with merge aeba3c6...

@bors
Copy link
Collaborator

bors commented Jan 29, 2025

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 29, 2025
@bors bors merged commit aeba3c6 into rust-lang:master Jan 29, 2025
7 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 29, 2025
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (aeba3c6): 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 (primary 1.7%, secondary -3.5%)

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)
1.7% [1.2%, 2.2%] 9
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.5% [-3.5%, -3.5%] 1
All ❌✅ (primary) 1.7% [1.2%, 2.2%] 9

Cycles

Results (secondary 2.6%)

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)
2.6% [2.3%, 2.9%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 770.985s -> 768.982s (-0.26%)
Artifact size: 328.20 MiB -> 328.22 MiB (0.01%)

github-merge-queue bot pushed a commit to rust-lang/rust-clippy that referenced this pull request Feb 7, 2025
Fix the version of `doc_overindented_list_items`. It actually will be in
1.86.0, not 1.80.0.
(rust-lang/rust#136209 has a milestone of
1.86.0)

changelog: none
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.