@@ -1047,7 +1047,11 @@ impl<'a> LoweringContext<'a> {
10471047 }
10481048 }
10491049
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 {
10511055 let kind = match t. node {
10521056 TyKind :: Infer => hir:: TyInfer ,
10531057 TyKind :: Err => hir:: TyErr ,
@@ -1087,10 +1091,15 @@ impl<'a> LoweringContext<'a> {
10871091 ) ,
10881092 TyKind :: Never => hir:: TyNever ,
10891093 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+ )
10911100 }
10921101 TyKind :: Paren ( ref ty) => {
1093- return self . lower_ty ( ty, itctx) ;
1102+ return self . lower_ty_direct ( ty, itctx) ;
10941103 }
10951104 TyKind :: Path ( ref qself, ref path) => {
10961105 let id = self . lower_node_id ( t. id ) ;
@@ -1269,12 +1278,12 @@ impl<'a> LoweringContext<'a> {
12691278 } ;
12701279
12711280 let LoweredNodeId { node_id, hir_id } = self . lower_node_id ( t. id ) ;
1272- P ( hir:: Ty {
1281+ hir:: Ty {
12731282 id : node_id,
12741283 node : kind,
12751284 span : t. span ,
12761285 hir_id,
1277- } )
1286+ }
12781287 }
12791288
12801289 fn generics_from_impl_trait_bounds (
@@ -1588,7 +1597,7 @@ impl<'a> LoweringContext<'a> {
15881597 // e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
15891598 // `<I as Iterator>::Item::default`.
15901599 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) ) )
15921601 } ;
15931602
15941603 // Anything after the base path are associated "extensions",
@@ -1619,7 +1628,7 @@ impl<'a> LoweringContext<'a> {
16191628
16201629 // Wrap the associated extension in another type node.
16211630 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) ) ;
16231632 }
16241633
16251634 // Should've returned in the for loop above.
@@ -1727,7 +1736,7 @@ impl<'a> LoweringContext<'a> {
17271736 (
17281737 hir:: PathParameters {
17291738 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 ( ) ,
17311740 bindings : bindings
17321741 . iter ( )
17331742 . map ( |b| self . lower_ty_binding ( b, itctx. reborrow ( ) ) )
@@ -1758,16 +1767,16 @@ impl<'a> LoweringContext<'a> {
17581767 } = data;
17591768 let inputs = inputs
17601769 . iter ( )
1761- . map ( |ty| this. lower_ty ( ty, DISALLOWED ) )
1770+ . map ( |ty| this. lower_ty_direct ( ty, DISALLOWED ) )
17621771 . collect ( ) ;
17631772 let mk_tup = |this : & mut Self , tys, span| {
17641773 let LoweredNodeId { node_id, hir_id } = this. next_id ( ) ;
1765- P ( hir:: Ty {
1774+ hir:: Ty {
17661775 node : hir:: TyTup ( tys) ,
17671776 id : node_id,
17681777 hir_id,
17691778 span,
1770- } )
1779+ }
17711780 } ;
17721781
17731782 (
@@ -1781,7 +1790,7 @@ impl<'a> LoweringContext<'a> {
17811790 ty: output
17821791 . as_ref( )
17831792 . 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) ) ) ,
17851794 span: output. as_ref( ) . map_or( span, |ty| ty. span) ,
17861795 }
17871796 ] ,
@@ -1853,9 +1862,9 @@ impl<'a> LoweringContext<'a> {
18531862 . iter ( )
18541863 . map ( |arg| {
18551864 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) )
18571866 } else {
1858- self . lower_ty ( & arg. ty , ImplTraitContext :: Disallowed )
1867+ self . lower_ty_direct ( & arg. ty , ImplTraitContext :: Disallowed )
18591868 }
18601869 } )
18611870 . collect ( ) ,
@@ -3316,7 +3325,7 @@ impl<'a> LoweringContext<'a> {
33163325 let e1 = self . lower_expr ( e1) ;
33173326 let e2 = self . lower_expr ( e2) ;
33183327 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) ) ) ;
33203329 let new_seg = P ( hir:: PathSegment :: from_name ( Symbol :: intern ( "new" ) ) ) ;
33213330 let new_path = hir:: QPath :: TypeRelative ( ty, new_seg) ;
33223331 let new = P ( self . expr ( span, hir:: ExprPath ( new_path) , ThinVec :: new ( ) ) ) ;
@@ -4194,7 +4203,7 @@ impl<'a> LoweringContext<'a> {
41944203 . resolve_str_path ( span, self . crate_root , components, is_value)
41954204 }
41964205
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 {
41984207 let mut id = id;
41994208 let node = match qpath {
42004209 hir:: QPath :: Resolved ( None , path) => {
@@ -4219,12 +4228,12 @@ impl<'a> LoweringContext<'a> {
42194228 }
42204229 _ => hir:: TyPath ( qpath) ,
42214230 } ;
4222- P ( hir:: Ty {
4231+ hir:: Ty {
42234232 id : id. node_id ,
42244233 hir_id : id. hir_id ,
42254234 node,
42264235 span,
4227- } )
4236+ }
42284237 }
42294238
42304239 /// Invoked to create the lifetime argument for a type `&T`
0 commit comments