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

Fix ICE in unnecessary_to_owned #9505

Merged
merged 1 commit into from Sep 21, 2022
Merged

Fix ICE in unnecessary_to_owned #9505

merged 1 commit into from Sep 21, 2022

Conversation

ghost
Copy link

@ghost ghost commented Sep 21, 2022

Fixes #9504

Compiler generated call into_future nodes return empty substs which we need when checking it's predicates. Handle this by simply exitting when we encounter one. This change introduces false negatives in place of the ICEs.

changelog: [unnecessary_to_owned]: fix ICE

Fixes #9504

Compiler generated call `into_iter` nodes return empty substs
which we need when checking it's predicates. Handle this by
simply exitting when we encounter one. This change introduces
false negatives in place of the ICEs.
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dswij (or someone else) soon.

Please see the contribution instructions for more information.

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

@dswij dswij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@dswij
Copy link
Member

dswij commented Sep 21, 2022

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 21, 2022

📌 Commit a783d54 has been approved by dswij

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Sep 21, 2022

⌛ Testing commit a783d54 with merge 3956c9d...

@bors
Copy link
Collaborator

bors commented Sep 21, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: dswij
Pushing 3956c9d to master...

@bors bors merged commit 3956c9d into rust-lang:master Sep 21, 2022
@smoelius smoelius mentioned this pull request Dec 3, 2022
bors added a commit that referenced this pull request Dec 4, 2022
Fix 10021

This PR proposes a fix for #10021.

The problem is similar to the one that `@mikerite` described in #9505. The compiler is generating an empty substitution for a call, even though the type of `Self` seems to be needed for a predicate. In `@mikerite's` case, the call was to [`IntoFuture::into_future`](https://doc.rust-lang.org/std/future/trait.IntoFuture.html#tymethod.into_future). In this case, the call is to [`Try::branch`](https://doc.rust-lang.org/std/ops/trait.Try.html#tymethod.branch).

The proposed fix is to verify that the parameter whose type is changing has an index within the substitution. The strikes me as a reasonable approach, since if the check were to fail, the following code would be a no-op:

https://github.com/rust-lang/rust-clippy/blob/4c123a06ba3c2ec17d3a4dfa251dccdc5368b712/clippy_lints/src/methods/unnecessary_to_owned.rs#L420-L428

Like `@mikerite's` original solution, this solution turns ICEs into false negatives.

changelog: fix `unnecessary_to_owned` false positive involving `Try::branch`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic parameter to async function causes ICE
3 participants