3
3
#![ deny( clippy:: missing_docs_in_private_items) ]
4
4
5
5
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} ;
7
7
use if_chain:: if_chain;
8
8
use rustc_ast:: ast:: { self , LitKind } ;
9
9
use rustc_hir as hir;
10
10
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 ,
12
12
} ;
13
13
use rustc_lint:: LateContext ;
14
14
use rustc_span:: { sym, symbol, ExpnKind , Span , Symbol } ;
@@ -513,8 +513,6 @@ pub struct FormatArgsExpn<'tcx> {
513
513
pub format_string_parts : & ' tcx [ Expr < ' tcx > ] ,
514
514
/// Symbols corresponding to [`Self::format_string_parts`]
515
515
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 > ] ,
518
516
/// Expressions like `ArgumentV1::new(arg0, Debug::fmt)`
519
517
pub args : & ' tcx [ Expr < ' tcx > ] ,
520
518
/// The final argument passed to `Arguments::new_v1_formatted`, if applicable
@@ -559,15 +557,13 @@ impl FormatArgsExpn<'tcx> {
559
557
_ => None ,
560
558
} )
561
559
. collect( ) ;
562
- if let PatKind :: Tuple ( arg_names, None ) = arm. pat. kind;
563
560
if let ExprKind :: Array ( args) = arm. body. kind;
564
561
then {
565
562
Some ( FormatArgsExpn {
566
563
format_string_span: strs_ref. span,
567
564
value_args,
568
565
format_string_parts,
569
566
format_string_symbols,
570
- arg_names,
571
567
args,
572
568
fmt_expr,
573
569
} )
@@ -594,10 +590,8 @@ impl FormatArgsExpn<'tcx> {
594
590
if let Ok ( i) = usize :: try_from( position) ;
595
591
let arg = & self . args[ i] ;
596
592
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 >( ) ;
601
595
then {
602
596
Some ( FormatArgsArg { value: self . value_args[ j] , arg, fmt: Some ( fmt) } )
603
597
} else {
0 commit comments