Clippy subtree update#156552
Merged
Merged
Conversation
The program will suggest using the `then_some` method. changelog: add [`some_filter`]
It currently only depends on two things: - `rustc_ast::AttrId`: this is just a re-export of `rustc_span::AttrId`, so we can import the original instead. - `rustc_ast::AttributeExt`: needed only for the `name` and `id` methods. We can instead pass in the `name` and `id` directly.
Previously when adding a suggestion for using `Cow::into_owned()` instead of `ToOwned::to_owned()`, the compiler would just convert the methods `Span` into a `String` and do checks on that `String`. This PR adds an extra guard to that suggestion by checking if the method is `sym::to_owned_method`.
Add extra symbol check for `.to_owned()` Follow up of rust-lang#154646 Previously when adding a suggestion for using `Cow::into_owned()` instead of `ToOwned::to_owned()`, the compiler would just convert the methods `Span` into a `String` and do checks on that `String`. This PR adds an extra guard to that suggestion by checking if the method is `sym::to_owned_method`. r? @davidtwco since you added the review to the previous PR
*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust-clippy/pull/15793)* This is needed for `SpanlessEq` to work correctly inside a macro expansion. The context selected for some of the lints may be wrong, but most of them don't handle macros correctly in the first place so this won't really be a regression. Without this change `SpanlessEq` would essentially assume the root context which isn't always correct. changelog: none
Make retags an implicit part of typed copies Ever since Stacked Borrows was first implemented in Miri, that was done with `Retag` statements: given a place (usually a local variable), those statements find all references stored inside the place and refresh their tags to ensure the aliasing requirements are upheld. However, this is a somewhat unsatisfying approach for multiple reasons: - It leaves open the [question](rust-lang/unsafe-code-guidelines#371) of where to even put `Retag` statements. Over time, the AddRetag pass settled on one possible answer to this, but it wasn't very canonical. - For assignments of the form `*ptr = expr`, if the assignment involves copying a reference, we probably want to do a retag -- but if we do a `Retag(*ptr)` as the next instruction, it can be non-trivial to argue that this even retags the right value, so we refrained from doing retags in that case. This has [come up](llvm/llvm-project#160913 (comment)) as a potential issue for Rust making better use of LLVM "captures" annotations. (That said, there might be [other ways](rust-lang/unsafe-code-guidelines#593 (comment)) to obtain this desired optimization.) - Normal compilation avoids generating retags, but we still generate LLVM IR with `noalias`. What does that even mean? How do MIR optimization passes interact with retags? These are questions we have to figure out to make better use of aliasing information, but currently we can't even really ask such questions. I think we should resolve all that by making retags part of what happens during a typed copy (a concept and interpreter infrastructure that did not exist yet when retags were initially introduced). Under this proposal, when executing a MIR assignment statement, what conceptually happens is as follows: - We evaluate the LHS to a place. - We evaluate the RHS to a value. This does a typed load from memory if needed, raising UB if memory does not contain a valid representation of the assignment's type. - We walk that value, identify all references inside of it, and retag them. If this happens as part of passing a function argument, this is a protecting retag. - We store (a representation of) the value into the place. However, this semantics doesn't fully work: there's a mandatory MIR pass that turns expressions like `&mut ***ptr` into intermediate deref's. Those must *not* do any retags. So far this happened because the AddRetag pass did not add retags for assignments to deref temporaries, but that information is not recorded in cross-crate MIR. Therefore I instead added a field to `Rvalue::Use` to indicate whether this value should be retagged or not. A non-retagging copy seems like a sufficiently canonical primitive that we should be able to express it. Dealing with the fallout from that is a large chunk of the overall diff. (I also considered adding this field to `StatementKind::Assign` instead, but decided against that as we only actually need it for `Rvalue::Use`. I am not sure if this was the right call...) This neatly answers the question of when retags should occur, and handles cases like `*ptr = expr`. It avoids traversing values twice in Miri. It makes codegen's use of `noalias` sound wrt the actual MIR that it is working on. It also gives us a target semantics to evaluate MIR opts against. However, I did not carefully check all MIR opts -- in particular, GVN needs a thorough look under the new semantics; it currently can turn alias-correct code into alias-incorrect code. (But this PR doesn't make things any worse for normal compilation where the retag indicator is anyway ignored.) Another side-effect of this PR is that `-Zmiri-disable-validation` now also disables alias checking. It'd be nicer to keep them orthogonal but I find this an acceptable price to pay. - [rustc benchmark results](rust-lang#154341 (comment)) - [miri benchmark results](rust-lang#154341 (comment))
Remove unused spans from AttributeKind Recently I noticed some spans in diagnostic attributes were never used. I went through and checked the other variants too.
changelog: none r? ghost
…nishearth Clippy subtree update r? Manishearth
…RalfJung,ShoyuVanilla Rip out rustc_layout_scalar_valid_range_* attribute support And either removes tests for it or replaces the uses with pattern types. primarily fixes rust-lang#135996 fixes rust-lang#147761 fixes rust-lang#133652
…ust-lang#16952) fixes rust-lang/rust-clippy#16950 lint should now also trigger over async fns. changelog: [`needless_return_with_question_mark`]: fix false negative in async fn bodies.
*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust-clippy/pull/15745)* Add a check for some followed by filter. The program will suggest using the `then_some` method. changelog: [`filter_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_some
This proposes replacing calls to `.truncate(0)` for types in the standard library by `.clear()`, as the specialized version might be more efficient.
Update `askama` version to `0.16.0` New features and bugfixes. Full changelog is [here](https://github.com/askama-rs/askama/releases/tag/v0.16.0). r? @Urgau
This PR prepares the clippy testsuite to work with the new Cargo `build-dir` layout tracked in rust-lang/cargo#16807. Context: In rust-lang#155439 we attempt to enable the new Cargo `build-dir` layout in rust-lang/rust and I am working through all of the build failures caused by changing where the files are. Also note that the `ui_test` crate was bumped to include the corresponding fix in oli-obk/ui_test#368 With the changes in this PR the following test passes on my system. ```sh CARGO_UNSTABLE_BUILD_DIR_NEW_LAYOUT=true ./x test --stage 2 src/tools/clippy ``` changelog: none
fix: peeling of block. test: supply corner case tests of implicit_return. fix: pass body.value rather than block.expr. fix: special checking for implicit_return. fix: suggestion. refactor: flatten the code structure. refactor: remove lint submission in helper. refactor: call is_lint_allowed when necessary.
…rn` (rust-lang#16949) *[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust-clippy/pull/16949)* changelog: fix [`non_canonical_clone_impl`] incompatibility with [`implicit_return`] Fixes rust-lang/rust-clippy#16945 <!-- TRIAGEBOT_START --> <!-- TRIAGEBOT_CONCERN-ISSUE_START --> > [!NOTE] > # Concerns (0 active) > > - ~~[Using `return *self` is not the canonical implementation of `Clone`](rust-lang/rust-clippy#16949 (comment) resolved in [this comment](rust-lang/rust-clippy#16949 (review)) > > *Managed by `@rustbot`—see [help](https://forge.rust-lang.org/triagebot/concern.html) for details.* <!-- TRIAGEBOT_CONCERN-ISSUE_END --> <!-- TRIAGEBOT_END -->
This proposes replacing calls to `.truncate(0)` for types in the standard library by `.clear()`, as the specialized version might be more efficient. changelog: [`manual_clear`]: new lint Closes rust-lang/rust-clippy#16615
Collaborator
|
The Clippy subtree was changed cc @rust-lang/clippy These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
Collaborator
|
Member
|
@bors r+ p=1 |
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
May 13, 2026
…Manishearth Clippy subtree update r? Manishearth `Cargo.lock` update due to patch version bump in `ui_test`. One day early, as I won't have access to my laptop from tomorrow till Sunday
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
May 13, 2026
Clippy subtree update r? Manishearth `Cargo.lock` update due to patch version bump in `ui_test`. One day early, as I won't have access to my laptop from tomorrow till Sunday
Contributor
|
@bors yield |
Contributor
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #156559. |
rust-bors Bot
pushed a commit
that referenced
this pull request
May 13, 2026
…uwer Rollup of 7 pull requests Successful merges: - #156552 (Clippy subtree update) - #156344 (Do not index past end of buffer when checking heuristic in error index syntax highlighter) - #156500 (Privacy: move macros handling to early stage) - #156260 (test: suppress deprecation warning) - #156413 (rustdoc: Correctness & perf improvements to link-to-definition) - #156539 (Add `ChildExt::kill_process_group`) - #156540 (use `deref_patterns` in `rustdoc` instead of `box_patterns`)
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
May 13, 2026
Clippy subtree update r? Manishearth `Cargo.lock` update due to patch version bump in `ui_test`. One day early, as I won't have access to my laptop from tomorrow till Sunday
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Contributor
|
💔 Test for 64ad72a failed: CI. Failed job:
|
rust-bors Bot
pushed a commit
that referenced
this pull request
May 14, 2026
…uwer Rollup of 7 pull requests Successful merges: - #156552 (Clippy subtree update) - #156344 (Do not index past end of buffer when checking heuristic in error index syntax highlighter) - #156500 (Privacy: move macros handling to early stage) - #156260 (test: suppress deprecation warning) - #156413 (rustdoc: Correctness & perf improvements to link-to-definition) - #156539 (Add `ChildExt::kill_process_group`) - #156540 (use `deref_patterns` in `rustdoc` instead of `box_patterns`)
rust-timer
added a commit
that referenced
this pull request
May 14, 2026
Rollup merge of #156552 - flip1995:clippy-subtree-update, r=Manishearth Clippy subtree update r? Manishearth `Cargo.lock` update due to patch version bump in `ui_test`. One day early, as I won't have access to my laptop from tomorrow till Sunday
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
r? Manishearth
Cargo.lockupdate due to patch version bump inui_test.One day early, as I won't have access to my laptop from tomorrow till Sunday