@@ -313,8 +313,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
313
313
let ( generics, ty) = self . lower_generics (
314
314
& generics,
315
315
id,
316
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
317
- |this| this. lower_ty ( ty, & mut ImplTraitContext :: TypeAliasesOpaqueTy ) ,
316
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
317
+ |this| this. lower_ty ( ty, & ImplTraitContext :: TypeAliasesOpaqueTy ) ,
318
318
) ;
319
319
hir:: ItemKind :: TyAlias ( ty, generics)
320
320
}
@@ -326,7 +326,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
326
326
let ( generics, ty) = self . lower_generics (
327
327
& generics,
328
328
id,
329
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
329
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
330
330
|this| this. arena . alloc ( this. ty ( span, hir:: TyKind :: Err ) ) ,
331
331
) ;
332
332
hir:: ItemKind :: TyAlias ( ty, generics)
@@ -335,7 +335,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
335
335
let ( generics, variants) = self . lower_generics (
336
336
generics,
337
337
id,
338
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
338
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
339
339
|this| {
340
340
this. arena . alloc_from_iter (
341
341
enum_definition. variants . iter ( ) . map ( |x| this. lower_variant ( x) ) ,
@@ -348,7 +348,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
348
348
let ( generics, struct_def) = self . lower_generics (
349
349
generics,
350
350
id,
351
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
351
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
352
352
|this| this. lower_variant_data ( hir_id, struct_def) ,
353
353
) ;
354
354
hir:: ItemKind :: Struct ( struct_def, generics)
@@ -357,7 +357,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
357
357
let ( generics, vdata) = self . lower_generics (
358
358
generics,
359
359
id,
360
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
360
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
361
361
|this| this. lower_variant_data ( hir_id, vdata) ,
362
362
) ;
363
363
hir:: ItemKind :: Union ( vdata, generics)
@@ -391,14 +391,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
391
391
let trait_ref = trait_ref. as_ref ( ) . map ( |trait_ref| {
392
392
this. lower_trait_ref (
393
393
trait_ref,
394
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Trait ) ,
394
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Trait ) ,
395
395
)
396
396
} ) ;
397
397
398
- let lowered_ty = this. lower_ty (
399
- ty,
400
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ,
401
- ) ;
398
+ let lowered_ty = this
399
+ . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
402
400
403
401
( trait_ref, lowered_ty)
404
402
} ) ;
@@ -437,11 +435,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
437
435
let ( generics, ( unsafety, items, bounds) ) = self . lower_generics (
438
436
generics,
439
437
id,
440
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
438
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
441
439
|this| {
442
440
let bounds = this. lower_param_bounds (
443
441
bounds,
444
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
442
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
445
443
) ;
446
444
let items = this. arena . alloc_from_iter (
447
445
items. iter ( ) . map ( |item| this. lower_trait_item_ref ( item) ) ,
@@ -456,11 +454,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
456
454
let ( generics, bounds) = self . lower_generics (
457
455
generics,
458
456
id,
459
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
457
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
460
458
|this| {
461
459
this. lower_param_bounds (
462
460
bounds,
463
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
461
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
464
462
)
465
463
} ,
466
464
) ;
@@ -483,7 +481,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
483
481
span : Span ,
484
482
body : Option < & Expr > ,
485
483
) -> ( & ' hir hir:: Ty < ' hir > , hir:: BodyId ) {
486
- let ty = self . lower_ty ( ty, & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
484
+ let ty = self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
487
485
( ty, self . lower_const_body ( span, body) )
488
486
}
489
487
@@ -675,8 +673,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
675
673
hir:: ForeignItemKind :: Fn ( fn_dec, fn_args, generics)
676
674
}
677
675
ForeignItemKind :: Static ( ref t, m, _) => {
678
- let ty = self
679
- . lower_ty ( t, & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
676
+ let ty =
677
+ self . lower_ty ( t, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
680
678
hir:: ForeignItemKind :: Static ( ty, m)
681
679
}
682
680
ForeignItemKind :: TyAlias ( ..) => hir:: ForeignItemKind :: Type ,
@@ -744,11 +742,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
744
742
qself,
745
743
path,
746
744
ParamMode :: ExplicitNamed , // no `'_` in declarations (Issue #61124)
747
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
745
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
748
746
) ;
749
747
self . arena . alloc ( t)
750
748
} else {
751
- self . lower_ty ( & f. ty , & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) )
749
+ self . lower_ty ( & f. ty , & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) )
752
750
} ;
753
751
let hir_id = self . lower_node_id ( f. id ) ;
754
752
self . lower_attrs ( hir_id, & f. attrs ) ;
@@ -771,8 +769,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
771
769
772
770
let ( generics, kind, has_default) = match i. kind {
773
771
AssocItemKind :: Const ( _, ref ty, ref default) => {
774
- let ty =
775
- self . lower_ty ( ty, & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
772
+ let ty = self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
776
773
let body = default. as_ref ( ) . map ( |x| self . lower_const_body ( i. span , Some ( x) ) ) ;
777
774
( hir:: Generics :: empty ( ) , hir:: TraitItemKind :: Const ( ty, body) , body. is_some ( ) )
778
775
}
@@ -813,18 +810,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
813
810
let ( generics, kind) = self . lower_generics (
814
811
& generics,
815
812
i. id ,
816
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
813
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
817
814
|this| {
818
815
let ty = ty. as_ref ( ) . map ( |x| {
819
- this. lower_ty (
820
- x,
821
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ,
822
- )
816
+ this. lower_ty ( x, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) )
823
817
} ) ;
824
818
hir:: TraitItemKind :: Type (
825
819
this. lower_param_bounds (
826
820
bounds,
827
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
821
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
828
822
) ,
829
823
ty,
830
824
)
@@ -877,8 +871,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
877
871
878
872
let ( generics, kind) = match & i. kind {
879
873
AssocItemKind :: Const ( _, ty, expr) => {
880
- let ty =
881
- self . lower_ty ( ty, & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
874
+ let ty = self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
882
875
(
883
876
hir:: Generics :: empty ( ) ,
884
877
hir:: ImplItemKind :: Const ( ty, self . lower_const_body ( i. span , expr. as_deref ( ) ) ) ,
@@ -905,14 +898,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
905
898
self . lower_generics (
906
899
& generics,
907
900
i. id ,
908
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
901
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
909
902
|this| match ty {
910
903
None => {
911
904
let ty = this. arena . alloc ( this. ty ( i. span , hir:: TyKind :: Err ) ) ;
912
905
hir:: ImplItemKind :: TyAlias ( ty)
913
906
}
914
907
Some ( ty) => {
915
- let ty = this. lower_ty ( ty, & mut ImplTraitContext :: TypeAliasesOpaqueTy ) ;
908
+ let ty = this. lower_ty ( ty, & ImplTraitContext :: TypeAliasesOpaqueTy ) ;
916
909
hir:: ImplItemKind :: TyAlias ( ty)
917
910
}
918
911
} ,
@@ -1322,7 +1315,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1322
1315
& mut self ,
1323
1316
generics : & Generics ,
1324
1317
parent_node_id : NodeId ,
1325
- itctx : & mut ImplTraitContext ,
1318
+ itctx : & ImplTraitContext ,
1326
1319
f : impl FnOnce ( & mut Self ) -> T ,
1327
1320
) -> ( & ' hir hir:: Generics < ' hir > , T ) {
1328
1321
debug_assert ! ( self . impl_trait_defs. is_empty( ) ) ;
@@ -1427,7 +1420,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1427
1420
id : NodeId ,
1428
1421
kind : & GenericParamKind ,
1429
1422
bounds : & [ GenericBound ] ,
1430
- itctx : & mut ImplTraitContext ,
1423
+ itctx : & ImplTraitContext ,
1431
1424
origin : PredicateOrigin ,
1432
1425
) -> Option < hir:: WherePredicate < ' hir > > {
1433
1426
// Do not create a clause if we do not have anything inside it.
@@ -1502,14 +1495,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
1502
1495
span,
1503
1496
} ) => hir:: WherePredicate :: BoundPredicate ( hir:: WhereBoundPredicate {
1504
1497
bound_generic_params : self . lower_generic_params ( bound_generic_params) ,
1505
- bounded_ty : self . lower_ty (
1506
- bounded_ty,
1507
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ,
1508
- ) ,
1498
+ bounded_ty : self
1499
+ . lower_ty ( bounded_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ,
1509
1500
bounds : self . arena . alloc_from_iter ( bounds. iter ( ) . map ( |bound| {
1510
1501
self . lower_param_bound (
1511
1502
bound,
1512
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
1503
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
1513
1504
)
1514
1505
} ) ) ,
1515
1506
span : self . lower_span ( span) ,
@@ -1524,20 +1515,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
1524
1515
lifetime : self . lower_lifetime ( lifetime) ,
1525
1516
bounds : self . lower_param_bounds (
1526
1517
bounds,
1527
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
1518
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
1528
1519
) ,
1529
1520
in_where_clause : true ,
1530
1521
} ) ,
1531
1522
WherePredicate :: EqPredicate ( WhereEqPredicate { ref lhs_ty, ref rhs_ty, span } ) => {
1532
1523
hir:: WherePredicate :: EqPredicate ( hir:: WhereEqPredicate {
1533
- lhs_ty : self . lower_ty (
1534
- lhs_ty,
1535
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ,
1536
- ) ,
1537
- rhs_ty : self . lower_ty (
1538
- rhs_ty,
1539
- & mut ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ,
1540
- ) ,
1524
+ lhs_ty : self
1525
+ . lower_ty ( lhs_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ,
1526
+ rhs_ty : self
1527
+ . lower_ty ( rhs_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ,
1541
1528
span : self . lower_span ( span) ,
1542
1529
} )
1543
1530
}
0 commit comments