Skip to content

Commit 67b2f05

Browse files
committed
Fix incorrect format-arg inlining
An edge case with format arguments being wrapped in parentesis
1 parent 887ba0c commit 67b2f05

File tree

3 files changed

+132
-76
lines changed

3 files changed

+132
-76
lines changed

tests/ui/uninlined_format_args.fixed

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
// aux-build:proc_macro_with_span.rs
22
// run-rustfix
3+
34
#![feature(custom_inner_attributes)]
45
#![warn(clippy::uninlined_format_args)]
56
#![allow(named_arguments_used_positionally, unused_imports, unused_macros, unused_variables)]
6-
#![allow(clippy::eq_op, clippy::format_in_format_args, clippy::print_literal)]
7+
#![allow(
8+
clippy::double_parens,
9+
clippy::eq_op,
10+
clippy::format_in_format_args,
11+
clippy::print_literal
12+
)]
713

814
extern crate proc_macro_with_span;
915
use proc_macro_with_span::with_span;
@@ -123,6 +129,10 @@ fn tester(fn_arg: i32) {
123129
println!("{}", format!("{local_i32}"));
124130
my_println!("{}", local_i32);
125131
my_println_args!("{}", local_i32);
132+
println!("{local_i32}");
133+
#[rustfmt::skip]
134+
println!("{local_i32}");
135+
println!("{local_i32:width$.prec$}");
126136

127137
// these should NOT be modified by the lint
128138
println!(concat!("nope ", "{}"), local_i32);

tests/ui/uninlined_format_args.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
// aux-build:proc_macro_with_span.rs
22
// run-rustfix
3+
34
#![feature(custom_inner_attributes)]
45
#![warn(clippy::uninlined_format_args)]
56
#![allow(named_arguments_used_positionally, unused_imports, unused_macros, unused_variables)]
6-
#![allow(clippy::eq_op, clippy::format_in_format_args, clippy::print_literal)]
7+
#![allow(
8+
clippy::double_parens,
9+
clippy::eq_op,
10+
clippy::format_in_format_args,
11+
clippy::print_literal
12+
)]
713

814
extern crate proc_macro_with_span;
915
use proc_macro_with_span::with_span;
@@ -126,6 +132,10 @@ fn tester(fn_arg: i32) {
126132
println!("{}", format!("{}", local_i32));
127133
my_println!("{}", local_i32);
128134
my_println_args!("{}", local_i32);
135+
println!("{}", (local_i32));
136+
#[rustfmt::skip]
137+
println!("{}", ((local_i32)));
138+
println!("{0:1$.2$}", (local_i32), (width), (prec));
129139

130140
// these should NOT be modified by the lint
131141
println!(concat!("nope ", "{}"), local_i32);

0 commit comments

Comments
 (0)