From 32b2a3f944f9889fd7c5fcfb7976430d1aeb7ed4 Mon Sep 17 00:00:00 2001 From: pro-grammer1 <1df0d0d3-eed4-45fc-bc60-43a85079f3f9@anonaddy.me> Date: Sun, 17 Jan 2021 19:21:33 +0000 Subject: [PATCH] Add numeric literals to the write_literal and print_literal tests that shouldn't fail --- tests/ui/print_literal.rs | 3 +++ tests/ui/print_literal.stderr | 22 +++++++++++----------- tests/ui/write_literal.rs | 3 +++ tests/ui/write_literal.stderr | 22 +++++++++++----------- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/tests/ui/print_literal.rs b/tests/ui/print_literal.rs index 0c8aecc2d8c..8665a3bb28a 100644 --- a/tests/ui/print_literal.rs +++ b/tests/ui/print_literal.rs @@ -17,6 +17,9 @@ fn main() { println!("{bar:8} {foo:>8}", foo = "hello", bar = "world"); println!("{number:>width$}", number = 1, width = 6); println!("{number:>0width$}", number = 1, width = 6); + println!("{} of {:b} people know binary, the other half doesn't", 1, 2); + println!("10 / 4 is {}", 2.5); + println!("2 + 1 = {}", 3); // these should throw warnings print!("Hello {}", "world"); diff --git a/tests/ui/print_literal.stderr b/tests/ui/print_literal.stderr index 692abdb3054..e284aece236 100644 --- a/tests/ui/print_literal.stderr +++ b/tests/ui/print_literal.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/print_literal.rs:22:24 + --> $DIR/print_literal.rs:25:24 | LL | print!("Hello {}", "world"); | ^^^^^^^ @@ -7,61 +7,61 @@ LL | print!("Hello {}", "world"); = note: `-D clippy::print-literal` implied by `-D warnings` error: literal with an empty format string - --> $DIR/print_literal.rs:23:36 + --> $DIR/print_literal.rs:26:36 | LL | println!("Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:24:26 + --> $DIR/print_literal.rs:27:26 | LL | println!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:29:25 + --> $DIR/print_literal.rs:32:25 | LL | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:29:34 + --> $DIR/print_literal.rs:32:34 | LL | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:30:25 + --> $DIR/print_literal.rs:33:25 | LL | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:30:34 + --> $DIR/print_literal.rs:33:34 | LL | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:33:35 + --> $DIR/print_literal.rs:36:35 | LL | println!("{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:33:50 + --> $DIR/print_literal.rs:36:50 | LL | println!("{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:34:35 + --> $DIR/print_literal.rs:37:35 | LL | println!("{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:34:50 + --> $DIR/print_literal.rs:37:50 | LL | println!("{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^ diff --git a/tests/ui/write_literal.rs b/tests/ui/write_literal.rs index f5de7ea71d3..0a127858def 100644 --- a/tests/ui/write_literal.rs +++ b/tests/ui/write_literal.rs @@ -22,6 +22,9 @@ fn main() { writeln!(&mut v, "{bar:8} {foo:>8}", foo = "hello", bar = "world"); writeln!(&mut v, "{number:>width$}", number = 1, width = 6); writeln!(&mut v, "{number:>0width$}", number = 1, width = 6); + writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); + writeln!(&mut v, "10 / 4 is {}", 2.5); + writeln!(&mut v, "2 + 1 = {}", 3); // these should throw warnings write!(&mut v, "Hello {}", "world"); diff --git a/tests/ui/write_literal.stderr b/tests/ui/write_literal.stderr index 4dcaaa474a8..e54d89ecf29 100644 --- a/tests/ui/write_literal.stderr +++ b/tests/ui/write_literal.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/write_literal.rs:27:32 + --> $DIR/write_literal.rs:30:32 | LL | write!(&mut v, "Hello {}", "world"); | ^^^^^^^ @@ -7,61 +7,61 @@ LL | write!(&mut v, "Hello {}", "world"); = note: `-D clippy::write-literal` implied by `-D warnings` error: literal with an empty format string - --> $DIR/write_literal.rs:28:44 + --> $DIR/write_literal.rs:31:44 | LL | writeln!(&mut v, "Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:29:34 + --> $DIR/write_literal.rs:32:34 | LL | writeln!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:34:33 + --> $DIR/write_literal.rs:37:33 | LL | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:34:42 + --> $DIR/write_literal.rs:37:42 | LL | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:35:33 + --> $DIR/write_literal.rs:38:33 | LL | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:35:42 + --> $DIR/write_literal.rs:38:42 | LL | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:38:43 + --> $DIR/write_literal.rs:41:43 | LL | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:38:58 + --> $DIR/write_literal.rs:41:58 | LL | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:39:43 + --> $DIR/write_literal.rs:42:43 | LL | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:39:58 + --> $DIR/write_literal.rs:42:58 | LL | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^