Closed
Description
Currently, expanding debug!("{}", foo)
looks something like:
static PRECOMPILED_FORMAT_STRING = ...;
let foo_addr = &foo;
let arguments: &fmt::Arguments = unsafe { /* do things with foo_addr */ };
fmt::writeln(logger, arguments)
This is a problem with the new temporary rules because you can't debug!("{}", some_ref_cell.borrow().get())
. This is because the borrow()
ends after the enclosing statement which in this case is let foo_addr = &foo;
In order to allow debugging these values, we should change the ast expansion to:
static PRECOMPILED_FORMAT_STRING = ...;
match foo {
ref foo_addr => {
let arguments: &fmt::Arguments = unsafe { /* do things with foo_addr */ };
fmt::writeln(logger, arguments)
}
}
Note that with a match
the enclosing statement encompasses the entire formatting call, so debugging foo.borrow().get()
should be valid. One other portion of this bug would be ensuring that codegen doesn't suffer in terms of compile-time or size as a result of this change. It is currently unknown how much a match
scope would affect codegen.