Uh oh!
There was an error while loading. Please reload this page.
Ensure callee_ids are body owners - #120000
Conversation
rustbot
commented
Jan 15, 2024
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
blyxyas
commented
Jan 15, 2024
Could this be opened as a PR directly to Clippy? |
smoelius
commented
Jan 15, 2024
I'm not sure, TBH. #118661 was largely unrelated to Clippy. But the way that Clippy called certain APIs ICEd following that PR's changes. I implemented the follow-up changes here to:
|
| ) -> bool { | ||
| let callee_id = cx | ||
| .enclosing_body | ||
| .map(|body| cx.tcx.hir().body_owner(body).owner.to_def_id()); |
There was a problem hiding this comment.
Using body_owner.owner is almost never the right thing to do. Would using body_owner_def_id solve the issue directly?
There was a problem hiding this comment.
Please forgive me but is that question directed towards me? Please note that the code you've cited is deleted by this PR.
fee1-dead
left a comment
There was a problem hiding this comment.
mostly LGTM, suggested some comment changes to clarify
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: fee1-dead <ent3rm4n@gmail.com>
smoelius
commented
Jan 18, 2024
The additional detail is much appreciated! |
fee1-dead
commented
Jan 20, 2024
@bors r+ |
bors
commented
Jan 20, 2024
Ensure `callee_id`s are body owners This PR makes the `callee_id` argument of Clippy's `implements_trait_with_env` optional, and when it is passed, ensures it is a body owner. rust-lang#118661 added the `callee_id` parameter to alleviate an ICE. Specifically, the `callee_id` is used to determine an "effect arg" in certain situations. Frankly, I [do not completely understand](rust-lang#118661 (comment)) what an "effect arg" is. But the code that determines it seems to require that `callee_id` is a body owner: - https://github.com/rust-lang/rust/blob/1ead4761e9e2f056385768614c23ffa7acb6a19e/src/tools/clippy/clippy_utils/src/ty.rs#L286-L288 - https://github.com/rust-lang/rust/blob/1ead4761e9e2f056385768614c23ffa7acb6a19e/compiler/rustc_middle/src/ty/util.rs#L834 - https://github.com/rust-lang/rust/blob/1ead4761e9e2f056385768614c23ffa7acb6a19e/compiler/rustc_middle/src/hir/map/mod.rs#L372 In the current head, some def ids passed as `callee_id`s are not body owners. This PR fixes that. cc `@rust-lang/clippy` r? `@fee1-dead`
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#118257 (Make traits / trait methods detected by the dead code lint) - rust-lang#119997 (Fix impl stripped in rustdoc HTML whereas it should not be in case the impl is implemented on a type alias) - rust-lang#120000 (Ensure `callee_id`s are body owners) - rust-lang#120015 (coverage: Format all coverage tests with `rustfmt`) - rust-lang#120063 (Remove special handling of `box` expressions from parser) - rust-lang#120138 (Increase vscode settings.json `git.detectSubmodulesLimit`) r? `@ghost` `@rustbot` modify labels: rollup
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#119997 (Fix impl stripped in rustdoc HTML whereas it should not be in case the impl is implemented on a type alias) - rust-lang#120000 (Ensure `callee_id`s are body owners) - rust-lang#120063 (Remove special handling of `box` expressions from parser) - rust-lang#120116 (Remove alignment-changing in-place collect) - rust-lang#120138 (Increase vscode settings.json `git.detectSubmodulesLimit`) - rust-lang#120169 (Spelling fix) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120000 - smoelius:fix-clippy, r=fee1-dead Ensure `callee_id`s are body owners This PR makes the `callee_id` argument of Clippy's `implements_trait_with_env` optional, and when it is passed, ensures it is a body owner. rust-lang#118661 added the `callee_id` parameter to alleviate an ICE. Specifically, the `callee_id` is used to determine an "effect arg" in certain situations. Frankly, I [do not completely understand](rust-lang#118661 (comment)) what an "effect arg" is. But the code that determines it seems to require that `callee_id` is a body owner: - https://github.com/rust-lang/rust/blob/1ead4761e9e2f056385768614c23ffa7acb6a19e/src/tools/clippy/clippy_utils/src/ty.rs#L286-L288 - https://github.com/rust-lang/rust/blob/1ead4761e9e2f056385768614c23ffa7acb6a19e/compiler/rustc_middle/src/ty/util.rs#L834 - https://github.com/rust-lang/rust/blob/1ead4761e9e2f056385768614c23ffa7acb6a19e/compiler/rustc_middle/src/hir/map/mod.rs#L372 In the current head, some def ids passed as `callee_id`s are not body owners. This PR fixes that. cc ``@rust-lang/clippy`` r? ``@fee1-dead``
Ensure `callee_id`s are body owners This PR makes the `callee_id` argument of Clippy's `implements_trait_with_env` optional, and when it is passed, ensures it is a body owner. rust-lang#118661 added the `callee_id` parameter to alleviate an ICE. Specifically, the `callee_id` is used to determine an "effect arg" in certain situations. Frankly, I [do not completely understand](rust-lang#118661 (comment)) what an "effect arg" is. But the code that determines it seems to require that `callee_id` is a body owner: - https://github.com/rust-lang/rust/blob/1ead4761e9e2f056385768614c23ffa7acb6a19e/src/tools/clippy/clippy_utils/src/ty.rs#L286-L288 - https://github.com/rust-lang/rust/blob/1ead4761e9e2f056385768614c23ffa7acb6a19e/compiler/rustc_middle/src/ty/util.rs#L834 - https://github.com/rust-lang/rust/blob/1ead4761e9e2f056385768614c23ffa7acb6a19e/compiler/rustc_middle/src/hir/map/mod.rs#L372 In the current head, some def ids passed as `callee_id`s are not body owners. This PR fixes that. cc ``@rust-lang/clippy`` r? ``@fee1-dead``
This PR makes the
callee_idargument of Clippy'simplements_trait_with_envoptional, and when it is passed, ensures it is a body owner.#118661 added the
callee_idparameter to alleviate an ICE. Specifically, thecallee_idis used to determine an "effect arg" in certain situations.Frankly, I do not completely understand what an "effect arg" is. But the code that determines it seems to require that
callee_idis a body owner:rust/src/tools/clippy/clippy_utils/src/ty.rs
Lines 286 to 288 in 1ead476
rust/compiler/rustc_middle/src/ty/util.rs
Line 834 in 1ead476
rust/compiler/rustc_middle/src/hir/map/mod.rs
Line 372 in 1ead476
In the current head, some def ids passed as
callee_ids are not body owners. This PR fixes that.cc @rust-lang/clippy
r? @fee1-dead