@@ -1074,11 +1074,15 @@ impl<'a> LoweringContext<'a> {
10741074 -> hir:: GenericArg {
10751075 match arg {
10761076 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) ) ,
10781078 }
10791079 }
10801080
10811081 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 {
10821086 let kind = match t. node {
10831087 TyKind :: Infer => hir:: TyInfer ,
10841088 TyKind :: Err => hir:: TyErr ,
@@ -1115,10 +1119,10 @@ impl<'a> LoweringContext<'a> {
11151119 ) ,
11161120 TyKind :: Never => hir:: TyNever ,
11171121 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 ( ) )
11191123 }
11201124 TyKind :: Paren ( ref ty) => {
1121- return self . lower_ty ( ty, itctx) ;
1125+ return self . lower_ty_direct ( ty, itctx) ;
11221126 }
11231127 TyKind :: Path ( ref qself, ref path) => {
11241128 let id = self . lower_node_id ( t. id ) ;
@@ -1228,12 +1232,12 @@ impl<'a> LoweringContext<'a> {
12281232 } ;
12291233
12301234 let LoweredNodeId { node_id, hir_id } = self . lower_node_id ( t. id ) ;
1231- P ( hir:: Ty {
1235+ hir:: Ty {
12321236 id : node_id,
12331237 node : kind,
12341238 span : t. span ,
12351239 hir_id,
1236- } )
1240+ }
12371241 }
12381242
12391243 fn lower_existential_impl_trait (
@@ -1636,7 +1640,7 @@ impl<'a> LoweringContext<'a> {
16361640 // e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
16371641 // `<I as Iterator>::Item::default`.
16381642 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) ) )
16401644 } ;
16411645
16421646 // Anything after the base path are associated "extensions",
@@ -1667,7 +1671,7 @@ impl<'a> LoweringContext<'a> {
16671671
16681672 // Wrap the associated extension in another type node.
16691673 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) ) ;
16711675 }
16721676
16731677 // Should've returned in the for loop above.
@@ -1802,10 +1806,10 @@ impl<'a> LoweringContext<'a> {
18021806 |this| {
18031807 const DISALLOWED : ImplTraitContext = ImplTraitContext :: Disallowed ;
18041808 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 ( ) ;
18061810 let mk_tup = |this : & mut Self , tys, span| {
18071811 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 }
18091813 } ;
18101814
18111815 (
@@ -1818,7 +1822,7 @@ impl<'a> LoweringContext<'a> {
18181822 ty: output
18191823 . as_ref( )
18201824 . 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) ) ) ,
18221826 span: output. as_ref( ) . map_or( span, |ty| ty. span) ,
18231827 }
18241828 ] ,
@@ -1894,9 +1898,9 @@ impl<'a> LoweringContext<'a> {
18941898 . iter ( )
18951899 . map ( |arg| {
18961900 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) )
18981902 } else {
1899- self . lower_ty ( & arg. ty , ImplTraitContext :: Disallowed )
1903+ self . lower_ty_direct ( & arg. ty , ImplTraitContext :: Disallowed )
19001904 }
19011905 } )
19021906 . collect :: < HirVec < _ > > ( ) ;
@@ -1936,7 +1940,7 @@ impl<'a> LoweringContext<'a> {
19361940 // fn_def_id: DefId of the parent function. Used to create child impl trait definition.
19371941 fn lower_async_fn_ret_ty (
19381942 & mut self ,
1939- inputs : & [ P < hir:: Ty > ] ,
1943+ inputs : & [ hir:: Ty ] ,
19401944 output : & FunctionRetTy ,
19411945 fn_def_id : DefId ,
19421946 ) -> hir:: FunctionRetTy {
@@ -3661,7 +3665,7 @@ impl<'a> LoweringContext<'a> {
36613665 let e1 = self . lower_expr ( e1) ;
36623666 let e2 = self . lower_expr ( e2) ;
36633667 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) ) ) ;
36653669 let new_seg = P ( hir:: PathSegment :: from_name ( Symbol :: intern ( "new" ) ) ) ;
36663670 let new_path = hir:: QPath :: TypeRelative ( ty, new_seg) ;
36673671 let new = P ( self . expr ( span, hir:: ExprPath ( new_path) , ThinVec :: new ( ) ) ) ;
@@ -4549,7 +4553,7 @@ impl<'a> LoweringContext<'a> {
45494553 . resolve_str_path ( span, self . crate_root , components, params, is_value)
45504554 }
45514555
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 {
45534557 let mut id = id;
45544558 let node = match qpath {
45554559 hir:: QPath :: Resolved ( None , path) => {
@@ -4574,12 +4578,12 @@ impl<'a> LoweringContext<'a> {
45744578 }
45754579 _ => hir:: TyPath ( qpath) ,
45764580 } ;
4577- P ( hir:: Ty {
4581+ hir:: Ty {
45784582 id : id. node_id ,
45794583 hir_id : id. hir_id ,
45804584 node,
45814585 span,
4582- } )
4586+ }
45834587 }
45844588
45854589 /// Invoked to create the lifetime argument for a type `&T`
0 commit comments