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

Commit fb2a06d

Browse files
committed
Remove numeric literals from print_literal and write_literal tests
1 parent ab155b1 commit fb2a06d

File tree

6 files changed

+31
-73
lines changed

6 files changed

+31
-73
lines changed

clippy_lints/src/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ impl Write {
461461
span_lint(cx, lint, token_expr.span, "literal with an empty format string");
462462
}
463463
idx += 1;
464-
}
464+
},
465465
ExprKind::Assign(lhs, rhs, _) => {
466466
if_chain! {
467467
if let ExprKind::Lit(ref lit) = rhs.kind;

tests/ui/crashes/ice-3891.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: invalid suffix `x` for integer literal
1+
error: invalid suffix `x` for number literal
22
--> $DIR/ice-3891.rs:2:5
33
|
44
LL | 1x;
55
| ^^ invalid suffix `x`
66
|
7-
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)
7+
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
88

99
error: aborting due to previous error
1010

tests/ui/print_literal.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@ fn main() {
1919
println!("{number:>0width$}", number = 1, width = 6);
2020

2121
// these should throw warnings
22-
println!("{} of {:b} people know binary, the other half doesn't", 1, 2);
2322
print!("Hello {}", "world");
2423
println!("Hello {} {}", world, "world");
2524
println!("Hello {}", "world");
26-
println!("10 / 4 is {}", 2.5);
27-
println!("2 + 1 = {}", 3);
2825

2926
// positional args don't change the fact
3027
// that we're using a literal -- this should

tests/ui/print_literal.stderr

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,70 @@
11
error: literal with an empty format string
2-
--> $DIR/print_literal.rs:22:71
3-
|
4-
LL | println!("{} of {:b} people know binary, the other half doesn't", 1, 2);
5-
| ^
6-
|
7-
= note: `-D clippy::print-literal` implied by `-D warnings`
8-
9-
error: literal with an empty format string
10-
--> $DIR/print_literal.rs:23:24
2+
--> $DIR/print_literal.rs:22:24
113
|
124
LL | print!("Hello {}", "world");
135
| ^^^^^^^
6+
|
7+
= note: `-D clippy::print-literal` implied by `-D warnings`
148

159
error: literal with an empty format string
16-
--> $DIR/print_literal.rs:24:36
10+
--> $DIR/print_literal.rs:23:36
1711
|
1812
LL | println!("Hello {} {}", world, "world");
1913
| ^^^^^^^
2014

2115
error: literal with an empty format string
22-
--> $DIR/print_literal.rs:25:26
16+
--> $DIR/print_literal.rs:24:26
2317
|
2418
LL | println!("Hello {}", "world");
2519
| ^^^^^^^
2620

2721
error: literal with an empty format string
28-
--> $DIR/print_literal.rs:26:30
29-
|
30-
LL | println!("10 / 4 is {}", 2.5);
31-
| ^^^
32-
33-
error: literal with an empty format string
34-
--> $DIR/print_literal.rs:27:28
35-
|
36-
LL | println!("2 + 1 = {}", 3);
37-
| ^
38-
39-
error: literal with an empty format string
40-
--> $DIR/print_literal.rs:32:25
22+
--> $DIR/print_literal.rs:29:25
4123
|
4224
LL | println!("{0} {1}", "hello", "world");
4325
| ^^^^^^^
4426

4527
error: literal with an empty format string
46-
--> $DIR/print_literal.rs:32:34
28+
--> $DIR/print_literal.rs:29:34
4729
|
4830
LL | println!("{0} {1}", "hello", "world");
4931
| ^^^^^^^
5032

5133
error: literal with an empty format string
52-
--> $DIR/print_literal.rs:33:25
34+
--> $DIR/print_literal.rs:30:25
5335
|
5436
LL | println!("{1} {0}", "hello", "world");
5537
| ^^^^^^^
5638

5739
error: literal with an empty format string
58-
--> $DIR/print_literal.rs:33:34
40+
--> $DIR/print_literal.rs:30:34
5941
|
6042
LL | println!("{1} {0}", "hello", "world");
6143
| ^^^^^^^
6244

6345
error: literal with an empty format string
64-
--> $DIR/print_literal.rs:36:35
46+
--> $DIR/print_literal.rs:33:35
6547
|
6648
LL | println!("{foo} {bar}", foo = "hello", bar = "world");
6749
| ^^^^^^^
6850

6951
error: literal with an empty format string
70-
--> $DIR/print_literal.rs:36:50
52+
--> $DIR/print_literal.rs:33:50
7153
|
7254
LL | println!("{foo} {bar}", foo = "hello", bar = "world");
7355
| ^^^^^^^
7456

7557
error: literal with an empty format string
76-
--> $DIR/print_literal.rs:37:35
58+
--> $DIR/print_literal.rs:34:35
7759
|
7860
LL | println!("{bar} {foo}", foo = "hello", bar = "world");
7961
| ^^^^^^^
8062

8163
error: literal with an empty format string
82-
--> $DIR/print_literal.rs:37:50
64+
--> $DIR/print_literal.rs:34:50
8365
|
8466
LL | println!("{bar} {foo}", foo = "hello", bar = "world");
8567
| ^^^^^^^
8668

87-
error: aborting due to 14 previous errors
69+
error: aborting due to 11 previous errors
8870

tests/ui/write_literal.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ fn main() {
2424
writeln!(&mut v, "{number:>0width$}", number = 1, width = 6);
2525

2626
// these should throw warnings
27-
writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2);
2827
write!(&mut v, "Hello {}", "world");
2928
writeln!(&mut v, "Hello {} {}", world, "world");
3029
writeln!(&mut v, "Hello {}", "world");
31-
writeln!(&mut v, "10 / 4 is {}", 2.5);
32-
writeln!(&mut v, "2 + 1 = {}", 3);
3330

3431
// positional args don't change the fact
3532
// that we're using a literal -- this should

tests/ui/write_literal.stderr

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,70 @@
11
error: literal with an empty format string
2-
--> $DIR/write_literal.rs:27:79
3-
|
4-
LL | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2);
5-
| ^
6-
|
7-
= note: `-D clippy::write-literal` implied by `-D warnings`
8-
9-
error: literal with an empty format string
10-
--> $DIR/write_literal.rs:28:32
2+
--> $DIR/write_literal.rs:27:32
113
|
124
LL | write!(&mut v, "Hello {}", "world");
135
| ^^^^^^^
6+
|
7+
= note: `-D clippy::write-literal` implied by `-D warnings`
148

159
error: literal with an empty format string
16-
--> $DIR/write_literal.rs:29:44
10+
--> $DIR/write_literal.rs:28:44
1711
|
1812
LL | writeln!(&mut v, "Hello {} {}", world, "world");
1913
| ^^^^^^^
2014

2115
error: literal with an empty format string
22-
--> $DIR/write_literal.rs:30:34
16+
--> $DIR/write_literal.rs:29:34
2317
|
2418
LL | writeln!(&mut v, "Hello {}", "world");
2519
| ^^^^^^^
2620

2721
error: literal with an empty format string
28-
--> $DIR/write_literal.rs:31:38
29-
|
30-
LL | writeln!(&mut v, "10 / 4 is {}", 2.5);
31-
| ^^^
32-
33-
error: literal with an empty format string
34-
--> $DIR/write_literal.rs:32:36
35-
|
36-
LL | writeln!(&mut v, "2 + 1 = {}", 3);
37-
| ^
38-
39-
error: literal with an empty format string
40-
--> $DIR/write_literal.rs:37:33
22+
--> $DIR/write_literal.rs:34:33
4123
|
4224
LL | writeln!(&mut v, "{0} {1}", "hello", "world");
4325
| ^^^^^^^
4426

4527
error: literal with an empty format string
46-
--> $DIR/write_literal.rs:37:42
28+
--> $DIR/write_literal.rs:34:42
4729
|
4830
LL | writeln!(&mut v, "{0} {1}", "hello", "world");
4931
| ^^^^^^^
5032

5133
error: literal with an empty format string
52-
--> $DIR/write_literal.rs:38:33
34+
--> $DIR/write_literal.rs:35:33
5335
|
5436
LL | writeln!(&mut v, "{1} {0}", "hello", "world");
5537
| ^^^^^^^
5638

5739
error: literal with an empty format string
58-
--> $DIR/write_literal.rs:38:42
40+
--> $DIR/write_literal.rs:35:42
5941
|
6042
LL | writeln!(&mut v, "{1} {0}", "hello", "world");
6143
| ^^^^^^^
6244

6345
error: literal with an empty format string
64-
--> $DIR/write_literal.rs:41:43
46+
--> $DIR/write_literal.rs:38:43
6547
|
6648
LL | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world");
6749
| ^^^^^^^
6850

6951
error: literal with an empty format string
70-
--> $DIR/write_literal.rs:41:58
52+
--> $DIR/write_literal.rs:38:58
7153
|
7254
LL | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world");
7355
| ^^^^^^^
7456

7557
error: literal with an empty format string
76-
--> $DIR/write_literal.rs:42:43
58+
--> $DIR/write_literal.rs:39:43
7759
|
7860
LL | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world");
7961
| ^^^^^^^
8062

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

87-
error: aborting due to 14 previous errors
69+
error: aborting due to 11 previous errors
8870

0 commit comments

Comments
 (0)