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)],
));
};
```
This commit is contained in:
commit
0bcacb391b
11 changed files with 128 additions and 96 deletions
|
|
@ -9,10 +9,5 @@ extern crate std;
|
|||
// pp-exact:dollar-crate.pp
|
||||
|
||||
fn main() {
|
||||
{
|
||||
::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"],
|
||||
&match () {
|
||||
_args => [],
|
||||
}));
|
||||
};
|
||||
{ ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &[])); };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,16 +41,7 @@ pub fn bar() ({
|
|||
[&str; 1])
|
||||
as
|
||||
&[&str; 1]),
|
||||
(&(match (()
|
||||
as
|
||||
())
|
||||
{
|
||||
_args
|
||||
=>
|
||||
([]
|
||||
as
|
||||
[ArgumentV1; 0]),
|
||||
}
|
||||
(&([]
|
||||
as
|
||||
[ArgumentV1; 0])
|
||||
as
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
29| 1| some_string = Some(String::from("the string content"));
|
||||
30| 1| let
|
||||
31| 1| a
|
||||
32| 1| =
|
||||
33| 1| ||
|
||||
32| | =
|
||||
33| | ||
|
||||
34| 0| {
|
||||
35| 0| let mut countdown = 0;
|
||||
36| 0| if is_false {
|
||||
|
|
@ -173,7 +173,7 @@
|
|||
169| | ;
|
||||
170| |
|
||||
171| 1| let short_used_not_covered_closure_line_break_no_block_embedded_branch =
|
||||
172| 1| | _unused_arg: u8 |
|
||||
172| | | _unused_arg: u8 |
|
||||
173| 0| println!(
|
||||
174| 0| "not called: {}",
|
||||
175| 0| if is_true { "check" } else { "me" }
|
||||
|
|
|
|||
|
|
@ -18,11 +18,8 @@ LL | bug!();
|
|||
error: unexpected token: `{
|
||||
let res =
|
||||
::alloc::fmt::format(::core::fmt::Arguments::new_v1(&[""],
|
||||
&match (&"u8",) {
|
||||
_args =>
|
||||
[::core::fmt::ArgumentV1::new(_args.0,
|
||||
::core::fmt::Display::fmt)],
|
||||
}));
|
||||
&[::core::fmt::ArgumentV1::new(&"u8",
|
||||
::core::fmt::Display::fmt)]));
|
||||
res
|
||||
}.as_str()`
|
||||
--> $DIR/key-value-expansion.rs:48:23
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ LL | let c1 : () = c;
|
|||
| expected due to this
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found closure `[mod1::f<T>::{closure#0} closure_substs=(unavailable) substs=[T, _#22t, extern "rust-call" fn(()), _#23t]]`
|
||||
found closure `[mod1::f<T>::{closure#0} closure_substs=(unavailable) substs=[T, _#19t, extern "rust-call" fn(()), _#20t]]`
|
||||
help: use parentheses to call this closure
|
||||
|
|
||||
LL | let c1 : () = c();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ LL | let c1 : () = c;
|
|||
| expected due to this
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found closure `[f<T>::{closure#0} closure_substs=(unavailable) substs=[T, _#22t, extern "rust-call" fn(()), _#23t]]`
|
||||
found closure `[f<T>::{closure#0} closure_substs=(unavailable) substs=[T, _#19t, extern "rust-call" fn(()), _#20t]]`
|
||||
help: use parentheses to call this closure
|
||||
|
|
||||
LL | let c1 : () = c();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,16 @@
|
|||
error[E0284]: type annotations needed: cannot satisfy `<u64 as Test<_>>::Output == _`
|
||||
--> $DIR/issue-69455.rs:29:26
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/issue-69455.rs:29:5
|
||||
|
|
||||
LL | type Output;
|
||||
| ------------ `<Self as Test<Rhs>>::Output` defined here
|
||||
...
|
||||
LL | println!("{}", 23u64.test(xs.iter().sum()));
|
||||
| ^^^^ cannot satisfy `<u64 as Test<_>>::Output == _`
|
||||
| ^^^^^^^^^^^^^^^---------------------------^
|
||||
| | |
|
||||
| | this method call resolves to `<Self as Test<Rhs>>::Output`
|
||||
| cannot infer type for type parameter `T` declared on the associated function `new`
|
||||
|
|
||||
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0283]: type annotations needed
|
||||
--> $DIR/issue-69455.rs:29:26
|
||||
|
|
@ -25,5 +33,5 @@ LL | println!("{}", 23u64.test(xs.iter().sum::<S>()));
|
|||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0283, E0284.
|
||||
For more information about an error, try `rustc --explain E0283`.
|
||||
Some errors have detailed explanations: E0282, E0283.
|
||||
For more information about an error, try `rustc --explain E0282`.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue