@@ -1047,7 +1047,11 @@ impl<'a> LoweringContext<'a> {
1047
1047
}
1048
1048
}
1049
1049
1050
- fn lower_ty ( & mut self , t : & Ty , mut itctx : ImplTraitContext ) -> P < hir:: Ty > {
1050
+ fn lower_ty ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> P < hir:: Ty > {
1051
+ P ( self . lower_ty_direct ( t, itctx) )
1052
+ }
1053
+
1054
+ fn lower_ty_direct ( & mut self , t : & Ty , mut itctx : ImplTraitContext ) -> hir:: Ty {
1051
1055
let kind = match t. node {
1052
1056
TyKind :: Infer => hir:: TyInfer ,
1053
1057
TyKind :: Err => hir:: TyErr ,
@@ -1087,10 +1091,15 @@ impl<'a> LoweringContext<'a> {
1087
1091
) ,
1088
1092
TyKind :: Never => hir:: TyNever ,
1089
1093
TyKind :: Tup ( ref tys) => {
1090
- hir:: TyTup ( tys. iter ( ) . map ( |ty| self . lower_ty ( ty, itctx. reborrow ( ) ) ) . collect ( ) )
1094
+ hir:: TyTup (
1095
+ tys
1096
+ . iter ( )
1097
+ . map ( |ty| self . lower_ty_direct ( ty, itctx. reborrow ( ) ) )
1098
+ . collect ( )
1099
+ )
1091
1100
}
1092
1101
TyKind :: Paren ( ref ty) => {
1093
- return self . lower_ty ( ty, itctx) ;
1102
+ return self . lower_ty_direct ( ty, itctx) ;
1094
1103
}
1095
1104
TyKind :: Path ( ref qself, ref path) => {
1096
1105
let id = self . lower_node_id ( t. id ) ;
@@ -1269,12 +1278,12 @@ impl<'a> LoweringContext<'a> {
1269
1278
} ;
1270
1279
1271
1280
let LoweredNodeId { node_id, hir_id } = self . lower_node_id ( t. id ) ;
1272
- P ( hir:: Ty {
1281
+ hir:: Ty {
1273
1282
id : node_id,
1274
1283
node : kind,
1275
1284
span : t. span ,
1276
1285
hir_id,
1277
- } )
1286
+ }
1278
1287
}
1279
1288
1280
1289
fn generics_from_impl_trait_bounds (
@@ -1588,7 +1597,7 @@ impl<'a> LoweringContext<'a> {
1588
1597
// e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
1589
1598
// `<I as Iterator>::Item::default`.
1590
1599
let new_id = self . next_id ( ) ;
1591
- self . ty_path ( new_id, p. span , hir:: QPath :: Resolved ( qself, path) )
1600
+ P ( self . ty_path ( new_id, p. span , hir:: QPath :: Resolved ( qself, path) ) )
1592
1601
} ;
1593
1602
1594
1603
// Anything after the base path are associated "extensions",
@@ -1619,7 +1628,7 @@ impl<'a> LoweringContext<'a> {
1619
1628
1620
1629
// Wrap the associated extension in another type node.
1621
1630
let new_id = self . next_id ( ) ;
1622
- ty = self . ty_path ( new_id, p. span , qpath) ;
1631
+ ty = P ( self . ty_path ( new_id, p. span , qpath) ) ;
1623
1632
}
1624
1633
1625
1634
// Should've returned in the for loop above.
@@ -1727,7 +1736,7 @@ impl<'a> LoweringContext<'a> {
1727
1736
(
1728
1737
hir:: PathParameters {
1729
1738
lifetimes : self . lower_lifetimes ( lifetimes) ,
1730
- types : types. iter ( ) . map ( |ty| self . lower_ty ( ty, itctx. reborrow ( ) ) ) . collect ( ) ,
1739
+ types : types. iter ( ) . map ( |ty| self . lower_ty_direct ( ty, itctx. reborrow ( ) ) ) . collect ( ) ,
1731
1740
bindings : bindings
1732
1741
. iter ( )
1733
1742
. map ( |b| self . lower_ty_binding ( b, itctx. reborrow ( ) ) )
@@ -1758,16 +1767,16 @@ impl<'a> LoweringContext<'a> {
1758
1767
} = data;
1759
1768
let inputs = inputs
1760
1769
. iter ( )
1761
- . map ( |ty| this. lower_ty ( ty, DISALLOWED ) )
1770
+ . map ( |ty| this. lower_ty_direct ( ty, DISALLOWED ) )
1762
1771
. collect ( ) ;
1763
1772
let mk_tup = |this : & mut Self , tys, span| {
1764
1773
let LoweredNodeId { node_id, hir_id } = this. next_id ( ) ;
1765
- P ( hir:: Ty {
1774
+ hir:: Ty {
1766
1775
node : hir:: TyTup ( tys) ,
1767
1776
id : node_id,
1768
1777
hir_id,
1769
1778
span,
1770
- } )
1779
+ }
1771
1780
} ;
1772
1781
1773
1782
(
@@ -1781,7 +1790,7 @@ impl<'a> LoweringContext<'a> {
1781
1790
ty: output
1782
1791
. as_ref( )
1783
1792
. map( |ty| this. lower_ty( & ty, DISALLOWED ) )
1784
- . unwrap_or_else( || mk_tup( this, hir:: HirVec :: new( ) , span) ) ,
1793
+ . unwrap_or_else( || P ( mk_tup( this, hir:: HirVec :: new( ) , span) ) ) ,
1785
1794
span: output. as_ref( ) . map_or( span, |ty| ty. span) ,
1786
1795
}
1787
1796
] ,
@@ -1853,9 +1862,9 @@ impl<'a> LoweringContext<'a> {
1853
1862
. iter ( )
1854
1863
. map ( |arg| {
1855
1864
if let Some ( ( def_id, ibty, _) ) = in_band_ty_params. as_mut ( ) {
1856
- self . lower_ty ( & arg. ty , ImplTraitContext :: Universal ( * def_id, ibty) )
1865
+ self . lower_ty_direct ( & arg. ty , ImplTraitContext :: Universal ( * def_id, ibty) )
1857
1866
} else {
1858
- self . lower_ty ( & arg. ty , ImplTraitContext :: Disallowed )
1867
+ self . lower_ty_direct ( & arg. ty , ImplTraitContext :: Disallowed )
1859
1868
}
1860
1869
} )
1861
1870
. collect ( ) ,
@@ -3316,7 +3325,7 @@ impl<'a> LoweringContext<'a> {
3316
3325
let e1 = self . lower_expr ( e1) ;
3317
3326
let e2 = self . lower_expr ( e2) ;
3318
3327
let ty_path = P ( self . std_path ( span, & [ "ops" , "RangeInclusive" ] , false ) ) ;
3319
- let ty = self . ty_path ( id, span, hir:: QPath :: Resolved ( None , ty_path) ) ;
3328
+ let ty = P ( self . ty_path ( id, span, hir:: QPath :: Resolved ( None , ty_path) ) ) ;
3320
3329
let new_seg = P ( hir:: PathSegment :: from_name ( Symbol :: intern ( "new" ) ) ) ;
3321
3330
let new_path = hir:: QPath :: TypeRelative ( ty, new_seg) ;
3322
3331
let new = P ( self . expr ( span, hir:: ExprPath ( new_path) , ThinVec :: new ( ) ) ) ;
@@ -4194,7 +4203,7 @@ impl<'a> LoweringContext<'a> {
4194
4203
. resolve_str_path ( span, self . crate_root , components, is_value)
4195
4204
}
4196
4205
4197
- fn ty_path ( & mut self , id : LoweredNodeId , span : Span , qpath : hir:: QPath ) -> P < hir:: Ty > {
4206
+ fn ty_path ( & mut self , id : LoweredNodeId , span : Span , qpath : hir:: QPath ) -> hir:: Ty {
4198
4207
let mut id = id;
4199
4208
let node = match qpath {
4200
4209
hir:: QPath :: Resolved ( None , path) => {
@@ -4219,12 +4228,12 @@ impl<'a> LoweringContext<'a> {
4219
4228
}
4220
4229
_ => hir:: TyPath ( qpath) ,
4221
4230
} ;
4222
- P ( hir:: Ty {
4231
+ hir:: Ty {
4223
4232
id : id. node_id ,
4224
4233
hir_id : id. hir_id ,
4225
4234
node,
4226
4235
span,
4227
- } )
4236
+ }
4228
4237
}
4229
4238
4230
4239
/// Invoked to create the lifetime argument for a type `&T`
0 commit comments