fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
7.9 KiB139 linesraw
1// check-pass
2// run-rustfix
3
4fn main() {
5    println!("{b} {a}", a=1, b=2);
6    //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
7    //~| HELP use the named argument by name to avoid ambiguity
8
9    println!("{} {a} {b} {c} {d}", 0, a=1, b=2, c=3, d=4);
10    //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
11    //~| WARNING named argument `b` is not used by name [named_arguments_used_positionally]
12    //~| WARNING named argument `c` is not used by name [named_arguments_used_positionally]
13    //~| WARNING named argument `d` is not used by name [named_arguments_used_positionally]
14    //~| HELP use the named argument by name to avoid ambiguity
15    //~| HELP use the named argument by name to avoid ambiguity
16    //~| HELP use the named argument by name to avoid ambiguity
17    //~| HELP use the named argument by name to avoid ambiguity
18
19    println!("Hello {:width$}!", "x", width = 5);
20    //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
21    //~| HELP use the named argument by name to avoid ambiguity
22
23    println!("Hello {f:width$.precision$}!", f = 0.02f32, width = 5, precision = 2);
24    //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
25    //~| WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
26    //~| WARNING named argument `f` is not used by name [named_arguments_used_positionally]
27    //~| HELP use the named argument by name to avoid ambiguity
28    //~| HELP use the named argument by name to avoid ambiguity
29    //~| HELP use the named argument by name to avoid ambiguity
30
31    println!("Hello {f:width$.precision$}!", f = 0.02f32, width = 5, precision = 2);
32    //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
33    //~| WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
34    //~| WARNING named argument `f` is not used by name [named_arguments_used_positionally]
35    //~| HELP use the named argument by name to avoid ambiguity
36    //~| HELP use the named argument by name to avoid ambiguity
37    //~| HELP use the named argument by name to avoid ambiguity
38
39    println!(
40        "{}, Hello {f:width$.precision$} {g:width2$.precision2$}! {f}",
41        //~^ HELP use the named argument by name to avoid ambiguity
42        //~| HELP use the named argument by name to avoid ambiguity
43        //~| HELP use the named argument by name to avoid ambiguity
44        //~| HELP use the named argument by name to avoid ambiguity
45        //~| HELP use the named argument by name to avoid ambiguity
46        //~| HELP use the named argument by name to avoid ambiguity
47        //~| HELP use the named argument by name to avoid ambiguity
48        1,
49        f = 0.02f32,
50        //~^ WARNING named argument `f` is not used by name [named_arguments_used_positionally]
51        //~| WARNING named argument `f` is not used by name [named_arguments_used_positionally]
52        width = 5,
53        //~^ WARNING named argument `width` is not used by name [named_arguments_used_positionally
54        precision = 2,
55        //~^ WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
56        g = 0.02f32,
57        //~^ WARNING named argument `g` is not used by name [named_arguments_used_positionally]
58        width2 = 5,
59        //~^ WARNING named argument `width2` is not used by name [named_arguments_used_positionally
60        precision2 = 2
61        //~^ WARNING named argument `precision2` is not used by name [named_arguments_used_positionally]
62    );
63
64    println!("Hello {f:0.1}!", f = 0.02f32);
65    //~^ WARNING named argument `f` is not used by name [named_arguments_used_positionally]
66    //~| HELP use the named argument by name to avoid ambiguity
67
68    println!("Hello {f:0.1}!", f = 0.02f32);
69    //~^ WARNING named argument `f` is not used by name [named_arguments_used_positionally]
70    //~| HELP use the named argument by name to avoid ambiguity
71
72    println!("Hello {f:width$.precision$}!", f = 0.02f32, width = 5, precision = 2);
73
74    let width = 5;
75    let precision = 2;
76    println!("Hello {f:width$.precision$}!", f = 0.02f32);
77
78    let val = 5;
79    println!("{v:v$}", v = val);
80    //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
81    //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
82    //~| HELP use the named argument by name to avoid ambiguity
83    //~| HELP use the named argument by name to avoid ambiguity
84    println!("{v:v$}", v = val);
85    //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
86    //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
87    //~| HELP use the named argument by name to avoid ambiguity
88    //~| HELP use the named argument by name to avoid ambiguity
89    println!("{v:v$.v$}", v = val);
90    //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
91    //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
92    //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
93    //~| HELP use the named argument by name to avoid ambiguity
94    //~| HELP use the named argument by name to avoid ambiguity
95    //~| HELP use the named argument by name to avoid ambiguity
96    println!("{v:v$.v$}", v = val);
97    //~^ WARNING named argument `v` is not used by name [named_arguments_used_positionally]
98    //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
99    //~| WARNING named argument `v` is not used by name [named_arguments_used_positionally]
100    //~| HELP use the named argument by name to avoid ambiguity
101    //~| HELP use the named argument by name to avoid ambiguity
102    //~| HELP use the named argument by name to avoid ambiguity
103
104    println!("{a} {a} {a}", a = 1);
105    //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
106    //~| WARNING named argument `a` is not used by name [named_arguments_used_positionally]
107    //~| HELP use the named argument by name to avoid ambiguity
108    //~| HELP use the named argument by name to avoid ambiguity
109
110    println!("aaaaaaaaaaaaaaa\
111                {a:b$.c$}",
112             //~^ HELP use the named argument by name to avoid ambiguity
113             //~| HELP use the named argument by name to avoid ambiguity
114             //~| HELP use the named argument by name to avoid ambiguity
115             a = 1.0, b = 1, c = 2,
116             //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
117             //~| WARNING named argument `b` is not used by name [named_arguments_used_positionally]
118             //~| WARNING named argument `c` is not used by name [named_arguments_used_positionally]
119    );
120
121    println!("aaaaaaaaaaaaaaa\
122                {a:b$.c$}",
123             //~^ HELP use the named argument by name to avoid ambiguity
124             //~| HELP use the named argument by name to avoid ambiguity
125             //~| HELP use the named argument by name to avoid ambiguity
126             a = 1.0, b = 1, c = 2,
127             //~^ WARNING named argument `a` is not used by name [named_arguments_used_positionally]
128             //~| WARNING named argument `b` is not used by name [named_arguments_used_positionally]
129             //~| WARNING named argument `c` is not used by name [named_arguments_used_positionally]
130    );
131
132    println!("{{{x:width$.precision$}}}", x = 1.0, width = 3, precision = 2);
133    //~^ WARNING named argument `x` is not used by name [named_arguments_used_positionally]
134    //~| WARNING named argument `width` is not used by name [named_arguments_used_positionally]
135    //~| WARNING named argument `precision` is not used by name [named_arguments_used_positionally]
136    //~| HELP use the named argument by name to avoid ambiguity
137    //~| HELP use the named argument by name to avoid ambiguity
138    //~| HELP use the named argument by name to avoid ambiguity
139}