Skip to content

Commit 8e21f3a

Browse files
committed
Fix Clippy with changed format_args!
1 parent 9f6a58e commit 8e21f3a

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/tools/clippy/clippy_utils/src/higher.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
#![deny(clippy::missing_docs_in_private_items)]
44

55
use crate::ty::is_type_diagnostic_item;
6-
use crate::{is_expn_of, last_path_segment, match_def_path, path_to_local_id, paths};
6+
use crate::{is_expn_of, last_path_segment, match_def_path, paths};
77
use if_chain::if_chain;
88
use rustc_ast::ast::{self, LitKind};
99
use rustc_hir as hir;
1010
use rustc_hir::{
11-
Arm, Block, BorrowKind, Expr, ExprKind, HirId, LoopSource, MatchSource, Node, Pat, PatKind, QPath, StmtKind, UnOp,
11+
Arm, Block, BorrowKind, Expr, ExprKind, HirId, LoopSource, MatchSource, Node, Pat, QPath, StmtKind, UnOp,
1212
};
1313
use rustc_lint::LateContext;
1414
use rustc_span::{sym, symbol, ExpnKind, Span, Symbol};
@@ -513,8 +513,6 @@ pub struct FormatArgsExpn<'tcx> {
513513
pub format_string_parts: &'tcx [Expr<'tcx>],
514514
/// Symbols corresponding to [`Self::format_string_parts`]
515515
pub format_string_symbols: Vec<Symbol>,
516-
/// Match arm patterns, the `arg0`, etc. from the next field `args`
517-
pub arg_names: &'tcx [Pat<'tcx>],
518516
/// Expressions like `ArgumentV1::new(arg0, Debug::fmt)`
519517
pub args: &'tcx [Expr<'tcx>],
520518
/// The final argument passed to `Arguments::new_v1_formatted`, if applicable
@@ -559,15 +557,13 @@ impl FormatArgsExpn<'tcx> {
559557
_ => None,
560558
})
561559
.collect();
562-
if let PatKind::Tuple(arg_names, None) = arm.pat.kind;
563560
if let ExprKind::Array(args) = arm.body.kind;
564561
then {
565562
Some(FormatArgsExpn {
566563
format_string_span: strs_ref.span,
567564
value_args,
568565
format_string_parts,
569566
format_string_symbols,
570-
arg_names,
571567
args,
572568
fmt_expr,
573569
})
@@ -594,10 +590,8 @@ impl FormatArgsExpn<'tcx> {
594590
if let Ok(i) = usize::try_from(position);
595591
let arg = &self.args[i];
596592
if let ExprKind::Call(_, [arg_name, _]) = arg.kind;
597-
if let Some(j) = self
598-
.arg_names
599-
.iter()
600-
.position(|pat| path_to_local_id(arg_name, pat.hir_id));
593+
if let ExprKind::Field(_, j) = arg_name.kind;
594+
if let Ok(j) = j.name.as_str().parse::<usize>();
601595
then {
602596
Some(FormatArgsArg { value: self.value_args[j], arg, fmt: Some(fmt) })
603597
} else {

0 commit comments

Comments
 (0)