summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorPreston From <prestonfrom@gmail.com>2022-07-16 15:13:14 -0600
committerPreston From <prestonfrom@gmail.com>2022-07-25 00:00:27 -0600
commit3330c7d1c3bcfd2c452b794db66705b92fb54a3c (patch)
tree54a0678eba5caf07335b5a1ede0314f515bde6f8 /src/test
parent530c0a81d50c6e1c9b1bdee0970d27af02ca49be (diff)
downloadrust-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')
-rw-r--r--src/test/ui/macros/issue-98466.stderr48
-rw-r--r--src/test/ui/macros/issue-99265.fixed139
-rw-r--r--src/test/ui/macros/issue-99265.rs139
-rw-r--r--src/test/ui/macros/issue-99265.stderr562
4 files changed, 864 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
diff --git a/src/test/ui/macros/issue-99265.fixed b/src/test/ui/macros/issue-99265.fixed
new file mode 100644
index 00000000000..f3be9c6285d
--- /dev/null
+++ b/src/test/ui/macros/issue-99265.fixed
@@ -0,0 +1,139 @@
+// check-pass
+// run-rustfix
+
+fn main() {
+ println!("{b} {a}", a=1, b=2);
+ //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("{} {a} {b} {c} {d}", 0, a=1, b=2, c=3, d=4);
+ //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `b` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `c` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `d` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("Hello {:width$}!", "x", width = 5);
+ //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("Hello {f:width$.precision$}!", f = 0.02f32, width = 5, precision = 2);
+ //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
+ //~| WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("Hello {f:width$.precision$}!", f = 0.02f32, width = 5, precision = 2);
+ //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
+ //~| WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!(
+ "{}, Hello {f:width$.precision$} {g:width2$.precision2$}! {f}",
+ //~^ HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ 1,
+ f = 0.02f32,
+ //~^ WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ width = 5,
+ //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
+ precision = 2,
+ //~^ WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
+ g = 0.02f32,
+ //~^ WARNING named argument `g` is not used by name [named_arguments_used_positionally]
+ width2 = 5,
+ //~^ WARNING named argument `width2` is not used by name [named_arguments_used_positionally
+ precision2 = 2
+ //~^ WARNING named argument `precision2` is not used by name [named_arguments_used_positionally]
+ );
+
+ println!("Hello {f:0.1}!", f = 0.02f32);
+ //~^ WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("Hello {f:0.1}!", f = 0.02f32);
+ //~^ WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("Hello {f:width$.precision$}!", f = 0.02f32, width = 5, precision = 2);
+
+ let width = 5;
+ let precision = 2;
+ println!("Hello {f:width$.precision$}!", f = 0.02f32);
+
+ let val = 5;
+ println!("{v:v$}", v = val);
+ //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ println!("{v:v$}", v = val);
+ //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ println!("{v:v$.v$}", v = val);
+ //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ println!("{v:v$.v$}", v = val);
+ //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("{a} {a} {a}", a = 1);
+ //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("aaaaaaaaaaaaaaa\
+ {a:b$.c$}",
+ //~^ HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ a = 1.0, b = 1, c = 2,
+ //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `b` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `c` is not used by name [named_arguments_used_positionally]
+ );
+
+ println!("aaaaaaaaaaaaaaa\
+ {a:b$.c$}",
+ //~^ HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ a = 1.0, b = 1, c = 2,
+ //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `b` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `c` is not used by name [named_arguments_used_positionally]
+ );
+
+ println!("{{{x:width$.precision$}}}", x = 1.0, width = 3, precision = 2);
+ //~^ WARNING named argument `x` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `width` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+}
diff --git a/src/test/ui/macros/issue-99265.rs b/src/test/ui/macros/issue-99265.rs
new file mode 100644
index 00000000000..e7cf608765b
--- /dev/null
+++ b/src/test/ui/macros/issue-99265.rs
@@ -0,0 +1,139 @@
+// check-pass
+// run-rustfix
+
+fn main() {
+ println!("{b} {}", a=1, b=2);
+ //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("{} {} {} {} {}", 0, a=1, b=2, c=3, d=4);
+ //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `b` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `c` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `d` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("Hello {:1$}!", "x", width = 5);
+ //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("Hello {:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
+ //~| WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("Hello {0:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
+ //~| WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!(
+ "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
+ //~^ HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ 1,
+ f = 0.02f32,
+ //~^ WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ width = 5,
+ //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
+ precision = 2,
+ //~^ WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
+ g = 0.02f32,
+ //~^ WARNING named argument `g` is not used by name [named_arguments_used_positionally]
+ width2 = 5,
+ //~^ WARNING named argument `width2` is not used by name [named_arguments_used_positionally
+ precision2 = 2
+ //~^ WARNING named argument `precision2` is not used by name [named_arguments_used_positionally]
+ );
+
+ println!("Hello {:0.1}!", f = 0.02f32);
+ //~^ WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("Hello {0:0.1}!", f = 0.02f32);
+ //~^ WARNING named argument `f` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("Hello {f:width$.precision$}!", f = 0.02f32, width = 5, precision = 2);
+
+ let width = 5;
+ let precision = 2;
+ println!("Hello {f:width$.precision$}!", f = 0.02f32);
+
+ let val = 5;
+ println!("{:0$}", v = val);
+ //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ println!("{0:0$}", v = val);
+ //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ println!("{:0$.0$}", v = val);
+ //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ println!("{0:0$.0$}", v = val);
+ //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("{} {a} {0}", a = 1);
+ //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+
+ println!("aaaaaaaaaaaaaaa\
+ {:1$.2$}",
+ //~^ HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ a = 1.0, b = 1, c = 2,
+ //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `b` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `c` is not used by name [named_arguments_used_positionally]
+ );
+
+ println!("aaaaaaaaaaaaaaa\
+ {0:1$.2$}",
+ //~^ HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ a = 1.0, b = 1, c = 2,
+ //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `b` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `c` is not used by name [named_arguments_used_positionally]
+ );
+
+ println!("{{{:1$.2$}}}", x = 1.0, width = 3, precision = 2);
+ //~^ WARNING named argument `x` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `width` is not used by name [named_arguments_used_positionally]
+ //~| WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+ //~| HELP use the named argument by name to avoid ambiguity
+}
diff --git a/src/test/ui/macros/issue-99265.stderr b/src/test/ui/macros/issue-99265.stderr
new file mode 100644
index 00000000000..0798ad8dc51
--- /dev/null
+++ b/src/test/ui/macros/issue-99265.stderr
@@ -0,0 +1,562 @@
+warning: named argument `a` is not used by name
+ --> $DIR/issue-99265.rs:5:24
+ |
+LL | println!("{b} {}", a=1, b=2);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `a` by position
+ |
+ = note: `#[warn(named_arguments_used_positionally)]` on by default
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{b} {a}", a=1, b=2);
+ | +
+
+warning: named argument `a` is not used by name
+ --> $DIR/issue-99265.rs:9:35
+ |
+LL | println!("{} {} {} {} {}", 0, a=1, b=2, c=3, d=4);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `a` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{} {a} {} {} {}", 0, a=1, b=2, c=3, d=4);
+ | +
+
+warning: named argument `b` is not used by name
+ --> $DIR/issue-99265.rs:9:40
+ |
+LL | println!("{} {} {} {} {}", 0, a=1, b=2, c=3, d=4);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `b` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{} {} {b} {} {}", 0, a=1, b=2, c=3, d=4);
+ | +
+
+warning: named argument `c` is not used by name
+ --> $DIR/issue-99265.rs:9:45
+ |
+LL | println!("{} {} {} {} {}", 0, a=1, b=2, c=3, d=4);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `c` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{} {} {} {c} {}", 0, a=1, b=2, c=3, d=4);
+ | +
+
+warning: named argument `d` is not used by name
+ --> $DIR/issue-99265.rs:9:50
+ |
+LL | println!("{} {} {} {} {}", 0, a=1, b=2, c=3, d=4);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `d` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{} {} {} {} {d}", 0, a=1, b=2, c=3, d=4);
+ | +
+
+warning: named argument `width` is not used by name
+ --> $DIR/issue-99265.rs:19:35
+ |
+LL | println!("Hello {:1$}!", "x", width = 5);
+ | -- ^^^^^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `width$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("Hello {:width$}!", "x", width = 5);
+ | ~~~~~~
+
+warning: named argument `width` is not used by name
+ --> $DIR/issue-99265.rs:23:46
+ |
+LL | println!("Hello {:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | -- ^^^^^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `width$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("Hello {:width$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | ~~~~~~
+
+warning: named argument `precision` is not used by name
+ --> $DIR/issue-99265.rs:23:57
+ |
+LL | println!("Hello {:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | -- ^^^^^^^^^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `precision$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("Hello {:1$.precision$}!", f = 0.02f32, width = 5, precision = 2);
+ | ~~~~~~~~~~
+
+warning: named argument `f` is not used by name
+ --> $DIR/issue-99265.rs:23:33
+ |
+LL | println!("Hello {:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `f` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("Hello {f:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | +
+
+warning: named argument `width` is not used by name
+ --> $DIR/issue-99265.rs:31:47
+ |
+LL | println!("Hello {0:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | -- ^^^^^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `width$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("Hello {0:width$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | ~~~~~~
+
+warning: named argument `precision` is not used by name
+ --> $DIR/issue-99265.rs:31:58
+ |
+LL | println!("Hello {0:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | -- ^^^^^^^^^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `precision$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("Hello {0:1$.precision$}!", f = 0.02f32, width = 5, precision = 2);
+ | ~~~~~~~~~~
+
+warning: named argument `f` is not used by name
+ --> $DIR/issue-99265.rs:31:34
+ |
+LL | println!("Hello {0:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `f` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("Hello {f:1$.2$}!", f = 0.02f32, width = 5, precision = 2);
+ | ~
+
+warning: named argument `width` is not used by name
+ --> $DIR/issue-99265.rs:52:9
+ |
+LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
+ | -- this formatting argument uses named argument `width$` by position
+...
+LL | width = 5,
+ | ^^^^^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | "{}, Hello {1:width$.3$} {4:5$.6$}! {1}",
+ | ~~~~~~
+
+warning: named argument `precision` is not used by name
+ --> $DIR/issue-99265.rs:54:9
+ |
+LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
+ | -- this formatting argument uses named argument `precision$` by position
+...
+LL | precision = 2,
+ | ^^^^^^^^^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | "{}, Hello {1:2$.precision$} {4:5$.6$}! {1}",
+ | ~~~~~~~~~~
+
+warning: named argument `f` is not used by name
+ --> $DIR/issue-99265.rs:49:9
+ |
+LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
+ | - this formatting argument uses named argument `f` by position
+...
+LL | f = 0.02f32,
+ | ^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | "{}, Hello {f:2$.3$} {4:5$.6$}! {1}",
+ | ~
+
+warning: named argument `width2` is not used by name
+ --> $DIR/issue-99265.rs:58:9
+ |
+LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
+ | -- this formatting argument uses named argument `width2$` by position
+...
+LL | width2 = 5,
+ | ^^^^^^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | "{}, Hello {1:2$.3$} {4:width2$.6$}! {1}",
+ | ~~~~~~~
+
+warning: named argument `precision2` is not used by name
+ --> $DIR/issue-99265.rs:60:9
+ |
+LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
+ | -- this formatting argument uses named argument `precision2$` by position
+...
+LL | precision2 = 2
+ | ^^^^^^^^^^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | "{}, Hello {1:2$.3$} {4:5$.precision2$}! {1}",
+ | ~~~~~~~~~~~
+
+warning: named argument `g` is not used by name
+ --> $DIR/issue-99265.rs:56:9
+ |
+LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
+ | - this formatting argument uses named argument `g` by position
+...
+LL | g = 0.02f32,
+ | ^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | "{}, Hello {1:2$.3$} {g:5$.6$}! {1}",
+ | ~
+
+warning: named argument `f` is not used by name
+ --> $DIR/issue-99265.rs:49:9
+ |
+LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {1}",
+ | - this formatting argument uses named argument `f` by position
+...
+LL | f = 0.02f32,
+ | ^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | "{}, Hello {1:2$.3$} {4:5$.6$}! {f}",
+ | ~
+
+warning: named argument `f` is not used by name
+ --> $DIR/issue-99265.rs:64:31
+ |
+LL | println!("Hello {:0.1}!", f = 0.02f32);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `f` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("Hello {f:0.1}!", f = 0.02f32);
+ | +
+
+warning: named argument `f` is not used by name
+ --> $DIR/issue-99265.rs:68:32
+ |
+LL | println!("Hello {0:0.1}!", f = 0.02f32);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `f` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("Hello {f:0.1}!", f = 0.02f32);
+ | ~
+
+warning: named argument `v` is not used by name
+ --> $DIR/issue-99265.rs:79:23
+ |
+LL | println!("{:0$}", v = val);
+ | -- ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{:v$}", v = val);
+ | ~~
+
+warning: named argument `v` is not used by name
+ --> $DIR/issue-99265.rs:79:23
+ |
+LL | println!("{:0$}", v = val);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{v:0$}", v = val);
+ | +
+
+warning: named argument `v` is not used by name
+ --> $DIR/issue-99265.rs:84:24
+ |
+LL | println!("{0:0$}", v = val);
+ | -- ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{0:v$}", v = val);
+ | ~~
+
+warning: named argument `v` is not used by name
+ --> $DIR/issue-99265.rs:84:24
+ |
+LL | println!("{0:0$}", v = val);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{v:0$}", v = val);
+ | ~
+
+warning: named argument `v` is not used by name
+ --> $DIR/issue-99265.rs:89:26
+ |
+LL | println!("{:0$.0$}", v = val);
+ | -- ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{:v$.0$}", v = val);
+ | ~~
+
+warning: named argument `v` is not used by name
+ --> $DIR/issue-99265.rs:89:26
+ |
+LL | println!("{:0$.0$}", v = val);
+ | -- ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{:0$.v$}", v = val);
+ | ~~
+
+warning: named argument `v` is not used by name
+ --> $DIR/issue-99265.rs:89:26
+ |
+LL | println!("{:0$.0$}", v = val);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{v:0$.0$}", v = val);
+ | +
+
+warning: named argument `v` is not used by name
+ --> $DIR/issue-99265.rs:96:27
+ |
+LL | println!("{0:0$.0$}", v = val);
+ | -- ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{0:v$.0$}", v = val);
+ | ~~
+
+warning: named argument `v` is not used by name
+ --> $DIR/issue-99265.rs:96:27
+ |
+LL | println!("{0:0$.0$}", v = val);
+ | -- ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{0:0$.v$}", v = val);
+ | ~~
+
+warning: named argument `v` is not used by name
+ --> $DIR/issue-99265.rs:96:27
+ |
+LL | println!("{0:0$.0$}", v = val);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `v` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{v:0$.0$}", v = val);
+ | ~
+
+warning: named argument `a` is not used by name
+ --> $DIR/issue-99265.rs:104:28
+ |
+LL | println!("{} {a} {0}", a = 1);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `a` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{a} {a} {0}", a = 1);
+ | +
+
+warning: named argument `a` is not used by name
+ --> $DIR/issue-99265.rs:104:28
+ |
+LL | println!("{} {a} {0}", a = 1);
+ | - ^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `a` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{} {a} {a}", a = 1);
+ | ~
+
+warning: named argument `b` is not used by name
+ --> $DIR/issue-99265.rs:115:23
+ |
+LL | {:1$.2$}",
+ | -- this formatting argument uses named argument `b$` by position
+...
+LL | a = 1.0, b = 1, c = 2,
+ | ^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | {:b$.2$}",
+ | ~~
+
+warning: named argument `c` is not used by name
+ --> $DIR/issue-99265.rs:115:30
+ |
+LL | {:1$.2$}",
+ | -- this formatting argument uses named argument `c$` by position
+...
+LL | a = 1.0, b = 1, c = 2,
+ | ^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | {:1$.c$}",
+ | ~~
+
+warning: named argument `a` is not used by name
+ --> $DIR/issue-99265.rs:115:14
+ |
+LL | {:1$.2$}",
+ | - this formatting argument uses named argument `a` by position
+...
+LL | a = 1.0, b = 1, c = 2,
+ | ^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | {a:1$.2$}",
+ | +
+
+warning: named argument `b` is not used by name
+ --> $DIR/issue-99265.rs:126:23
+ |
+LL | {0:1$.2$}",
+ | -- this formatting argument uses named argument `b$` by position
+...
+LL | a = 1.0, b = 1, c = 2,
+ | ^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | {0:b$.2$}",
+ | ~~
+
+warning: named argument `c` is not used by name
+ --> $DIR/issue-99265.rs:126:30
+ |
+LL | {0:1$.2$}",
+ | -- this formatting argument uses named argument `c$` by position
+...
+LL | a = 1.0, b = 1, c = 2,
+ | ^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | {0:1$.c$}",
+ | ~~
+
+warning: named argument `a` is not used by name
+ --> $DIR/issue-99265.rs:126:14
+ |
+LL | {0:1$.2$}",
+ | - this formatting argument uses named argument `a` by position
+...
+LL | a = 1.0, b = 1, c = 2,
+ | ^ this named argument is only referred to by position in formatting string
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | {a:1$.2$}",
+ | ~
+
+warning: named argument `width` is not used by name
+ --> $DIR/issue-99265.rs:132:39
+ |
+LL | println!("{{{:1$.2$}}}", x = 1.0, width = 3, precision = 2);
+ | -- ^^^^^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `width$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{{{:width$.2$}}}", x = 1.0, width = 3, precision = 2);
+ | ~~~~~~
+
+warning: named argument `precision` is not used by name
+ --> $DIR/issue-99265.rs:132:50
+ |
+LL | println!("{{{:1$.2$}}}", x = 1.0, width = 3, precision = 2);
+ | -- ^^^^^^^^^ this named argument is only referred to by position in formatting string
+ | |
+ | this formatting argument uses named argument `precision$` by position
+ |
+help: use the named argument by name to avoid ambiguity
+ |
+LL | println!("{{{:1$.precision$}}}", x = 1.0, width = 3, precision = 2);
+ | ~~~~~~~~~~
+
+warning: named argument `x` is not used by name
+ --> $DIR/issue-99265.rs:132:30
+ |
+LL | println!("{{{:1$.2$}}}", x = 1.0, width = 3, precision = 2);
+ | - ^ 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 | println!("{{{x:1$.2$}}}", x = 1.0, width = 3, precision = 2);
+ | +
+
+warning: 42 warnings emitted
+