Skip to content

Commit

Permalink
Auto merge of rust-lang#91359 - dtolnay:args, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
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)],
    ));
};
```
  • Loading branch information
bors committed Jan 21, 2022
2 parents 5a25c0e + c422824 commit ec00cf8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/ui/to_string_in_display.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,14 @@ LL | write!(f, "{}", self.to_string())
|
= note: `-D clippy::to-string-in-display` implied by `-D warnings`

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

error: aborting due to 2 previous errors

0 comments on commit ec00cf8

Please sign in to comment.