-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
18 additions
and
1,270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
tests/ui-toml/allow_mixed_uninlined_format_args/auxiliary/proc_macro_with_span.rs
This file was deleted.
Oops, something went wrong.
167 changes: 2 additions & 165 deletions
167
tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,177 +1,14 @@ | ||
// aux-build:proc_macro_with_span.rs | ||
// run-rustfix | ||
#![feature(custom_inner_attributes)] | ||
#![warn(clippy::uninlined_format_args)] | ||
#![allow(named_arguments_used_positionally, unused_imports, unused_macros, unused_variables)] | ||
#![allow(clippy::eq_op, clippy::format_in_format_args, clippy::print_literal)] | ||
|
||
extern crate proc_macro_with_span; | ||
use proc_macro_with_span::with_span; | ||
|
||
macro_rules! no_param_str { | ||
() => { | ||
"{}" | ||
}; | ||
} | ||
|
||
macro_rules! my_println { | ||
($($args:tt),*) => {{ | ||
println!($($args),*) | ||
}}; | ||
} | ||
|
||
macro_rules! my_println_args { | ||
($($args:tt),*) => {{ | ||
println!("foo: {}", format_args!($($args),*)) | ||
}}; | ||
} | ||
|
||
fn tester(fn_arg: i32) { | ||
fn main() { | ||
let local_i32 = 1; | ||
let local_f64 = 2.0; | ||
let local_opt: Option<i32> = Some(3); | ||
let width = 4; | ||
let prec = 5; | ||
let val = 6; | ||
|
||
// make sure this file hasn't been corrupted with tabs converted to spaces | ||
// let _ = ' '; // <- this is a single tab character | ||
let _: &[u8; 3] = b" "; // <- <tab><space><tab> | ||
|
||
println!("val='{local_i32}'"); | ||
println!("val='{local_i32}'"); // 3 spaces | ||
println!("val='{local_i32}'"); // tab | ||
println!("val='{local_i32}'"); // space+tab | ||
println!("val='{local_i32}'"); // tab+space | ||
println!( | ||
"val='{local_i32}'" | ||
); | ||
println!("{local_i32}"); | ||
println!("{fn_arg}"); | ||
println!("{local_i32:?}"); | ||
println!("{local_i32:#?}"); | ||
println!("{local_i32:4}"); | ||
println!("{local_i32:04}"); | ||
println!("{local_i32:<3}"); | ||
println!("{local_i32:#010x}"); | ||
println!("{local_f64:.1}"); | ||
println!("Hello {} is {local_f64:.local_i32$}", "x"); | ||
println!("Hello x is {local_f64:.local_i32$}"); | ||
println!("Hello {local_i32} is {local_f64:.*}", 5); | ||
println!("Hello {local_i32} is {local_f64:.*}", 5); | ||
println!("{local_i32} {local_f64}"); | ||
println!("{local_i32}, {}", local_opt.unwrap()); | ||
println!("{val}"); | ||
println!("{val}"); | ||
println!("{} {1}", local_i32, 42); | ||
println!("val='{local_i32}'"); | ||
println!("val='{local_i32}'"); | ||
println!("val='{local_i32}'"); | ||
println!("val='{fn_arg}'"); | ||
println!("{local_i32}"); | ||
println!("{local_i32:?}"); | ||
println!("{local_i32:#?}"); | ||
println!("{local_i32:04}"); | ||
println!("{local_i32:<3}"); | ||
println!("{local_i32:#010x}"); | ||
println!("{local_f64:.1}"); | ||
println!("{local_i32} {local_i32}"); | ||
println!("{local_f64} {local_i32} {local_i32} {local_f64}"); | ||
println!("{local_i32} {local_f64}"); | ||
println!("{local_f64} {local_i32}"); | ||
println!("{local_f64} {local_i32} {local_f64} {local_i32}"); | ||
println!("{1} {0}", "str", local_i32); | ||
println!("{local_i32}"); | ||
println!("{local_i32:width$}"); | ||
println!("{local_i32:width$}"); | ||
println!("{local_i32:.prec$}"); | ||
println!("{local_i32:.prec$}"); | ||
println!("{val:val$}"); | ||
println!("{val:val$}"); | ||
println!("{val:val$.val$}"); | ||
println!("{val:val$.val$}"); | ||
println!("{val:val$.val$}"); | ||
println!("{val:val$.val$}"); | ||
println!("{val:val$.val$}"); | ||
println!("{val:val$.val$}"); | ||
println!("{val:val$.val$}"); | ||
println!("{val:val$.val$}"); | ||
println!("{width:width$}"); | ||
println!("{local_i32:width$}"); | ||
println!("{width:width$}"); | ||
println!("{local_i32:width$}"); | ||
println!("{prec:.prec$}"); | ||
println!("{local_i32:.prec$}"); | ||
println!("{prec:.prec$}"); | ||
println!("{local_i32:.prec$}"); | ||
println!("{width:width$.prec$}"); | ||
println!("{width:width$.prec$}"); | ||
println!("{local_f64:width$.prec$}"); | ||
println!("{local_f64:width$.prec$} {local_f64} {width} {prec}"); | ||
println!( | ||
"{local_i32:width$.prec$} {local_i32:prec$.width$} {width:local_i32$.prec$} {width:prec$.local_i32$} {prec:local_i32$.width$} {prec:width$.local_i32$}", | ||
); | ||
println!( | ||
"{0:1$.2$} {0:2$.1$} {1:0$.2$} {1:2$.0$} {2:0$.1$} {2:1$.0$} {3}", | ||
local_i32, | ||
width, | ||
prec, | ||
1 + 2 | ||
); | ||
println!("Width = {local_i32}, value with width = {local_f64:local_i32$}"); | ||
println!("{local_i32:width$.prec$}"); | ||
println!("{width:width$.prec$}"); | ||
println!("{}", format!("{local_i32}")); | ||
my_println!("{}", local_i32); | ||
my_println_args!("{}", local_i32); | ||
|
||
// these should NOT be modified by the lint | ||
println!(concat!("nope ", "{}"), local_i32); | ||
println!("val='{local_i32}'"); | ||
println!("val='{local_i32 }'"); | ||
println!("val='{local_i32 }'"); // with tab | ||
println!("val='{local_i32\n}'"); | ||
println!("{}", usize::MAX); | ||
println!("{}", local_opt.unwrap()); | ||
println!( | ||
"val='{local_i32 | ||
}'" | ||
); | ||
println!(no_param_str!(), local_i32); | ||
|
||
println!( | ||
"{val}", | ||
); | ||
println!("{val}"); | ||
|
||
println!(with_span!("{0} {1}" "{1} {0}"), local_i32, local_f64); | ||
println!("{}", with_span!(span val)); | ||
|
||
if local_i32 > 0 { | ||
panic!("p1 {local_i32}"); | ||
} | ||
if local_i32 > 0 { | ||
panic!("p2 {local_i32}"); | ||
} | ||
if local_i32 > 0 { | ||
panic!("p3 {local_i32}"); | ||
} | ||
if local_i32 > 0 { | ||
panic!("p4 {local_i32}"); | ||
} | ||
} | ||
|
||
fn main() { | ||
tester(42); | ||
} | ||
|
||
fn _under_msrv() { | ||
#![clippy::msrv = "1.57"] | ||
let local_i32 = 1; | ||
println!("don't expand='{}'", local_i32); | ||
} | ||
|
||
fn _meets_msrv() { | ||
#![clippy::msrv = "1.58"] | ||
let local_i32 = 1; | ||
println!("expand='{local_i32}'"); | ||
} |
Oops, something went wrong.