Skip to content

Commit ec00cf8

Browse files
committed
Auto merge of rust-lang#91359 - dtolnay:args, r=Mark-Simulacrum
Emit simpler code from format_args I made this PR so that `cargo expand` dumps a less overwhelming amount of formatting-related code. <br> `println!("rust")` **Before:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &match () { _args => [], })); }; ``` **After:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &[])); }; ``` `println!("{}", x)` **Before:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1( &["", "\n"], &match (&x,) { _args => [::core::fmt::ArgumentV1::new( _args.0, ::core::fmt::Display::fmt, )], }, )); }; ``` **After:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1( &["", "\n"], &[::core::fmt::ArgumentV1::new(&x, ::core::fmt::Display::fmt)], )); }; ```
2 parents 5a25c0e + c422824 commit ec00cf8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/ui/to_string_in_display.stderr

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,14 @@ LL | write!(f, "{}", self.to_string())
66
|
77
= note: `-D clippy::to-string-in-display` implied by `-D warnings`
88

9-
error: aborting due to previous error
9+
error: unnecessary use of `to_string`
10+
--> $DIR/to_string_in_display.rs:55:50
11+
|
12+
LL | Self::E(string) => write!(f, "E {}", string.to_string()),
13+
| ^^^^^^^^^^^^^^^^^^
14+
|
15+
= note: `-D clippy::unnecessary-to-owned` implied by `-D warnings`
16+
= note: this error originates in the macro `$crate::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
17+
18+
error: aborting due to 2 previous errors
1019

0 commit comments

Comments
 (0)