Return a value from find_format_args instead of using a callback

This commit is contained in:
Alex Macleod 2023-09-01 17:05:30 +00:00
parent b788addfcc
commit c29de92d85
9 changed files with 126 additions and 129 deletions

View file

@ -304,7 +304,7 @@ impl<'tcx> LateLintPass<'tcx> for Write {
_ => return,
}
find_format_args(cx, expr, macro_call.expn, |format_args| {
if let Some(format_args) = find_format_args(cx, expr, macro_call.expn) {
// ignore `writeln!(w)` and `write!(v, some_macro!())`
if format_args.span.from_expansion() {
return;
@ -312,15 +312,15 @@ impl<'tcx> LateLintPass<'tcx> for Write {
match diag_name {
sym::print_macro | sym::eprint_macro | sym::write_macro => {
check_newline(cx, format_args, &macro_call, name);
check_newline(cx, &format_args, &macro_call, name);
},
sym::println_macro | sym::eprintln_macro | sym::writeln_macro => {
check_empty_string(cx, format_args, &macro_call, name);
check_empty_string(cx, &format_args, &macro_call, name);
},
_ => {},
}
check_literal(cx, format_args, name);
check_literal(cx, &format_args, name);
if !self.in_debug_impl {
for piece in &format_args.template {
@ -334,7 +334,7 @@ impl<'tcx> LateLintPass<'tcx> for Write {
}
}
}
});
}
}
}