summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-06-19 19:13:32 +0000
committerbors <bors@rust-lang.org>2025-06-19 19:13:32 +0000
commit255aa220821c05c3eac7605fce4ea1c9ab2cbdb4 (patch)
treeee6218a293a2c3d22a0f830cc64ef2f28a73a83d /tests
parent8de4c7234dd9b97c9d76b58671343fdbbc9a433e (diff)
parentb4f2cac097504a0728206b08fd4f8cb3d0946a3c (diff)
downloadrust-255aa220821c05c3eac7605fce4ea1c9ab2cbdb4.tar.gz
rust-255aa220821c05c3eac7605fce4ea1c9ab2cbdb4.zip
Auto merge of #140748 - m-ou-se:super-format-args3, r=jdonszelmann
 Allow storing `format_args!()` in variable

Fixes https://github.com/rust-lang/rust/issues/92698

Tracking issue for super let: https://github.com/rust-lang/rust/issues/139076

Tracking issue for format_args: https://github.com/rust-lang/rust/issues/99012

This change allows:

```rust
let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!

println!("{f}");
```

This will need an FCP.

This implementation makes use of `super let`, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have _a_ way of expressing temporary lifetimes like this, since the (stable) `pin!()` macro needs this too. (This was also the motivation for merging https://github.com/rust-lang/rust/pull/139114.)

(This is a second version of https://github.com/rust-lang/rust/pull/139135)
Diffstat (limited to 'tests')
-rw-r--r--tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff159
-rw-r--r--tests/ui/borrowck/clone-on-ref.stderr4
-rw-r--r--tests/ui/borrowck/issue-114374-invalid-help-fmt-args.rs16
-rw-r--r--tests/ui/borrowck/issue-114374-invalid-help-fmt-args.stderr31
-rw-r--r--tests/ui/consts/recursive-const-in-impl.stderr5
-rw-r--r--tests/ui/impl-trait/precise-capturing/foreign-2021.stderr2
-rw-r--r--tests/ui/impl-trait/precise-capturing/migration-note.stderr10
-rw-r--r--tests/ui/lifetimes/temporary-lifetime-extension-tuple-ctor.stderr2
-rw-r--r--tests/ui/macros/format-args-temporaries-in-write.stderr10
-rw-r--r--tests/ui/sized/unsized-binding.rs4
-rw-r--r--tests/ui/suggestions/issue-97760.stderr4
-rw-r--r--tests/ui/unpretty/exhaustive.hir.stdout6
-rw-r--r--tests/ui/unpretty/flattened-format-args.stdout6
13 files changed, 118 insertions, 141 deletions
diff --git a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff
index 33f1ad9bef4..e2d3c6c41b8 100644
--- a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff
+++ b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff
@@ -11,28 +11,29 @@
       let _9: ();
       let _10: ();
       let mut _11: std::fmt::Arguments<'_>;
-      let mut _12: &[&str; 3];
-      let _13: &[&str; 3];
-      let _14: [&str; 3];
-      let mut _15: &[core::fmt::rt::Argument<'_>; 2];
-      let _16: &[core::fmt::rt::Argument<'_>; 2];
-      let _17: [core::fmt::rt::Argument<'_>; 2];
+      let mut _13: &std::boxed::Box<dyn std::fmt::Display>;
+      let mut _14: &u32;
+      let mut _16: core::fmt::rt::Argument<'_>;
+      let mut _17: &std::boxed::Box<dyn std::fmt::Display>;
       let mut _18: core::fmt::rt::Argument<'_>;
-      let mut _19: &std::boxed::Box<dyn std::fmt::Display>;
-      let _20: &std::boxed::Box<dyn std::fmt::Display>;
-      let mut _21: core::fmt::rt::Argument<'_>;
-      let mut _22: &u32;
-      let _23: &u32;
-      let mut _25: bool;
-      let mut _26: isize;
-      let mut _27: isize;
-      let mut _28: isize;
-+     let _29: std::result::Result<std::boxed::Box<dyn std::fmt::Display>, <T as Err>::Err>;
-+     let _30: u32;
+      let mut _19: &u32;
+      let mut _20: &[&str; 3];
+      let _21: &[&str; 3];
+      let _22: [&str; 3];
+      let mut _23: &[core::fmt::rt::Argument<'_>; 2];
+      let _24: &[core::fmt::rt::Argument<'_>; 2];
+      let mut _26: &std::boxed::Box<dyn std::fmt::Display>;
+      let mut _27: &u32;
+      let mut _28: bool;
+      let mut _29: isize;
+      let mut _30: isize;
+      let mut _31: isize;
++     let _32: std::result::Result<std::boxed::Box<dyn std::fmt::Display>, <T as Err>::Err>;
++     let _33: u32;
       scope 1 {
 -         debug foo => _1;
-+         debug ((foo: Foo<T>).0: std::result::Result<std::boxed::Box<dyn std::fmt::Display>, <T as Err>::Err>) => _29;
-+         debug ((foo: Foo<T>).1: u32) => _30;
++         debug ((foo: Foo<T>).0: std::result::Result<std::boxed::Box<dyn std::fmt::Display>, <T as Err>::Err>) => _32;
++         debug ((foo: Foo<T>).1: u32) => _33;
           let _5: std::result::Result<std::boxed::Box<dyn std::fmt::Display>, <T as Err>::Err>;
           scope 2 {
               debug x => _5;
@@ -42,17 +43,29 @@
                   scope 4 {
                       debug x => _8;
                       let _8: std::boxed::Box<dyn std::fmt::Display>;
-                      let mut _24: &[&str; 3];
+                      let _12: (&std::boxed::Box<dyn std::fmt::Display>, &u32);
++                     let _34: &std::boxed::Box<dyn std::fmt::Display>;
++                     let _35: &u32;
+                      scope 5 {
+-                         debug args => _12;
++                         debug ((args: (&Box<dyn std::fmt::Display>, &u32)).0: &std::boxed::Box<dyn std::fmt::Display>) => _34;
++                         debug ((args: (&Box<dyn std::fmt::Display>, &u32)).1: &u32) => _35;
+                          let _15: [core::fmt::rt::Argument<'_>; 2];
+                          scope 6 {
+                              debug args => _15;
+                              let mut _25: &[&str; 3];
+                          }
+                      }
                   }
               }
           }
       }
   
       bb0: {
-          _25 = const false;
+          _28 = const false;
 -         StorageLive(_1);
-+         StorageLive(_29);
-+         StorageLive(_30);
++         StorageLive(_32);
++         StorageLive(_33);
 +         nop;
           StorageLive(_2);
           StorageLive(_3);
@@ -66,77 +79,93 @@
           _2 = Result::<Box<dyn std::fmt::Display>, <T as Err>::Err>::Ok(move _3);
           StorageDead(_3);
 -         _1 = Foo::<T> { x: move _2, y: const 7_u32 };
-+         _29 = move _2;
-+         _30 = const 7_u32;
++         _32 = move _2;
++         _33 = const 7_u32;
 +         nop;
           StorageDead(_2);
           StorageLive(_5);
-          _25 = const true;
+          _28 = const true;
 -         _5 = move (_1.0: std::result::Result<std::boxed::Box<dyn std::fmt::Display>, <T as Err>::Err>);
-+         _5 = move _29;
++         _5 = move _32;
           StorageLive(_6);
 -         _6 = copy (_1.1: u32);
-+         _6 = copy _30;
++         _6 = copy _33;
           _7 = discriminant(_5);
           switchInt(move _7) -> [0: bb2, otherwise: bb7];
       }
   
       bb2: {
           StorageLive(_8);
-          _25 = const false;
+          _28 = const false;
           _8 = move ((_5 as Ok).0: std::boxed::Box<dyn std::fmt::Display>);
           StorageLive(_9);
           StorageLive(_10);
           StorageLive(_11);
-          StorageLive(_12);
+-         StorageLive(_12);
++         StorageLive(_34);
++         StorageLive(_35);
++         nop;
           StorageLive(_13);
-          _24 = const foo::<T>::promoted[0];
-          _13 = &(*_24);
-          _12 = &(*_13);
+          _13 = &_8;
+          StorageLive(_14);
+          _14 = &_6;
+-         _12 = (move _13, move _14);
++         _34 = move _13;
++         _35 = move _14;
++         nop;
+          StorageDead(_14);
+          StorageDead(_13);
           StorageLive(_15);
           StorageLive(_16);
           StorageLive(_17);
-          StorageLive(_18);
-          StorageLive(_19);
-          StorageLive(_20);
-          _20 = &_8;
-          _19 = &(*_20);
-          _18 = core::fmt::rt::Argument::<'_>::new_display::<Box<dyn std::fmt::Display>>(move _19) -> [return: bb3, unwind unreachable];
+-         _26 = deref_copy (_12.0: &std::boxed::Box<dyn std::fmt::Display>);
++         _26 = deref_copy _34;
+          _17 = &(*_26);
+          _16 = core::fmt::rt::Argument::<'_>::new_display::<Box<dyn std::fmt::Display>>(move _17) -> [return: bb3, unwind unreachable];
       }
   
       bb3: {
-          StorageDead(_19);
-          StorageLive(_21);
-          StorageLive(_22);
-          StorageLive(_23);
-          _23 = &_6;
-          _22 = &(*_23);
-          _21 = core::fmt::rt::Argument::<'_>::new_display::<u32>(move _22) -> [return: bb4, unwind unreachable];
+          StorageDead(_17);
+          StorageLive(_18);
+          StorageLive(_19);
+-         _27 = deref_copy (_12.1: &u32);
++         _27 = deref_copy _35;
+          _19 = &(*_27);
+          _18 = core::fmt::rt::Argument::<'_>::new_display::<u32>(move _19) -> [return: bb4, unwind unreachable];
       }
   
       bb4: {
-          StorageDead(_22);
-          _17 = [move _18, move _21];
-          StorageDead(_21);
+          StorageDead(_19);
+          _15 = [move _16, move _18];
           StorageDead(_18);
-          _16 = &_17;
-          _15 = &(*_16);
-          _11 = core::fmt::rt::<impl Arguments<'_>>::new_v1::<3, 2>(move _12, move _15) -> [return: bb5, unwind unreachable];
+          StorageDead(_16);
+          StorageLive(_20);
+          StorageLive(_21);
+          _25 = const foo::<T>::promoted[0];
+          _21 = &(*_25);
+          _20 = &(*_21);
+          StorageLive(_23);
+          StorageLive(_24);
+          _24 = &_15;
+          _23 = &(*_24);
+          _11 = core::fmt::rt::<impl Arguments<'_>>::new_v1::<3, 2>(move _20, move _23) -> [return: bb5, unwind unreachable];
       }
   
       bb5: {
-          StorageDead(_15);
-          StorageDead(_12);
+          StorageDead(_24);
+          StorageDead(_23);
+          StorageDead(_21);
+          StorageDead(_20);
           _10 = _eprint(move _11) -> [return: bb6, unwind unreachable];
       }
   
       bb6: {
           StorageDead(_11);
-          StorageDead(_23);
-          StorageDead(_20);
-          StorageDead(_17);
-          StorageDead(_16);
-          StorageDead(_13);
+          StorageDead(_15);
+-         StorageDead(_12);
++         StorageDead(_34);
++         StorageDead(_35);
++         nop;
           StorageDead(_10);
           _9 = const ();
           StorageDead(_9);
@@ -156,22 +185,22 @@
   
       bb9: {
           StorageDead(_6);
-          _26 = discriminant(_5);
-          switchInt(move _26) -> [0: bb11, otherwise: bb13];
+          _29 = discriminant(_5);
+          switchInt(move _29) -> [0: bb11, otherwise: bb13];
       }
   
       bb10: {
-          _25 = const false;
+          _28 = const false;
           StorageDead(_5);
 -         StorageDead(_1);
-+         StorageDead(_29);
-+         StorageDead(_30);
++         StorageDead(_32);
++         StorageDead(_33);
 +         nop;
           return;
       }
   
       bb11: {
-          switchInt(copy _25) -> [0: bb10, otherwise: bb12];
+          switchInt(copy _28) -> [0: bb10, otherwise: bb12];
       }
   
       bb12: {
diff --git a/tests/ui/borrowck/clone-on-ref.stderr b/tests/ui/borrowck/clone-on-ref.stderr
index 911c136086c..72580e7464b 100644
--- a/tests/ui/borrowck/clone-on-ref.stderr
+++ b/tests/ui/borrowck/clone-on-ref.stderr
@@ -30,7 +30,7 @@ LL |     drop(x);
    |          ^ move out of `x` occurs here
 LL |
 LL |     println!("{b}");
-   |               --- borrow later used here
+   |                - borrow later used here
    |
 help: if `T` implemented `Clone`, you could clone the value
   --> $DIR/clone-on-ref.rs:11:8
@@ -57,7 +57,7 @@ LL |     drop(x);
    |          ^ move out of `x` occurs here
 LL |
 LL |     println!("{b:?}");
-   |               ----- borrow later used here
+   |                - borrow later used here
    |
 note: if `A` implemented `Clone`, you could clone the value
   --> $DIR/clone-on-ref.rs:19:1
diff --git a/tests/ui/borrowck/issue-114374-invalid-help-fmt-args.rs b/tests/ui/borrowck/issue-114374-invalid-help-fmt-args.rs
deleted file mode 100644
index 4a6c2f9ed06..00000000000
--- a/tests/ui/borrowck/issue-114374-invalid-help-fmt-args.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-#![allow(dead_code)]
-
-fn bar<'a>(_: std::fmt::Arguments<'a>) {}
-fn main() {
-    let x = format_args!("a {} {} {}.", 1, format_args!("b{}!", 2), 3);
-    //~^ ERROR temporary value dropped while borrowed
-
-    bar(x);
-
-    let foo = format_args!("{}", "hi");
-    //~^ ERROR temporary value dropped while borrowed
-    bar(foo);
-
-    let foo = format_args!("hi"); // no placeholder in arguments, so no error
-    bar(foo);
-}
diff --git a/tests/ui/borrowck/issue-114374-invalid-help-fmt-args.stderr b/tests/ui/borrowck/issue-114374-invalid-help-fmt-args.stderr
deleted file mode 100644
index 30f292f71a2..00000000000
--- a/tests/ui/borrowck/issue-114374-invalid-help-fmt-args.stderr
+++ /dev/null
@@ -1,31 +0,0 @@
-error[E0716]: temporary value dropped while borrowed
-  --> $DIR/issue-114374-invalid-help-fmt-args.rs:5:13
-   |
-LL |     let x = format_args!("a {} {} {}.", 1, format_args!("b{}!", 2), 3);
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
-   |             |
-   |             creates a temporary value which is freed while still in use
-...
-LL |     bar(x);
-   |         - borrow later used here
-   |
-   = note: the result of `format_args!` can only be assigned directly if no placeholders in its arguments are used
-   = note: to learn more, visit <https://doc.rust-lang.org/std/macro.format_args.html>
-
-error[E0716]: temporary value dropped while borrowed
-  --> $DIR/issue-114374-invalid-help-fmt-args.rs:10:15
-   |
-LL |     let foo = format_args!("{}", "hi");
-   |               ^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
-   |               |
-   |               creates a temporary value which is freed while still in use
-LL |
-LL |     bar(foo);
-   |         --- borrow later used here
-   |
-   = note: the result of `format_args!` can only be assigned directly if no placeholders in its arguments are used
-   = note: to learn more, visit <https://doc.rust-lang.org/std/macro.format_args.html>
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0716`.
diff --git a/tests/ui/consts/recursive-const-in-impl.stderr b/tests/ui/consts/recursive-const-in-impl.stderr
index 6175112c8cc..035d9c2f21c 100644
--- a/tests/ui/consts/recursive-const-in-impl.stderr
+++ b/tests/ui/consts/recursive-const-in-impl.stderr
@@ -1,11 +1,12 @@
 error: queries overflow the depth limit!
-  --> $DIR/recursive-const-in-impl.rs:11:14
+  --> $DIR/recursive-const-in-impl.rs:11:20
    |
 LL |     println!("{}", Thing::<i32>::X);
-   |              ^^^^
+   |                    ^^^^^^^^^^^^^^^
    |
    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "14"]` attribute to your crate (`recursive_const_in_impl`)
    = note: query depth increased by 9 when simplifying constant for the type system `main::promoted[1]`
+   = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/impl-trait/precise-capturing/foreign-2021.stderr b/tests/ui/impl-trait/precise-capturing/foreign-2021.stderr
index cd9ed0fb885..1dcd800cfc5 100644
--- a/tests/ui/impl-trait/precise-capturing/foreign-2021.stderr
+++ b/tests/ui/impl-trait/precise-capturing/foreign-2021.stderr
@@ -8,7 +8,7 @@ LL |     x.push(0);
    |     ^^^^^^^^^ mutable borrow occurs here
 ...
 LL |     println!("{h}");
-   |               --- immutable borrow later used here
+   |                - immutable borrow later used here
    |
 note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
   --> $DIR/foreign-2021.rs:7:13
diff --git a/tests/ui/impl-trait/precise-capturing/migration-note.stderr b/tests/ui/impl-trait/precise-capturing/migration-note.stderr
index 676b6c12f52..aa0f6400091 100644
--- a/tests/ui/impl-trait/precise-capturing/migration-note.stderr
+++ b/tests/ui/impl-trait/precise-capturing/migration-note.stderr
@@ -23,7 +23,7 @@ LL |     x.push(1);
    |     ^^^^^^^^^ mutable borrow occurs here
 ...
 LL |     println!("{a}");
-   |               --- immutable borrow later used here
+   |                - immutable borrow later used here
    |
 note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
   --> $DIR/migration-note.rs:16:13
@@ -99,7 +99,7 @@ LL |     x.push(1);
    |     ^ second mutable borrow occurs here
 ...
 LL |     println!("{a}");
-   |               --- first borrow later used here
+   |                - first borrow later used here
    |
 note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
   --> $DIR/migration-note.rs:63:13
@@ -175,7 +175,7 @@ LL |     s.f = 1;
    |     ^^^^^^^ `s.f` is assigned to here but it was already borrowed
 ...
 LL |     println!("{a}");
-   |               --- borrow later used here
+   |                - borrow later used here
    |
 note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
   --> $DIR/migration-note.rs:112:13
@@ -197,7 +197,7 @@ LL |     s.f = 1;
    |     ^^^^^^^ `s.f` is assigned to here but it was already borrowed
 ...
 LL |     println!("{a}");
-   |               --- borrow later used here
+   |                - borrow later used here
    |
 note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
   --> $DIR/migration-note.rs:128:13
@@ -219,7 +219,7 @@ LL |     s.f;
    |     ^^^ use of borrowed `s.f`
 ...
 LL |     println!("{a}");
-   |               --- borrow later used here
+   |                - borrow later used here
    |
 note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
   --> $DIR/migration-note.rs:140:13
diff --git a/tests/ui/lifetimes/temporary-lifetime-extension-tuple-ctor.stderr b/tests/ui/lifetimes/temporary-lifetime-extension-tuple-ctor.stderr
index 66f9140f63c..b0d64b531cb 100644
--- a/tests/ui/lifetimes/temporary-lifetime-extension-tuple-ctor.stderr
+++ b/tests/ui/lifetimes/temporary-lifetime-extension-tuple-ctor.stderr
@@ -6,7 +6,7 @@ LL |     let g = some(&temp());
    |                   |
    |                   creates a temporary value which is freed while still in use
 LL |     println!("{a:?} {b:?} {c:?} {d:?} {e:?} {f:?} {g:?}");
-   |                                                   ----- borrow later used here
+   |                                                    - borrow later used here
    |
 help: consider using a `let` binding to create a longer lived value
    |
diff --git a/tests/ui/macros/format-args-temporaries-in-write.stderr b/tests/ui/macros/format-args-temporaries-in-write.stderr
index e58a43383f6..489987899cd 100644
--- a/tests/ui/macros/format-args-temporaries-in-write.stderr
+++ b/tests/ui/macros/format-args-temporaries-in-write.stderr
@@ -13,11 +13,6 @@ LL |     };
    |     -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard`
    |     |
    |     `mutex` dropped here while still borrowed
-   |
-help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
-   |
-LL |         write!(Out, "{}", mutex.lock()); /* no semicolon */
-   |                                        +
 
 error[E0597]: `mutex` does not live long enough
   --> $DIR/format-args-temporaries-in-write.rs:47:29
@@ -34,11 +29,6 @@ LL |     };
    |     -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard`
    |     |
    |     `mutex` dropped here while still borrowed
-   |
-help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
-   |
-LL |         writeln!(Out, "{}", mutex.lock()); /* no semicolon */
-   |                                          +
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/sized/unsized-binding.rs b/tests/ui/sized/unsized-binding.rs
index 3b99b0f6e96..ce6c1527376 100644
--- a/tests/ui/sized/unsized-binding.rs
+++ b/tests/ui/sized/unsized-binding.rs
@@ -1,5 +1,5 @@
 fn main() {
     let x = *""; //~ ERROR E0277
-    println!("{}", x);
-    println!("{}", x);
+    drop(x);
+    drop(x);
 }
diff --git a/tests/ui/suggestions/issue-97760.stderr b/tests/ui/suggestions/issue-97760.stderr
index c3cf7e13987..ddd143b967c 100644
--- a/tests/ui/suggestions/issue-97760.stderr
+++ b/tests/ui/suggestions/issue-97760.stderr
@@ -1,8 +1,8 @@
 error[E0277]: `<impl IntoIterator as IntoIterator>::Item` doesn't implement `std::fmt::Display`
-  --> $DIR/issue-97760.rs:4:19
+  --> $DIR/issue-97760.rs:4:20
    |
 LL |         println!("{x}");
-   |                   ^^^ `<impl IntoIterator as IntoIterator>::Item` cannot be formatted with the default formatter
+   |                    ^ `<impl IntoIterator as IntoIterator>::Item` cannot be formatted with the default formatter
    |
    = help: the trait `std::fmt::Display` is not implemented for `<impl IntoIterator as IntoIterator>::Item`
    = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
diff --git a/tests/ui/unpretty/exhaustive.hir.stdout b/tests/ui/unpretty/exhaustive.hir.stdout
index c20f123b16e..5d6e3907d75 100644
--- a/tests/ui/unpretty/exhaustive.hir.stdout
+++ b/tests/ui/unpretty/exhaustive.hir.stdout
@@ -405,8 +405,10 @@ mod expressions {
     fn expr_format_args() {
         let expr;
         format_arguments::new_const(&[]);
-        format_arguments::new_v1(&[""],
-            &[format_argument::new_display(&expr)]);
+        {
+            super let args = [format_argument::new_display(&expr)];
+            format_arguments::new_v1(&[""], &args)
+        };
     }
 }
 mod items {
diff --git a/tests/ui/unpretty/flattened-format-args.stdout b/tests/ui/unpretty/flattened-format-args.stdout
index a5d943281ad..4af82924c7b 100644
--- a/tests/ui/unpretty/flattened-format-args.stdout
+++ b/tests/ui/unpretty/flattened-format-args.stdout
@@ -10,7 +10,9 @@ fn main() {
     let x = 1;
     // Should flatten to println!("a 123 b {x} xyz\n"):
     {
-        ::std::io::_print(format_arguments::new_v1(&["a 123 b ", " xyz\n"],
-                &[format_argument::new_display(&x)]));
+        ::std::io::_print({
+                super let args = [format_argument::new_display(&x)];
+                format_arguments::new_v1(&["a 123 b ", " xyz\n"], &args)
+            });
     };
 }