1
Fork 0

Rollup merge of #90131 - camsteffen:fmt-args-span-fix, r=cjgillot

Fix a format_args span to be expansion

I found this while exploring solutions for rust-lang/rust-clippy#7843.

r? `@m-ou-se`
This commit is contained in:
Matthias Krüger 2021-11-28 23:45:15 +01:00 committed by GitHub
commit 9715724006
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 51 additions and 1 deletions

View file

@ -769,7 +769,10 @@ impl<'a, 'b> Context<'a, 'b> {
for arg_ty in self.arg_unique_types[i].iter() {
args.push(Context::format_arg(self.ecx, self.macsp, e.span, arg_ty, i));
}
heads.push(self.ecx.expr_addr_of(e.span, e));
// use the arg span for `&arg` so that borrowck errors
// point to the specific expression passed to the macro
// (the span is otherwise unavailable in MIR)
heads.push(self.ecx.expr_addr_of(e.span.with_ctxt(self.macsp.ctxt()), e));
}
for pos in self.count_args {
let index = match pos {