Fix format macro expansions spans to be macro-generated

New Exprs generated as part of the format macro expansion should get the macro
expansion span which has an expansion context, not the span of the format string
which does not.
This commit is contained in:
Stephen Crane 2019-09-25 11:45:38 -07:00
parent 6c2c29c432
commit 0ec4513d5f
3 changed files with 9 additions and 12 deletions

View file

@ -15,5 +15,5 @@ impl ::std::fmt::Write for Stream {
fn main() {
write(|| format_args!("{}", String::from("Hello world")));
//~^ ERROR cannot return value referencing temporary value
//~| ERROR cannot return value referencing temporary value
//~| ERROR cannot return reference to temporary value
}

View file

@ -7,14 +7,11 @@ LL | write(|| format_args!("{}", String::from("Hello world")));
| | temporary value created here
| returns a value referencing data owned by the current function
error[E0515]: cannot return value referencing temporary value
error[E0515]: cannot return reference to temporary value
--> $DIR/issue-27592.rs:16:14
|
LL | write(|| format_args!("{}", String::from("Hello world")));
| ^^^^^^^^^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | temporary value created here
| returns a value referencing data owned by the current function
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returns a reference to data owned by the current function
error: aborting due to 2 previous errors