]> git.proxmox.com Git - rustc.git/blob - tests/ui/macros/issue-98466.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / macros / issue-98466.rs
1 // check-pass
2 // run-rustfix
3
4 fn main() {
5 let mut _x: usize;
6 _x = 1;
7 println!("_x is {}", _x = 5);
8 //~^ WARNING named argument `_x` is not used by name [named_arguments_used_positionally]
9 //~| HELP use the named argument by name to avoid ambiguity
10 println!("_x is {}", y = _x);
11 //~^ WARNING named argument `y` is not used by name [named_arguments_used_positionally]
12 //~| HELP use the named argument by name to avoid ambiguity
13 println!("first positional arg {}, second positional arg {}, _x is {}", 1, 2, y = _x);
14 //~^ WARNING named argument `y` is not used by name [named_arguments_used_positionally]
15 //~| HELP use the named argument by name to avoid ambiguity
16
17 let mut _x: usize;
18 _x = 1;
19 let _f = format!("_x is {}", _x = 5);
20 //~^ WARNING named argument `_x` is not used by name [named_arguments_used_positionally]
21 //~| HELP use the named argument by name to avoid ambiguity
22 let _f = format!("_x is {}", y = _x);
23 //~^ WARNING named argument `y` is not used by name [named_arguments_used_positionally]
24 //~| HELP use the named argument by name to avoid ambiguity
25 let _f = format!("first positional arg {}, second positional arg {}, _x is {}", 1, 2, y = _x);
26 //~^ WARNING named argument `y` is not used by name [named_arguments_used_positionally]
27 //~| HELP use the named argument by name to avoid ambiguity
28
29 let s = "0.009";
30 // Confirm that named arguments used in formatting are correctly considered.
31 println!(".{:0<width$}", s, width = _x);
32
33 let region = "abc";
34 let width = 8;
35 let ls = "abcde";
36 let full = "abcde";
37 // Confirm that named arguments used in formatting are correctly considered.
38 println!(
39 "| {r:rw$?} | {ui:4?} | {v}",
40 r = region,
41 rw = width,
42 ui = ls,
43 v = full,
44 );
45
46 // Confirm that named arguments used in formatting are correctly considered.
47 println!("{:.a$}", "aaaaaaaaaaaaaaaaaa", a = 4);
48
49 // Confirm that named arguments used in formatting are correctly considered.
50 println!("{:._a$}", "aaaaaaaaaaaaaaaaaa", _a = 4);
51 }