mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
ace5cb44f0
This simplifies the Scope lifetimes, and should make it a compile error for scope created handles to exit the scope. This should be strictly better, as you would never WANT to do this, but I hope that I have not caused a subtle lifetime problem that would prevent passing those created handles back into Lua. I've tested every situation I can think of, and it doesn't appear to be an issue, but I admit that I don't fully understand everything involved and I could be missing something. The reason that I needed to do this is that if you can let a scope handle escape the scope, you have a LuaRef with an unused registry id, and that can lead to UB. Since not letting the scope references escape is a strict improvement ANYWAY (if I haven't caused a lifetime issue), this is the easiest fix. This is technically a breaking change but I think in most cases if you notice it you would be invoking UB, or you had a function that accepted a Scope or something. I don't know if it's worth a version bump?