@@ -1074,11 +1074,15 @@ impl<'a> LoweringContext<'a> {
1074
1074
-> hir:: GenericArg {
1075
1075
match arg {
1076
1076
ast:: GenericArg :: Lifetime ( lt) => GenericArg :: Lifetime ( self . lower_lifetime ( & lt) ) ,
1077
- ast:: GenericArg :: Type ( ty) => GenericArg :: Type ( self . lower_ty ( & ty, itctx) ) ,
1077
+ ast:: GenericArg :: Type ( ty) => GenericArg :: Type ( self . lower_ty_direct ( & ty, itctx) ) ,
1078
1078
}
1079
1079
}
1080
1080
1081
1081
fn lower_ty ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> P < hir:: Ty > {
1082
+ P ( self . lower_ty_direct ( t, itctx) )
1083
+ }
1084
+
1085
+ fn lower_ty_direct ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> hir:: Ty {
1082
1086
let kind = match t. node {
1083
1087
TyKind :: Infer => hir:: TyInfer ,
1084
1088
TyKind :: Err => hir:: TyErr ,
@@ -1115,10 +1119,10 @@ impl<'a> LoweringContext<'a> {
1115
1119
) ,
1116
1120
TyKind :: Never => hir:: TyNever ,
1117
1121
TyKind :: Tup ( ref tys) => {
1118
- hir:: TyTup ( tys. iter ( ) . map ( |ty| self . lower_ty ( ty, itctx) ) . collect ( ) )
1122
+ hir:: TyTup ( tys. iter ( ) . map ( |ty| self . lower_ty_direct ( ty, itctx) ) . collect ( ) )
1119
1123
}
1120
1124
TyKind :: Paren ( ref ty) => {
1121
- return self . lower_ty ( ty, itctx) ;
1125
+ return self . lower_ty_direct ( ty, itctx) ;
1122
1126
}
1123
1127
TyKind :: Path ( ref qself, ref path) => {
1124
1128
let id = self . lower_node_id ( t. id ) ;
@@ -1228,12 +1232,12 @@ impl<'a> LoweringContext<'a> {
1228
1232
} ;
1229
1233
1230
1234
let LoweredNodeId { node_id, hir_id } = self . lower_node_id ( t. id ) ;
1231
- P ( hir:: Ty {
1235
+ hir:: Ty {
1232
1236
id : node_id,
1233
1237
node : kind,
1234
1238
span : t. span ,
1235
1239
hir_id,
1236
- } )
1240
+ }
1237
1241
}
1238
1242
1239
1243
fn lower_existential_impl_trait (
@@ -1636,7 +1640,7 @@ impl<'a> LoweringContext<'a> {
1636
1640
// e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
1637
1641
// `<I as Iterator>::Item::default`.
1638
1642
let new_id = self . next_id ( ) ;
1639
- self . ty_path ( new_id, p. span , hir:: QPath :: Resolved ( qself, path) )
1643
+ P ( self . ty_path ( new_id, p. span , hir:: QPath :: Resolved ( qself, path) ) )
1640
1644
} ;
1641
1645
1642
1646
// Anything after the base path are associated "extensions",
@@ -1667,7 +1671,7 @@ impl<'a> LoweringContext<'a> {
1667
1671
1668
1672
// Wrap the associated extension in another type node.
1669
1673
let new_id = self . next_id ( ) ;
1670
- ty = self . ty_path ( new_id, p. span , qpath) ;
1674
+ ty = P ( self . ty_path ( new_id, p. span , qpath) ) ;
1671
1675
}
1672
1676
1673
1677
// Should've returned in the for loop above.
@@ -1802,10 +1806,10 @@ impl<'a> LoweringContext<'a> {
1802
1806
|this| {
1803
1807
const DISALLOWED : ImplTraitContext = ImplTraitContext :: Disallowed ;
1804
1808
let & ParenthesisedArgs { ref inputs, ref output, span } = data;
1805
- let inputs = inputs. iter ( ) . map ( |ty| this. lower_ty ( ty, DISALLOWED ) ) . collect ( ) ;
1809
+ let inputs = inputs. iter ( ) . map ( |ty| this. lower_ty_direct ( ty, DISALLOWED ) ) . collect ( ) ;
1806
1810
let mk_tup = |this : & mut Self , tys, span| {
1807
1811
let LoweredNodeId { node_id, hir_id } = this. next_id ( ) ;
1808
- P ( hir:: Ty { node : hir:: TyTup ( tys) , id : node_id, hir_id, span } )
1812
+ hir:: Ty { node : hir:: TyTup ( tys) , id : node_id, hir_id, span }
1809
1813
} ;
1810
1814
1811
1815
(
@@ -1818,7 +1822,7 @@ impl<'a> LoweringContext<'a> {
1818
1822
ty: output
1819
1823
. as_ref( )
1820
1824
. map( |ty| this. lower_ty( & ty, DISALLOWED ) )
1821
- . unwrap_or_else( || mk_tup( this, hir:: HirVec :: new( ) , span) ) ,
1825
+ . unwrap_or_else( || P ( mk_tup( this, hir:: HirVec :: new( ) , span) ) ) ,
1822
1826
span: output. as_ref( ) . map_or( span, |ty| ty. span) ,
1823
1827
}
1824
1828
] ,
@@ -1894,9 +1898,9 @@ impl<'a> LoweringContext<'a> {
1894
1898
. iter ( )
1895
1899
. map ( |arg| {
1896
1900
if let Some ( def_id) = fn_def_id {
1897
- self . lower_ty ( & arg. ty , ImplTraitContext :: Universal ( def_id) )
1901
+ self . lower_ty_direct ( & arg. ty , ImplTraitContext :: Universal ( def_id) )
1898
1902
} else {
1899
- self . lower_ty ( & arg. ty , ImplTraitContext :: Disallowed )
1903
+ self . lower_ty_direct ( & arg. ty , ImplTraitContext :: Disallowed )
1900
1904
}
1901
1905
} )
1902
1906
. collect :: < HirVec < _ > > ( ) ;
@@ -1936,7 +1940,7 @@ impl<'a> LoweringContext<'a> {
1936
1940
// fn_def_id: DefId of the parent function. Used to create child impl trait definition.
1937
1941
fn lower_async_fn_ret_ty (
1938
1942
& mut self ,
1939
- inputs : & [ P < hir:: Ty > ] ,
1943
+ inputs : & [ hir:: Ty ] ,
1940
1944
output : & FunctionRetTy ,
1941
1945
fn_def_id : DefId ,
1942
1946
) -> hir:: FunctionRetTy {
@@ -3661,7 +3665,7 @@ impl<'a> LoweringContext<'a> {
3661
3665
let e1 = self . lower_expr ( e1) ;
3662
3666
let e2 = self . lower_expr ( e2) ;
3663
3667
let ty_path = P ( self . std_path ( span, & [ "ops" , "RangeInclusive" ] , None , false ) ) ;
3664
- let ty = self . ty_path ( id, span, hir:: QPath :: Resolved ( None , ty_path) ) ;
3668
+ let ty = P ( self . ty_path ( id, span, hir:: QPath :: Resolved ( None , ty_path) ) ) ;
3665
3669
let new_seg = P ( hir:: PathSegment :: from_name ( Symbol :: intern ( "new" ) ) ) ;
3666
3670
let new_path = hir:: QPath :: TypeRelative ( ty, new_seg) ;
3667
3671
let new = P ( self . expr ( span, hir:: ExprPath ( new_path) , ThinVec :: new ( ) ) ) ;
@@ -4549,7 +4553,7 @@ impl<'a> LoweringContext<'a> {
4549
4553
. resolve_str_path ( span, self . crate_root , components, params, is_value)
4550
4554
}
4551
4555
4552
- fn ty_path ( & mut self , id : LoweredNodeId , span : Span , qpath : hir:: QPath ) -> P < hir:: Ty > {
4556
+ fn ty_path ( & mut self , id : LoweredNodeId , span : Span , qpath : hir:: QPath ) -> hir:: Ty {
4553
4557
let mut id = id;
4554
4558
let node = match qpath {
4555
4559
hir:: QPath :: Resolved ( None , path) => {
@@ -4574,12 +4578,12 @@ impl<'a> LoweringContext<'a> {
4574
4578
}
4575
4579
_ => hir:: TyPath ( qpath) ,
4576
4580
} ;
4577
- P ( hir:: Ty {
4581
+ hir:: Ty {
4578
4582
id : id. node_id ,
4579
4583
hir_id : id. hir_id ,
4580
4584
node,
4581
4585
span,
4582
- } )
4586
+ }
4583
4587
}
4584
4588
4585
4589
/// Invoked to create the lifetime argument for a type `&T`
0 commit comments