about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-01-21 06:20:18 +0000
committerbors <bors@rust-lang.org>2022-01-21 06:20:18 +0000
commitec00cf80a306abe59e99ffdb4bfcc55b022fc5b7 (patch)
tree91fe3ecdd29046ff9d88cb16703d773372e583e5 /tests
parent5a25c0e6e95fb8dc7138b9028c8c76698b637449 (diff)
parentc4228242753837ce2c78c78c644d9dbd1e5b2540 (diff)
downloadrust-ec00cf80a306abe59e99ffdb4bfcc55b022fc5b7.tar.gz
rust-ec00cf80a306abe59e99ffdb4bfcc55b022fc5b7.zip
Auto merge of #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)],
    ));
};
```
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/to_string_in_display.stderr11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/ui/to_string_in_display.stderr b/tests/ui/to_string_in_display.stderr
index 5f26ef413e2..80189ca1f0a 100644
--- a/tests/ui/to_string_in_display.stderr
+++ b/tests/ui/to_string_in_display.stderr
@@ -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