From 4d840223b004aac41a2307fdd4aba07082164731 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Thu, 16 Mar 2023 12:16:27 +0100 Subject: [PATCH] Add test for -Zflatten-format-args=yes. --- tests/ui/unpretty/flattened-format-args.rs | 8 ++++++++ tests/ui/unpretty/flattened-format-args.stdout | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/ui/unpretty/flattened-format-args.rs create mode 100644 tests/ui/unpretty/flattened-format-args.stdout diff --git a/tests/ui/unpretty/flattened-format-args.rs b/tests/ui/unpretty/flattened-format-args.rs new file mode 100644 index 00000000000..705dded169a --- /dev/null +++ b/tests/ui/unpretty/flattened-format-args.rs @@ -0,0 +1,8 @@ +// compile-flags: -Zunpretty=hir -Zflatten-format-args=yes +// check-pass + +fn main() { + let x = 1; + // Should flatten to println!("a 123 b {x} xyz\n"): + println!("a {} {}", format_args!("{} b {x}", 123), "xyz"); +} diff --git a/tests/ui/unpretty/flattened-format-args.stdout b/tests/ui/unpretty/flattened-format-args.stdout new file mode 100644 index 00000000000..a8fe8da0024 --- /dev/null +++ b/tests/ui/unpretty/flattened-format-args.stdout @@ -0,0 +1,16 @@ +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// compile-flags: -Zunpretty=hir -Zflatten-format-args=yes +// check-pass + +fn main() { + let x = 1; + // Should flatten to println!("a 123 b {x} xyz\n"): + { + ::std::io::_print(<#[lang = "format_arguments"]>::new_v1(&["a 123 b ", + " xyz\n"], + &[<#[lang = "format_argument"]>::new_display(&x)])); + }; + }