Skip to content

Commit 6c2f56f

Browse files
committed
formatting, [args,..] and registering the lint
1 parent 4596d61 commit 6c2f56f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

clippy_lints/src/declared_lints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
495495
crate::partialeq_to_none::PARTIALEQ_TO_NONE_INFO,
496496
crate::pass_by_ref_or_value::LARGE_TYPES_PASSED_BY_VALUE_INFO,
497497
crate::pass_by_ref_or_value::TRIVIALLY_COPY_PASS_BY_REF_INFO,
498+
crate::paths_from_format::PATHS_FROM_FORMAT_INFO,
498499
crate::pattern_type_mismatch::PATTERN_TYPE_MISMATCH_INFO,
499500
crate::permissions_set_readonly_false::PERMISSIONS_SET_READONLY_FALSE_INFO,
500501
crate::precedence::PRECEDENCE_INFO,

clippy_lints/src/paths_from_format.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ declare_lint_pass!(PathsFromFormat => [PATHS_FROM_FORMAT]);
4444
impl<'tcx> LateLintPass<'tcx> for PathsFromFormat {
4545
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
4646
if_chain! {
47-
if let ExprKind::Call(_, args) = expr.kind;
47+
if let ExprKind::Call(_, [args, ..]) = expr.kind;
4848
if let ty = cx.typeck_results().expr_ty(expr);
4949
if is_type_diagnostic_item(cx, ty, sym::PathBuf);
5050
if !args.is_empty();
@@ -54,9 +54,15 @@ impl<'tcx> LateLintPass<'tcx> for PathsFromFormat {
5454
then {
5555
let format_string_parts = format_args.format_string.parts;
5656
let format_value_args = format_args.args;
57-
let string_parts: Vec<&str> = format_string_parts.iter().map(rustc_span::Symbol::as_str).collect();
57+
let string_parts: Vec<&str> = format_string_parts
58+
.iter()
59+
.map(rustc_span::Symbol::as_str)
60+
.collect();
5861
let mut applicability = Applicability::MachineApplicable;
59-
let real_vars: Vec<Sugg<'_>> = format_value_args.iter().map(|x| Sugg::hir_with_applicability(cx, x.param.value, "..", &mut applicability)).collect();
62+
let real_vars: Vec<Sugg<'_>> = format_value_args
63+
.iter()
64+
.map(|x| Sugg::hir_with_applicability(cx, x.param.value, "..", &mut applicability))
65+
.collect();
6066
let mut paths_zip = string_parts.iter().take(real_vars.len()).zip(real_vars.clone());
6167
let mut sugg = String::new();
6268
if let Some((part, arg)) = paths_zip.next() {

0 commit comments

Comments
 (0)