rune-rs / rune

An embeddable dynamic programming language for Rust.
https://rune-rs.github.io
Apache License 2.0
1.7k stars 85 forks source link

Fix formatting panic for 0.13.x #749

Closed VorpalBlade closed 1 month ago

VorpalBlade commented 1 month ago

Two commits are needed to fix this on 0.13:

(fixes #747)

VorpalBlade commented 1 month ago

I'm not sure if there are any tests that also need to be backported or not.

udoprog commented 1 month ago

LGTM!

Did you intend to fix the Debug impl for Value as well to not return fmt::Error in case the debug impl errors?

VorpalBlade commented 1 month ago

Did you intend to fix the Debug impl for Value as well to not return fmt::Error in case the debug impl errors?

The fix I did seems to work for my use case (no more panics), but it can still return error indeed. I'm not sure under what conditions that can happen though. But since posting this PR I did manage to hit that path again:

    let cmd = process::Command::new("ls");
    cmd.arg("-l");
    let child = cmd.spawn();
    dbg(cmd);

(This fails because cmd is apparently moved).

So perhaps we should also add something like the <object at address> format for the error case one level up?

VorpalBlade commented 1 month ago

With the latest change we now get debug prints like: <unknown object at 0x7ffd3816a388: Cannot read, value is moved>, which seems maximally informative.

udoprog commented 1 month ago

That's great! I think there's still the is_err thing in the Debug impl (can't check right now) which we should probably get rid off?

Regardless I'll merge this when I'm home. Thanks!

VorpalBlade commented 1 month ago

That's great! I think there's still the is_err thing in the Debug impl (can't check right now) which we should probably get rid off?

I must have missed this, not sure what is left at this point?

udoprog commented 1 month ago

You're right. Thank you!