mattwparas / steel

An embedded scheme interpreter in Rust
Apache License 2.0
980 stars 46 forks source link

wrap env::set_var in a closure #207

Closed RalfJung closed 2 months ago

RalfJung commented 2 months ago

This is in preparation for https://github.com/rust-lang/rust/pull/124636, where we're making set_var unsafe. On old (pre-2024) editions, the unsafety error is downgraded to a warning so old code largely keeps working -- except when set_var is coerced to a function pointer, as is done by this crate (and by no other crate it seems); then the true type of set_var being an unsafe fn shines through and the build fails.

So to keep this crate building with future versions of rustc, wrap set_var in a closure such that the closure gets coerced to a function pointer, and set_var just gets called the normal way.

mattwparas commented 2 months ago

Thank you!

RalfJung commented 2 months ago

Thanks for the quick merge :)