-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ICE with move FnOnce unboxed closure #18652
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
Comments
|
We take the branch in question as an optimization when the closure is less than or equal to the size of an llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type()) The assert seems to assume that this can only happen if the closure has 1 or 0 free variables, but it's trivial to have several smaller variables packed into the space of an #![feature(unboxed_closures)]
fn main() {
let x = 0u16;
let y = 0u16;
move |:| x + y;
} In the original example, |
As an optimization, once unboxed closures receive their environment by value if it fits within the size of an `int`. An assert in this code path assumed that this would only occur if the environment had no more than a single free variable in it, but multiple smaller free variables can easily be packed into the space of an `int`, particularly if any of them are 0-sized. The assert can simply be removed. Closes rust-lang#18652
`FnOnce` environments that fit within an `int` are passed to the closure by value. For some reason there was an assert that this would only happen if there were 1 or 0 free variables, but it can also happen if there are multiple variables that happen to fit. Closes #18652
feat: Add an assist to extract an expression into a constant
Gives:
Rust playpen
Foo.bar can take
&self
or&mut self
instead and the ICE still happens. The following things stop the ICE from happening:|&:|
or|& mut:|
.Only have access to the playpen right now, so I can't get a backtrace, sorry.
The text was updated successfully, but these errors were encountered: