summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/format_args.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/tests/ui/format_args.rs51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/tools/clippy/tests/ui/format_args.rs b/src/tools/clippy/tests/ui/format_args.rs
index 3a434c5bf..b9a4d66c2 100644
--- a/src/tools/clippy/tests/ui/format_args.rs
+++ b/src/tools/clippy/tests/ui/format_args.rs
@@ -1,8 +1,6 @@
// run-rustfix
-#![allow(unreachable_code)]
-#![allow(unused_macros)]
-#![allow(unused_variables)]
+#![allow(unused)]
#![allow(clippy::assertions_on_constants)]
#![allow(clippy::eq_op)]
#![allow(clippy::print_literal)]
@@ -115,3 +113,50 @@ fn main() {
// https://github.com/rust-lang/rust-clippy/issues/7903
println!("{foo}{foo:?}", foo = "foo".to_string());
}
+
+fn issue8643(vendor_id: usize, product_id: usize, name: &str) {
+ println!(
+ "{:<9} {:<10} {}",
+ format!("0x{:x}", vendor_id),
+ format!("0x{:x}", product_id),
+ name
+ );
+}
+
+// https://github.com/rust-lang/rust-clippy/issues/8855
+mod issue_8855 {
+ #![allow(dead_code)]
+
+ struct A {}
+
+ impl std::fmt::Display for A {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ write!(f, "test")
+ }
+ }
+
+ fn main() {
+ let a = A {};
+ let b = A {};
+
+ let x = format!("{} {}", a, b.to_string());
+ dbg!(x);
+
+ let x = format!("{:>6} {:>6}", a, b.to_string());
+ dbg!(x);
+ }
+}
+
+// https://github.com/rust-lang/rust-clippy/issues/9256
+mod issue_9256 {
+ #![allow(dead_code)]
+
+ fn print_substring(original: &str) {
+ assert!(original.len() > 10);
+ println!("{}", original[..10].to_string());
+ }
+
+ fn main() {
+ print_substring("Hello, world!");
+ }
+}