@@ -1049,7 +1049,11 @@ impl<'a> LoweringContext<'a> {
1049
1049
}
1050
1050
}
1051
1051
1052
- fn lower_ty ( & mut self , t : & Ty , mut itctx : ImplTraitContext ) -> P < hir:: Ty > {
1052
+ fn lower_ty ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> P < hir:: Ty > {
1053
+ P ( self . lower_ty_direct ( t, itctx) )
1054
+ }
1055
+
1056
+ fn lower_ty_direct ( & mut self , t : & Ty , mut itctx : ImplTraitContext ) -> hir:: Ty {
1053
1057
let kind = match t. node {
1054
1058
TyKind :: Infer => hir:: TyInfer ,
1055
1059
TyKind :: Err => hir:: TyErr ,
@@ -1086,10 +1090,15 @@ impl<'a> LoweringContext<'a> {
1086
1090
) ,
1087
1091
TyKind :: Never => hir:: TyNever ,
1088
1092
TyKind :: Tup ( ref tys) => {
1089
- hir:: TyTup ( tys. iter ( ) . map ( |ty| self . lower_ty ( ty, itctx. reborrow ( ) ) ) . collect ( ) )
1093
+ hir:: TyTup (
1094
+ tys
1095
+ . iter ( )
1096
+ . map ( |ty| self . lower_ty_direct ( ty, itctx. reborrow ( ) ) )
1097
+ . collect ( )
1098
+ )
1090
1099
}
1091
1100
TyKind :: Paren ( ref ty) => {
1092
- return self . lower_ty ( ty, itctx) ;
1101
+ return self . lower_ty_direct ( ty, itctx) ;
1093
1102
}
1094
1103
TyKind :: Path ( ref qself, ref path) => {
1095
1104
let id = self . lower_node_id ( t. id ) ;
@@ -1270,12 +1279,12 @@ impl<'a> LoweringContext<'a> {
1270
1279
} ;
1271
1280
1272
1281
let LoweredNodeId { node_id, hir_id } = self . lower_node_id ( t. id ) ;
1273
- P ( hir:: Ty {
1282
+ hir:: Ty {
1274
1283
id : node_id,
1275
1284
node : kind,
1276
1285
span : t. span ,
1277
1286
hir_id,
1278
- } )
1287
+ }
1279
1288
}
1280
1289
1281
1290
fn generics_from_impl_trait_bounds (
@@ -1596,7 +1605,7 @@ impl<'a> LoweringContext<'a> {
1596
1605
// e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
1597
1606
// `<I as Iterator>::Item::default`.
1598
1607
let new_id = self . next_id ( ) ;
1599
- self . ty_path ( new_id, p. span , hir:: QPath :: Resolved ( qself, path) )
1608
+ P ( self . ty_path ( new_id, p. span , hir:: QPath :: Resolved ( qself, path) ) )
1600
1609
} ;
1601
1610
1602
1611
// Anything after the base path are associated "extensions",
@@ -1627,7 +1636,7 @@ impl<'a> LoweringContext<'a> {
1627
1636
1628
1637
// Wrap the associated extension in another type node.
1629
1638
let new_id = self . next_id ( ) ;
1630
- ty = self . ty_path ( new_id, p. span , qpath) ;
1639
+ ty = P ( self . ty_path ( new_id, p. span , qpath) ) ;
1631
1640
}
1632
1641
1633
1642
// Should've returned in the for loop above.
@@ -1762,10 +1771,10 @@ impl<'a> LoweringContext<'a> {
1762
1771
|this| {
1763
1772
const DISALLOWED : ImplTraitContext = ImplTraitContext :: Disallowed ;
1764
1773
let & ParenthesisedArgs { ref inputs, ref output, span } = data;
1765
- let inputs = inputs. iter ( ) . map ( |ty| this. lower_ty ( ty, DISALLOWED ) ) . collect ( ) ;
1774
+ let inputs = inputs. iter ( ) . map ( |ty| this. lower_ty_direct ( ty, DISALLOWED ) ) . collect ( ) ;
1766
1775
let mk_tup = |this : & mut Self , tys, span| {
1767
1776
let LoweredNodeId { node_id, hir_id } = this. next_id ( ) ;
1768
- P ( hir:: Ty { node : hir:: TyTup ( tys) , id : node_id, hir_id, span } )
1777
+ hir:: Ty { node : hir:: TyTup ( tys) , id : node_id, hir_id, span }
1769
1778
} ;
1770
1779
1771
1780
(
@@ -1778,7 +1787,7 @@ impl<'a> LoweringContext<'a> {
1778
1787
ty: output
1779
1788
. as_ref( )
1780
1789
. map( |ty| this. lower_ty( & ty, DISALLOWED ) )
1781
- . unwrap_or_else( || mk_tup( this, hir:: HirVec :: new( ) , span) ) ,
1790
+ . unwrap_or_else( || P ( mk_tup( this, hir:: HirVec :: new( ) , span) ) ) ,
1782
1791
span: output. as_ref( ) . map_or( span, |ty| ty. span) ,
1783
1792
}
1784
1793
] ,
@@ -1850,9 +1859,9 @@ impl<'a> LoweringContext<'a> {
1850
1859
. iter ( )
1851
1860
. map ( |arg| {
1852
1861
if let Some ( ( def_id, ibty, _) ) = in_band_ty_params. as_mut ( ) {
1853
- self . lower_ty ( & arg. ty , ImplTraitContext :: Universal ( * def_id, ibty) )
1862
+ self . lower_ty_direct ( & arg. ty , ImplTraitContext :: Universal ( * def_id, ibty) )
1854
1863
} else {
1855
- self . lower_ty ( & arg. ty , ImplTraitContext :: Disallowed )
1864
+ self . lower_ty_direct ( & arg. ty , ImplTraitContext :: Disallowed )
1856
1865
}
1857
1866
} )
1858
1867
. collect ( ) ,
@@ -3302,7 +3311,7 @@ impl<'a> LoweringContext<'a> {
3302
3311
let e1 = self . lower_expr ( e1) ;
3303
3312
let e2 = self . lower_expr ( e2) ;
3304
3313
let ty_path = P ( self . std_path ( span, & [ "ops" , "RangeInclusive" ] , false ) ) ;
3305
- let ty = self . ty_path ( id, span, hir:: QPath :: Resolved ( None , ty_path) ) ;
3314
+ let ty = P ( self . ty_path ( id, span, hir:: QPath :: Resolved ( None , ty_path) ) ) ;
3306
3315
let new_seg = P ( hir:: PathSegment :: from_name ( Symbol :: intern ( "new" ) ) ) ;
3307
3316
let new_path = hir:: QPath :: TypeRelative ( ty, new_seg) ;
3308
3317
let new = P ( self . expr ( span, hir:: ExprPath ( new_path) , ThinVec :: new ( ) ) ) ;
@@ -4180,7 +4189,7 @@ impl<'a> LoweringContext<'a> {
4180
4189
. resolve_str_path ( span, self . crate_root , components, is_value)
4181
4190
}
4182
4191
4183
- fn ty_path ( & mut self , id : LoweredNodeId , span : Span , qpath : hir:: QPath ) -> P < hir:: Ty > {
4192
+ fn ty_path ( & mut self , id : LoweredNodeId , span : Span , qpath : hir:: QPath ) -> hir:: Ty {
4184
4193
let mut id = id;
4185
4194
let node = match qpath {
4186
4195
hir:: QPath :: Resolved ( None , path) => {
@@ -4205,12 +4214,12 @@ impl<'a> LoweringContext<'a> {
4205
4214
}
4206
4215
_ => hir:: TyPath ( qpath) ,
4207
4216
} ;
4208
- P ( hir:: Ty {
4217
+ hir:: Ty {
4209
4218
id : id. node_id ,
4210
4219
hir_id : id. hir_id ,
4211
4220
node,
4212
4221
span,
4213
- } )
4222
+ }
4214
4223
}
4215
4224
4216
4225
/// Invoked to create the lifetime argument for a type `&T`
0 commit comments