1 #![allow(clippy::assertions_on_constants)]
2 #![allow(clippy::eq_op)]
3 #![warn(clippy::format_in_format_args)]
4 #![warn(clippy::to_string_in_format_args)]
6 use std::io::{stdout, Error, ErrorKind, Write};
8 use std::panic::Location;
10 macro_rules! my_macro {
12 // here be dragons, do not enter (or lint)
13 println!("error: {}", format!("something failed at {}", Location::caller()));
17 macro_rules! my_other_macro {
19 format!("something failed at {}", Location::caller())
24 let error = Error::new(ErrorKind::Other, "bad thing");
27 println!("error: {}", format!("something failed at {}", Location::caller()));
28 println!("{}: {}", error, format!("something failed at {}", Location::caller()));
29 println!("{:?}: {}", error, format!("something failed at {}", Location::caller()));
30 println!("{{}}: {}", format!("something failed at {}", Location::caller()));
31 println!(r#"error: "{}""#, format!("something failed at {}", Location::caller()));
32 println!("error: {}", format!(r#"something failed at "{}""#, Location::caller()));
33 println!("error: {}", format!("something failed at {} {0}", Location::caller()));
34 let _ = format!("error: {}", format!("something failed at {}", Location::caller()));
38 format!("something failed at {}", Location::caller())
43 format!("something failed at {}", Location::caller())
45 print!("error: {}", format!("something failed at {}", Location::caller()));
46 eprint!("error: {}", format!("something failed at {}", Location::caller()));
47 eprintln!("error: {}", format!("something failed at {}", Location::caller()));
48 let _ = format_args!("error: {}", format!("something failed at {}", Location::caller()));
49 assert!(true, "error: {}", format!("something failed at {}", Location::caller()));
50 assert_eq!(0, 0, "error: {}", format!("something failed at {}", Location::caller()));
51 assert_ne!(0, 0, "error: {}", format!("something failed at {}", Location::caller()));
52 panic!("error: {}", format!("something failed at {}", Location::caller()));
55 println!("error: {}", format_args!("something failed at {}", Location::caller()));
56 println!("error: {:>70}", format!("something failed at {}", Location::caller()));
57 println!("error: {} {0}", format!("something failed at {}", Location::caller()));
58 println!("{} and again {0}", format!("hi {}", x));
60 println!("error: {}", my_other_macro!());