summaryrefslogtreecommitdiffstats
path: root/src/test/ui/macros/issue-99265.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/macros/issue-99265.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/macros/issue-99265.rs')
-rw-r--r--src/test/ui/macros/issue-99265.rs139
1 files changed, 139 insertions, 0 deletions
diff --git a/src/test/ui/macros/issue-99265.rs b/src/test/ui/macros/issue-99265.rs
new file mode 100644
index 000000000..e7cf60876
--- /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
+}