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