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 {

View file

@ -3,6 +3,8 @@ error[E0381]: borrow of possibly-uninitialized variable: `i`
|
LL | println!("{}", i);
| ^ use of possibly-uninitialized `i`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -3,6 +3,8 @@ error[E0381]: borrow of possibly-uninitialized variable: `x`
|
LL | println!("{}", x);
| ^ use of possibly-uninitialized `x`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -3,6 +3,8 @@ error[E0381]: borrow of possibly-uninitialized variable: `x`
|
LL | println!("{}", x);
| ^ use of possibly-uninitialized `x`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -3,6 +3,8 @@ error[E0381]: borrow of possibly-uninitialized variable: `i`
|
LL | println!("{}", i);
| ^ use of possibly-uninitialized `i`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -3,6 +3,8 @@ error[E0381]: borrow of possibly-uninitialized variable: `v`
|
LL | println!("{}", v);
| ^ use of possibly-uninitialized `v`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -3,12 +3,16 @@ error[E0381]: borrow of possibly-uninitialized variable: `x`
|
LL | println!("{}", x);
| ^ use of possibly-uninitialized `x`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0381]: borrow of possibly-uninitialized variable: `x`
--> $DIR/issue-24267-flow-exit.rs:18:20
|
LL | println!("{}", x);
| ^ use of possibly-uninitialized `x`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors

View file

@ -81,6 +81,8 @@ LL | println!("{}", arr[3]);
...
LL | c();
| - mutable borrow later used here
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0502]: cannot borrow `arr` as immutable because it is also borrowed as mutable
--> $DIR/arrays.rs:73:24

View file

@ -25,6 +25,8 @@ LL | println!("{}", e.0.0.m.x);
LL |
LL | c();
| - mutable borrow later used here
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0506]: cannot assign to `e.0.0.m.x` because it is borrowed
--> $DIR/box.rs:55:5

View file

@ -8,6 +8,7 @@ LL | println!("{}", foo.x);
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: 1 warning emitted

View file

@ -13,6 +13,8 @@ LL | println!("{:?}", p);
LL |
LL | c();
| - mutable borrow later used here
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -14,6 +14,7 @@ note: this function takes ownership of the receiver `self`, which moves `some_ve
|
LL | fn into_iter(self) -> Self::IntoIter;
| ^^^^
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -28,6 +28,7 @@ LL | println!("{}", FOO);
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error; 2 warnings emitted

View file

@ -39,6 +39,7 @@ LL | println!("{} {}", X, Y);
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/issue-43197.rs:16:26
@ -54,6 +55,7 @@ LL | println!("{} {}", X, Y);
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors; 4 warnings emitted

View file

@ -10,6 +10,8 @@ LL | println!("{}", x);
| ^ second borrow occurs here
LL | Pin::new(&mut b).resume(());
| ------ first borrow later used here
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -8,6 +8,8 @@ LL | let mut s_copy = s;
...
LL | println!("{}", s);
| ^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -12,6 +12,8 @@ LL | println!("{:?}", heap);
...
LL | };
| - ... and the mutable borrow might be used here, when that temporary is dropped and runs the destructor for type `(Option<PeekMut<'_, i32>>, ())`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -18,6 +18,7 @@ LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors

View file

@ -28,6 +28,8 @@ LL | println!("{}", y);
| ^ value borrowed here after move
LL | while true { while true { while true { x = y; x.clone(); } } }
| - value moved here, in previous iteration of loop
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error; 3 warnings emitted

View file

@ -8,6 +8,8 @@ LL | let y = x;
LL |
LL | println!("{}", *x);
| ^^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -7,6 +7,8 @@ LL | send(ch, message);
| ------- value moved here
LL | println!("{}", message);
| ^^^^^^^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -3,6 +3,8 @@ error[E0381]: borrow of possibly-uninitialized variable: `x`
|
LL | println!("{:?}", x);
| ^ use of possibly-uninitialized `x`
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -10,6 +10,8 @@ LL | println!("{}", x);
LL | });
LL | println!("{}", x);
| ^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -21,6 +21,8 @@ LL | ::std::mem::drop(x);
LL | };
LL | println!("{}", x);
| ^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0506]: cannot assign to `i` because it is borrowed
--> $DIR/try-block-maybe-bad-lifetime.rs:40:9

View file

@ -7,6 +7,8 @@ LL | let _y = x;
| - value moved here
LL | println!("{}", x);
| ^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -13,6 +13,7 @@ note: this function takes ownership of the receiver `self`, which moves `start`
|
LL | fn make_string_bar(mut self) -> Mine{
| ^^^^
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error