@@ -245,7 +245,8 @@ pub struct MethodDef<'a> {
245
245
pub struct Substructure < ' a > {
246
246
/// ident of self
247
247
pub type_ident : Ident ,
248
- /// verbatim access to any non-selflike arguments
248
+ /// Verbatim access to any non-selflike arguments, i.e. arguments that
249
+ /// don't have type `&Self`.
249
250
pub nonselflike_args : & ' a [ P < Expr > ] ,
250
251
pub fields : & ' a SubstructureFields < ' a > ,
251
252
}
@@ -934,10 +935,9 @@ impl<'a> MethodDef<'a> {
934
935
935
936
let arg_expr = cx. expr_ident ( span, ident) ;
936
937
937
- match * ty {
938
- // for static methods, just treat any Self
939
- // arguments as a normal arg
940
- Ref ( ref ty, _) if matches ! ( * * ty, Self_ ) && !self . is_static ( ) => {
938
+ match ty {
939
+ // Selflike (`&Self`) arguments only occur in non-static methods.
940
+ Ref ( box Self_ , _) if !self . is_static ( ) => {
941
941
selflike_args. push ( cx. expr_deref ( span, arg_expr) )
942
942
}
943
943
Self_ => cx. span_bug ( span, "`Self` in non-return position" ) ,
@@ -1459,11 +1459,8 @@ impl<'a> TraitDef<'a> {
1459
1459
prefixes
1460
1460
. iter ( )
1461
1461
. map ( |prefix| {
1462
- let pieces: Vec < _ > = struct_def
1463
- . fields ( )
1464
- . iter ( )
1465
- . enumerate ( )
1466
- . map ( |( i, struct_field) | {
1462
+ let pieces_iter =
1463
+ struct_def. fields ( ) . iter ( ) . enumerate ( ) . map ( |( i, struct_field) | {
1467
1464
let sp = struct_field. span . with_ctxt ( self . span . ctxt ( ) ) ;
1468
1465
let binding_mode = if use_temporaries {
1469
1466
ast:: BindingMode :: ByValue ( ast:: Mutability :: Not )
@@ -1477,14 +1474,12 @@ impl<'a> TraitDef<'a> {
1477
1474
struct_field. ident ,
1478
1475
cx. pat ( path. span , PatKind :: Ident ( binding_mode, path, None ) ) ,
1479
1476
)
1480
- } )
1481
- . collect ( ) ;
1477
+ } ) ;
1482
1478
1483
1479
let struct_path = struct_path. clone ( ) ;
1484
1480
match * struct_def {
1485
1481
VariantData :: Struct ( ..) => {
1486
- let field_pats = pieces
1487
- . into_iter ( )
1482
+ let field_pats = pieces_iter
1488
1483
. map ( |( sp, ident, pat) | {
1489
1484
if ident. is_none ( ) {
1490
1485
cx. span_bug (
@@ -1506,7 +1501,7 @@ impl<'a> TraitDef<'a> {
1506
1501
cx. pat_struct ( self . span , struct_path, field_pats)
1507
1502
}
1508
1503
VariantData :: Tuple ( ..) => {
1509
- let subpats = pieces . into_iter ( ) . map ( |( _, _, subpat) | subpat) . collect ( ) ;
1504
+ let subpats = pieces_iter . map ( |( _, _, subpat) | subpat) . collect ( ) ;
1510
1505
cx. pat_tuple_struct ( self . span , struct_path, subpats)
1511
1506
}
1512
1507
VariantData :: Unit ( ..) => cx. pat_path ( self . span , struct_path) ,
0 commit comments