diff options
| author | Preston From <prestonfrom@gmail.com> | 2022-07-16 15:13:14 -0600 |
|---|---|---|
| committer | Preston From <prestonfrom@gmail.com> | 2022-07-25 00:00:27 -0600 |
| commit | 3330c7d1c3bcfd2c452b794db66705b92fb54a3c (patch) | |
| tree | 54a0678eba5caf07335b5a1ede0314f515bde6f8 /src/test/ui/macros/issue-98466.stderr | |
| parent | 530c0a81d50c6e1c9b1bdee0970d27af02ca49be (diff) | |
| download | rust-3330c7d1c3bcfd2c452b794db66705b92fb54a3c.tar.gz | |
Generate correct suggestion with named arguments used positionally
Address issue #99265 by checking each positionally used argument
to see if the argument is named and adding a lint to use the name
instead. This way, when named arguments are used positionally in a
different order than their argument order, the suggested lint is
correct.
For example:
```
println!("{b} {}", a=1, b=2);
```
This will now generate the suggestion:
```
println!("{b} {a}", a=1, b=2);
```
Additionally, this check now also correctly replaces or inserts
only where the positional argument is (or would be if implicit).
Also, width and precision are replaced with their argument names
when they exists.
Since the issues were so closely related, this fix for issue #99265
also fixes issue #99266.
Fixes #99265
Fixes #99266
Diffstat (limited to 'src/test/ui/macros/issue-98466.stderr')
| -rw-r--r-- | src/test/ui/macros/issue-98466.stderr | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/test/ui/macros/issue-98466.stderr b/src/test/ui/macros/issue-98466.stderr index ad11d181b62..4a39dd1440b 100644 --- a/src/test/ui/macros/issue-98466.stderr +++ b/src/test/ui/macros/issue-98466.stderr @@ -2,80 +2,80 @@ warning: named argument `_x` is not used by name --> $DIR/issue-98466.rs:7:26 | LL | println!("_x is {}", _x = 5); - | -- ^^ this named argument is only referred to by position in formatting string - | | - | this formatting argument uses named argument `_x` by position + | - ^^ this named argument is only referred to by position in formatting string + | | + | this formatting argument uses named argument `_x` by position | = note: `#[warn(named_arguments_used_positionally)]` on by default help: use the named argument by name to avoid ambiguity | LL | println!("_x is {_x}", _x = 5); - | ~~~~ + | ++ warning: named argument `y` is not used by name --> $DIR/issue-98466.rs:10:26 | LL | println!("_x is {}", y = _x); - | -- ^ this named argument is only referred to by position in formatting string - | | - | this formatting argument uses named argument `y` by position + | - ^ this named argument is only referred to by position in formatting string + | | + | this formatting argument uses named argument `y` by position | help: use the named argument by name to avoid ambiguity | LL | println!("_x is {y}", y = _x); - | ~~~ + | + warning: named argument `y` is not used by name --> $DIR/issue-98466.rs:13:83 | LL | println!("first positional arg {}, second positional arg {}, _x is {}", 1, 2, y = _x); - | -- ^ this named argument is only referred to by position in formatting string - | | - | this formatting argument uses named argument `y` by position + | - ^ this named argument is only referred to by position in formatting string + | | + | this formatting argument uses named argument `y` by position | help: use the named argument by name to avoid ambiguity | LL | println!("first positional arg {}, second positional arg {}, _x is {y}", 1, 2, y = _x); - | ~~~ + | + warning: named argument `_x` is not used by name --> $DIR/issue-98466.rs:19:34 | LL | let _f = format!("_x is {}", _x = 5); - | -- ^^ this named argument is only referred to by position in formatting string - | | - | this formatting argument uses named argument `_x` by position + | - ^^ this named argument is only referred to by position in formatting string + | | + | this formatting argument uses named argument `_x` by position | help: use the named argument by name to avoid ambiguity | LL | let _f = format!("_x is {_x}", _x = 5); - | ~~~~ + | ++ warning: named argument `y` is not used by name --> $DIR/issue-98466.rs:22:34 | LL | let _f = format!("_x is {}", y = _x); - | -- ^ this named argument is only referred to by position in formatting string - | | - | this formatting argument uses named argument `y` by position + | - ^ this named argument is only referred to by position in formatting string + | | + | this formatting argument uses named argument `y` by position | help: use the named argument by name to avoid ambiguity | LL | let _f = format!("_x is {y}", y = _x); - | ~~~ + | + warning: named argument `y` is not used by name --> $DIR/issue-98466.rs:25:91 | LL | let _f = format!("first positional arg {}, second positional arg {}, _x is {}", 1, 2, y = _x); - | -- ^ this named argument is only referred to by position in formatting string - | | - | this formatting argument uses named argument `y` by position + | - ^ this named argument is only referred to by position in formatting string + | | + | this formatting argument uses named argument `y` by position | help: use the named argument by name to avoid ambiguity | LL | let _f = format!("first positional arg {}, second positional arg {}, _x is {y}", 1, 2, y = _x); - | ~~~ + | + warning: 6 warnings emitted |
