-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Change the debug! macro ast expansion for temporaries #12239
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
This may break some code. For example, |
I saw several such compiling errors in |
Argh. This seems to be more of a bug with the linter, or at least a |
Currently, the format_args! macro and its downstream macros in turn expand to series of let statements, one for each of its arguments, and then the invocation of the macro function. If one or more of the arguments are RefCell's, the enclosing statement for the temporary of the let is the let itself, which leads to scope problem. This patch changes let's to a match expression. Closes #12239.
minor: Fix typo in publisher field
…tation, r=y21 Add `missing_transmute_annotations` lint Fixes rust-lang/rust-clippy#715. r? `@blyxyas` changelog: Add `missing_transmute_annotations` lint
Currently, expanding
debug!("{}", foo)
looks something like:This is a problem with the new temporary rules because you can't
debug!("{}", some_ref_cell.borrow().get())
. This is because theborrow()
ends after the enclosing statement which in this case islet foo_addr = &foo;
In order to allow debugging these values, we should change the ast expansion to:
Note that with a
match
the enclosing statement encompasses the entire formatting call, so debuggingfoo.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 amatch
scope would affect codegen.cc @nikomatsakis
The text was updated successfully, but these errors were encountered: