Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 32b2a3f

Browse files
committed
Add numeric literals to the write_literal and print_literal tests that shouldn't fail
1 parent fb2a06d commit 32b2a3f

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

tests/ui/print_literal.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ fn main() {
1717
println!("{bar:8} {foo:>8}", foo = "hello", bar = "world");
1818
println!("{number:>width$}", number = 1, width = 6);
1919
println!("{number:>0width$}", number = 1, width = 6);
20+
println!("{} of {:b} people know binary, the other half doesn't", 1, 2);
21+
println!("10 / 4 is {}", 2.5);
22+
println!("2 + 1 = {}", 3);
2023

2124
// these should throw warnings
2225
print!("Hello {}", "world");

tests/ui/print_literal.stderr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
11
error: literal with an empty format string
2-
--> $DIR/print_literal.rs:22:24
2+
--> $DIR/print_literal.rs:25:24
33
|
44
LL | print!("Hello {}", "world");
55
| ^^^^^^^
66
|
77
= note: `-D clippy::print-literal` implied by `-D warnings`
88

99
error: literal with an empty format string
10-
--> $DIR/print_literal.rs:23:36
10+
--> $DIR/print_literal.rs:26:36
1111
|
1212
LL | println!("Hello {} {}", world, "world");
1313
| ^^^^^^^
1414

1515
error: literal with an empty format string
16-
--> $DIR/print_literal.rs:24:26
16+
--> $DIR/print_literal.rs:27:26
1717
|
1818
LL | println!("Hello {}", "world");
1919
| ^^^^^^^
2020

2121
error: literal with an empty format string
22-
--> $DIR/print_literal.rs:29:25
22+
--> $DIR/print_literal.rs:32:25
2323
|
2424
LL | println!("{0} {1}", "hello", "world");
2525
| ^^^^^^^
2626

2727
error: literal with an empty format string
28-
--> $DIR/print_literal.rs:29:34
28+
--> $DIR/print_literal.rs:32:34
2929
|
3030
LL | println!("{0} {1}", "hello", "world");
3131
| ^^^^^^^
3232

3333
error: literal with an empty format string
34-
--> $DIR/print_literal.rs:30:25
34+
--> $DIR/print_literal.rs:33:25
3535
|
3636
LL | println!("{1} {0}", "hello", "world");
3737
| ^^^^^^^
3838

3939
error: literal with an empty format string
40-
--> $DIR/print_literal.rs:30:34
40+
--> $DIR/print_literal.rs:33:34
4141
|
4242
LL | println!("{1} {0}", "hello", "world");
4343
| ^^^^^^^
4444

4545
error: literal with an empty format string
46-
--> $DIR/print_literal.rs:33:35
46+
--> $DIR/print_literal.rs:36:35
4747
|
4848
LL | println!("{foo} {bar}", foo = "hello", bar = "world");
4949
| ^^^^^^^
5050

5151
error: literal with an empty format string
52-
--> $DIR/print_literal.rs:33:50
52+
--> $DIR/print_literal.rs:36:50
5353
|
5454
LL | println!("{foo} {bar}", foo = "hello", bar = "world");
5555
| ^^^^^^^
5656

5757
error: literal with an empty format string
58-
--> $DIR/print_literal.rs:34:35
58+
--> $DIR/print_literal.rs:37:35
5959
|
6060
LL | println!("{bar} {foo}", foo = "hello", bar = "world");
6161
| ^^^^^^^
6262

6363
error: literal with an empty format string
64-
--> $DIR/print_literal.rs:34:50
64+
--> $DIR/print_literal.rs:37:50
6565
|
6666
LL | println!("{bar} {foo}", foo = "hello", bar = "world");
6767
| ^^^^^^^

tests/ui/write_literal.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ fn main() {
2222
writeln!(&mut v, "{bar:8} {foo:>8}", foo = "hello", bar = "world");
2323
writeln!(&mut v, "{number:>width$}", number = 1, width = 6);
2424
writeln!(&mut v, "{number:>0width$}", number = 1, width = 6);
25+
writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2);
26+
writeln!(&mut v, "10 / 4 is {}", 2.5);
27+
writeln!(&mut v, "2 + 1 = {}", 3);
2528

2629
// these should throw warnings
2730
write!(&mut v, "Hello {}", "world");

tests/ui/write_literal.stderr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
11
error: literal with an empty format string
2-
--> $DIR/write_literal.rs:27:32
2+
--> $DIR/write_literal.rs:30:32
33
|
44
LL | write!(&mut v, "Hello {}", "world");
55
| ^^^^^^^
66
|
77
= note: `-D clippy::write-literal` implied by `-D warnings`
88

99
error: literal with an empty format string
10-
--> $DIR/write_literal.rs:28:44
10+
--> $DIR/write_literal.rs:31:44
1111
|
1212
LL | writeln!(&mut v, "Hello {} {}", world, "world");
1313
| ^^^^^^^
1414

1515
error: literal with an empty format string
16-
--> $DIR/write_literal.rs:29:34
16+
--> $DIR/write_literal.rs:32:34
1717
|
1818
LL | writeln!(&mut v, "Hello {}", "world");
1919
| ^^^^^^^
2020

2121
error: literal with an empty format string
22-
--> $DIR/write_literal.rs:34:33
22+
--> $DIR/write_literal.rs:37:33
2323
|
2424
LL | writeln!(&mut v, "{0} {1}", "hello", "world");
2525
| ^^^^^^^
2626

2727
error: literal with an empty format string
28-
--> $DIR/write_literal.rs:34:42
28+
--> $DIR/write_literal.rs:37:42
2929
|
3030
LL | writeln!(&mut v, "{0} {1}", "hello", "world");
3131
| ^^^^^^^
3232

3333
error: literal with an empty format string
34-
--> $DIR/write_literal.rs:35:33
34+
--> $DIR/write_literal.rs:38:33
3535
|
3636
LL | writeln!(&mut v, "{1} {0}", "hello", "world");
3737
| ^^^^^^^
3838

3939
error: literal with an empty format string
40-
--> $DIR/write_literal.rs:35:42
40+
--> $DIR/write_literal.rs:38:42
4141
|
4242
LL | writeln!(&mut v, "{1} {0}", "hello", "world");
4343
| ^^^^^^^
4444

4545
error: literal with an empty format string
46-
--> $DIR/write_literal.rs:38:43
46+
--> $DIR/write_literal.rs:41:43
4747
|
4848
LL | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world");
4949
| ^^^^^^^
5050

5151
error: literal with an empty format string
52-
--> $DIR/write_literal.rs:38:58
52+
--> $DIR/write_literal.rs:41:58
5353
|
5454
LL | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world");
5555
| ^^^^^^^
5656

5757
error: literal with an empty format string
58-
--> $DIR/write_literal.rs:39:43
58+
--> $DIR/write_literal.rs:42:43
5959
|
6060
LL | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world");
6161
| ^^^^^^^
6262

6363
error: literal with an empty format string
64-
--> $DIR/write_literal.rs:39:58
64+
--> $DIR/write_literal.rs:42:58
6565
|
6666
LL | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world");
6767
| ^^^^^^^

0 commit comments

Comments
 (0)