@@ -38,7 +38,6 @@ use crate::hir::def::{DefKind, Namespace, PartialRes, PerNS, Res};
38
38
use crate :: hir:: def_id:: { DefId , DefIndex , CRATE_DEF_INDEX } ;
39
39
use crate :: hir:: map:: { DefKey , DefPathData , Definitions } ;
40
40
use crate :: hir:: ptr:: P ;
41
- use crate :: hir:: HirVec ;
42
41
use crate :: hir:: { self , ParamName } ;
43
42
use crate :: hir:: { ConstArg , GenericArg } ;
44
43
use crate :: lint;
@@ -540,7 +539,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
540
539
visit:: walk_crate ( & mut item:: ItemLowerer { lctx : & mut self } , c) ;
541
540
542
541
let module = self . lower_mod ( & c. module ) ;
543
- let attrs = self . arena . alloc_from_iter ( self . lower_attrs ( & c. attrs ) . into_iter ( ) ) ;
542
+ let attrs = self . lower_attrs ( & c. attrs ) ;
544
543
let body_ids = body_ids ( & self . bodies ) ;
545
544
546
545
self . resolver . definitions ( ) . init_node_id_to_hir_id_mapping ( self . node_id_to_hir_id ) ;
@@ -958,14 +957,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
958
957
}
959
958
}
960
959
961
- fn lower_attrs_arena ( & mut self , attrs : & [ Attribute ] ) -> & ' hir [ Attribute ] {
960
+ fn lower_attrs ( & mut self , attrs : & [ Attribute ] ) -> & ' hir [ Attribute ] {
962
961
self . arena . alloc_from_iter ( attrs. iter ( ) . map ( |a| self . lower_attr ( a) ) )
963
962
}
964
963
965
- fn lower_attrs ( & mut self , attrs : & [ Attribute ] ) -> hir:: HirVec < Attribute > {
966
- attrs. iter ( ) . map ( |a| self . lower_attr ( a) ) . collect :: < Vec < _ > > ( ) . into ( )
967
- }
968
-
969
964
fn lower_attr ( & mut self , attr : & Attribute ) -> Attribute {
970
965
// Note that we explicitly do not walk the path. Since we don't really
971
966
// lower attributes (we use the AST version) there is nowhere to keep
@@ -1225,25 +1220,21 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1225
1220
} ;
1226
1221
hir:: TyKind :: Rptr ( lifetime, self . lower_mt ( mt, itctx) )
1227
1222
}
1228
- TyKind :: BareFn ( ref f) => {
1229
- self . with_in_scope_lifetime_defs ( & f. generic_params , |this| {
1230
- this. with_anonymous_lifetime_mode ( AnonymousLifetimeMode :: PassThrough , |this| {
1231
- hir:: TyKind :: BareFn ( this. arena . alloc ( hir:: BareFnTy {
1232
- generic_params : this. lower_generic_params (
1233
- & f. generic_params ,
1234
- & NodeMap :: default ( ) ,
1235
- ImplTraitContext :: disallowed ( ) ,
1236
- ) ,
1237
- unsafety : f. unsafety ,
1238
- abi : this. lower_extern ( f. ext ) ,
1239
- decl : this. lower_fn_decl ( & f. decl , None , false , None ) ,
1240
- param_names : this. arena . alloc_from_iter (
1241
- this. lower_fn_params_to_names ( & f. decl ) . into_iter ( ) ,
1242
- ) ,
1243
- } ) )
1244
- } )
1223
+ TyKind :: BareFn ( ref f) => self . with_in_scope_lifetime_defs ( & f. generic_params , |this| {
1224
+ this. with_anonymous_lifetime_mode ( AnonymousLifetimeMode :: PassThrough , |this| {
1225
+ hir:: TyKind :: BareFn ( this. arena . alloc ( hir:: BareFnTy {
1226
+ generic_params : this. lower_generic_params (
1227
+ & f. generic_params ,
1228
+ & NodeMap :: default ( ) ,
1229
+ ImplTraitContext :: disallowed ( ) ,
1230
+ ) ,
1231
+ unsafety : f. unsafety ,
1232
+ abi : this. lower_extern ( f. ext ) ,
1233
+ decl : this. lower_fn_decl ( & f. decl , None , false , None ) ,
1234
+ param_names : this. lower_fn_params_to_names ( & f. decl ) ,
1235
+ } ) )
1245
1236
} )
1246
- }
1237
+ } ) ,
1247
1238
TyKind :: Never => hir:: TyKind :: Never ,
1248
1239
TyKind :: Tup ( ref tys) => {
1249
1240
hir:: TyKind :: Tup ( self . arena . alloc_from_iter (
@@ -1412,7 +1403,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1412
1403
opaque_ty_def_index,
1413
1404
& hir_bounds,
1414
1405
) ;
1415
- let lifetime_defs = self . arena . alloc_from_iter ( lifetime_defs. into_iter ( ) ) ;
1416
1406
1417
1407
debug ! ( "lower_opaque_impl_trait: lifetimes={:#?}" , lifetimes, ) ;
1418
1408
@@ -1473,7 +1463,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1473
1463
opaque_ty_id : NodeId ,
1474
1464
parent_index : DefIndex ,
1475
1465
bounds : hir:: GenericBounds < ' hir > ,
1476
- ) -> ( & ' hir [ hir:: GenericArg < ' hir > ] , HirVec < hir:: GenericParam < ' hir > > ) {
1466
+ ) -> ( & ' hir [ hir:: GenericArg < ' hir > ] , & ' hir [ hir :: GenericParam < ' hir > ] ) {
1477
1467
debug ! (
1478
1468
"lifetimes_from_impl_trait_bounds(opaque_ty_id={:?}, \
1479
1469
parent_index={:?}, \
@@ -1640,7 +1630,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1640
1630
let ImplTraitLifetimeCollector { output_lifetimes, output_lifetime_params, .. } =
1641
1631
lifetime_collector;
1642
1632
1643
- ( self . arena . alloc_from_iter ( output_lifetimes) , output_lifetime_params. into ( ) )
1633
+ (
1634
+ self . arena . alloc_from_iter ( output_lifetimes) ,
1635
+ self . arena . alloc_from_iter ( output_lifetime_params) ,
1636
+ )
1644
1637
}
1645
1638
1646
1639
fn lower_qpath (
@@ -2075,21 +2068,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2075
2068
)
2076
2069
}
2077
2070
2078
- fn lower_fn_params_to_names ( & mut self , decl : & FnDecl ) -> hir:: HirVec < Ident > {
2071
+ fn lower_fn_params_to_names ( & mut self , decl : & FnDecl ) -> & ' hir [ Ident ] {
2079
2072
// Skip the `...` (`CVarArgs`) trailing arguments from the AST,
2080
2073
// as they are not explicit in HIR/Ty function signatures.
2081
2074
// (instead, the `c_variadic` flag is set to `true`)
2082
2075
let mut inputs = & decl. inputs [ ..] ;
2083
2076
if decl. c_variadic ( ) {
2084
2077
inputs = & inputs[ ..inputs. len ( ) - 1 ] ;
2085
2078
}
2086
- inputs
2087
- . iter ( )
2088
- . map ( |param| match param. pat . kind {
2089
- PatKind :: Ident ( _, ident, _) => ident,
2090
- _ => Ident :: new ( kw:: Invalid , param. pat . span ) ,
2091
- } )
2092
- . collect ( )
2079
+ self . arena . alloc_from_iter ( inputs. iter ( ) . map ( |param| match param. pat . kind {
2080
+ PatKind :: Ident ( _, ident, _) => ident,
2081
+ _ => Ident :: new ( kw:: Invalid , param. pat . span ) ,
2082
+ } ) )
2093
2083
}
2094
2084
2095
2085
// Lowers a function declaration.
@@ -2571,7 +2561,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2571
2561
name,
2572
2562
span : param. ident . span ,
2573
2563
pure_wrt_drop : attr:: contains_name ( & param. attrs , sym:: may_dangle) ,
2574
- attrs : self . lower_attrs_arena ( & param. attrs ) ,
2564
+ attrs : self . lower_attrs ( & param. attrs ) ,
2575
2565
bounds : self . arena . alloc_from_iter ( bounds) ,
2576
2566
kind,
2577
2567
}
0 commit comments