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

don't visit nested bodies in is_const_evaluatable #11977

Merged
merged 1 commit into from
Dec 16, 2023

Conversation

y21
Copy link
Member

@y21 y21 commented Dec 16, 2023

Fixes #11939

This ICE happened in if_let_some_else_none, but the root problem is in one of the utils that it uses.
It is (was) possible for is_const_evalutable to visit nested bodies which would lead to it trying to get the type of one of the expressions with the wrong typeck table, which won't have the type stored.

Notably, for the expression Bytes::from_static(&[0; 256 * 1024]); in the linked issue, the array length is an anonymous const in which type checking happens on its own, so we can't use the typeck table of the enclosing function in there.

Visiting nested bodies is also not needed for checking whether an expression can be const, so I think it's safe to ignore just ignore them altogether.

changelog: Fix ICE when checking for constness in nested bodies

@rustbot
Copy link
Collaborator

rustbot commented Dec 16, 2023

r? @Manishearth

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 16, 2023
@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 16, 2023

📌 Commit b5169ae has been approved by Manishearth

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Dec 16, 2023

⌛ Testing commit b5169ae with merge fff484d...

@bors
Copy link
Collaborator

bors commented Dec 16, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Manishearth
Pushing fff484d to master...

1 similar comment
@bors
Copy link
Collaborator

bors commented Dec 16, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Manishearth
Pushing fff484d to master...

@bors bors merged commit fff484d into rust-lang:master Dec 16, 2023
5 checks passed
@y21
Copy link
Member Author

y21 commented Dec 16, 2023

Is it worth nominating this ICE fix for beta backport? 🤔

@Manishearth
Copy link
Member

Seems okay. I'm a bit busy these weeks, perhaps ask in zulip?

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.

Crash when calling bytes::Bytes::from_static with compile time evaluated size inside futures::stream::unfold
4 participants