Skip to content

Commit 97a2f80

Browse files
committed
rm indoc, ignore expanded macros
1 parent ba320c7 commit 97a2f80

File tree

6 files changed

+88
-90
lines changed

6 files changed

+88
-90
lines changed

Diff for: Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ clap = { version = "3.1", features = ["derive"] }
4646
clippy_utils = { path = "clippy_utils" }
4747
derive-new = "0.5"
4848
if_chain = "1.0"
49-
indoc = "1.0"
5049
itertools = "0.10.1"
5150
quote = "1.0"
5251
serde = { version = "1.0.125", features = ["derive"] }

Diff for: clippy_lints/src/format_args.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs {
164164
}
165165

166166
fn check_uninlined_args(cx: &LateContext<'_>, args: &FormatArgsExpn<'_>, call_site: Span) {
167+
if args.format_string.span.from_expansion() {
168+
return;
169+
}
170+
167171
let mut fixes = Vec::new();
168172
// If any of the arguments are referenced by an index number,
169173
// and that argument is not a simple variable and cannot be inlined,
@@ -204,17 +208,17 @@ fn check_one_arg(cx: &LateContext<'_>, param: &FormatParam<'_>, fixes: &mut Vec<
204208
&& let [segment] = segments
205209
{
206210
let replacement = match param.usage {
207-
FormatParamUsage::Argument => segment.ident.name.to_string(),
211+
FormatParamUsage::Argument => segment.ident.name.to_string(),
208212
FormatParamUsage::Width => format!("{}$", segment.ident.name),
209213
FormatParamUsage::Precision => format!(".{}$", segment.ident.name),
210-
};
211-
fixes.push((param.span, replacement));
212-
let arg_span = expand_past_previous_comma(cx, *span);
213-
fixes.push((arg_span, String::new()));
214-
true // successful inlining, continue checking
215-
} else {
216-
// if we can't inline a numbered argument, we can't continue
217-
param.kind != Numbered
214+
};
215+
fixes.push((param.span, replacement));
216+
let arg_span = expand_past_previous_comma(cx, *span);
217+
fixes.push((arg_span, String::new()));
218+
true // successful inlining, continue checking
219+
} else {
220+
// if we can't inline a numbered argument, we can't continue
221+
param.kind != Numbered
218222
}
219223
}
220224

Diff for: tests/compile-test.rs

-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static TEST_DEPENDENCIES: &[&str] = &[
3737
"tokio",
3838
"parking_lot",
3939
"rustc_semver",
40-
"indoc",
4140
];
4241

4342
// Test dependencies may need an `extern crate` here to ensure that they show up
@@ -53,8 +52,6 @@ extern crate futures;
5352
#[allow(unused_extern_crates)]
5453
extern crate if_chain;
5554
#[allow(unused_extern_crates)]
56-
extern crate indoc;
57-
#[allow(unused_extern_crates)]
5855
extern crate itertools;
5956
#[allow(unused_extern_crates)]
6057
extern crate parking_lot;

Diff for: tests/ui/uninlined_format_args.fixed

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#![warn(clippy::uninlined_format_args)]
99
#![feature(custom_inner_attributes)]
1010

11-
use indoc::{indoc, printdoc};
12-
1311
macro_rules! no_param_str {
1412
() => {
1513
"{}"
@@ -130,8 +128,9 @@ fn tester(fn_arg: i32) {
130128
"val='{local_i32
131129
}'"
132130
);
131+
println!(no_param_str!(), local_i32);
132+
133133
// FIXME: bugs!
134-
// println!(no_param_str!(), local_i32);
135134
// println!(pass_through!("foo={local_i32}"), local_i32 = local_i32);
136135
// println!(pass_through!("foo={}"), local_i32);
137136
// println!(indoc!("foo={}"), local_i32);

Diff for: tests/ui/uninlined_format_args.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#![warn(clippy::uninlined_format_args)]
99
#![feature(custom_inner_attributes)]
1010

11-
use indoc::{indoc, printdoc};
12-
1311
macro_rules! no_param_str {
1412
() => {
1513
"{}"
@@ -133,8 +131,9 @@ fn tester(fn_arg: i32) {
133131
"val='{local_i32
134132
}'"
135133
);
134+
println!(no_param_str!(), local_i32);
135+
136136
// FIXME: bugs!
137-
// println!(no_param_str!(), local_i32);
138137
// println!(pass_through!("foo={local_i32}"), local_i32 = local_i32);
139138
// println!(pass_through!("foo={}"), local_i32);
140139
// println!(indoc!("foo={}"), local_i32);

0 commit comments

Comments
 (0)