@@ -168,6 +168,7 @@ pub trait Resolver {
168168 span : Span ,
169169 crate_root : Option < & str > ,
170170 components : & [ & str ] ,
171+ params : Option < P < hir:: PathParameters > >
171172 is_value: bool ,
172173 ) -> hir:: Path ;
173174}
@@ -876,7 +877,7 @@ impl<'a> LoweringContext<'a> {
876877
877878 let unstable_span = self . allow_internal_unstable ( CompilerDesugaringKind :: Async , span) ;
878879 let gen_future = self . expr_std_path (
879- unstable_span, & [ "raw" , "future_from_generator" ] , ThinVec :: new ( ) ) ;
880+ unstable_span, & [ "raw" , "future_from_generator" ] , None , ThinVec :: new ( ) ) ;
880881 hir:: ExprCall ( P ( gen_future) , hir_vec ! [ generator] )
881882 }
882883
@@ -2115,24 +2116,21 @@ impl<'a> LoweringContext<'a> {
21152116 }
21162117 } ;
21172118
2118- let hir:: Path { def, segments, .. } = this. std_path ( span, & [ "future" , "Future" ] , false ) ;
2119- let future_path = hir:: Path {
2120- segments : segments. map_slice ( |mut v| {
2121- v. last_mut ( ) . unwrap ( ) . parameters = Some ( P ( hir:: PathParameters {
2122- lifetimes : hir_vec ! [ ] ,
2123- types : hir_vec ! [ ] ,
2124- bindings : hir_vec ! [ hir:: TypeBinding {
2125- name: Symbol :: intern( FN_OUTPUT_NAME ) ,
2126- ty: output_ty,
2127- id: this. next_id( ) . node_id,
2128- span,
2129- } ] ,
2130- parenthesized : false ,
2131- } ) ) ;
2132- v
2133- } ) ,
2134- def, span
2135- } ;
2119+ // "<Output = T>"
2120+ let future_params = P ( hir:: PathParameters {
2121+ lifetimes : hir_vec ! [ ] ,
2122+ types : hir_vec ! [ ] ,
2123+ bindings : hir_vec ! [ hir:: TypeBinding {
2124+ name: Symbol :: intern( FN_OUTPUT_NAME ) ,
2125+ ty: output_ty,
2126+ id: this. next_id( ) . node_id,
2127+ span,
2128+ } ] ,
2129+ parenthesized : false ,
2130+ } ) ;
2131+
2132+ let let future_path =
2133+ this. std_path ( span, & [ "future" , "Future" ] , Some ( future_params) , false ) ;
21362134
21372135 // FIXME(cramertj) collect input lifetimes to function and add them to
21382136 // the output `impl Trait` type here.
@@ -3665,7 +3663,7 @@ impl<'a> LoweringContext<'a> {
36653663 let id = self . next_id ( ) ;
36663664 let e1 = self . lower_expr ( e1) ;
36673665 let e2 = self . lower_expr ( e2) ;
3668- let ty_path = P ( self . std_path ( span, & [ "ops" , "RangeInclusive" ] , false ) ) ;
3666+ let ty_path = P ( self . std_path ( span, & [ "ops" , "RangeInclusive" ] , None , false ) ) ;
36693667 let ty = self . ty_path ( id, span, hir:: QPath :: Resolved ( None , ty_path) ) ;
36703668 let new_seg = P ( hir:: PathSegment :: from_name ( Symbol :: intern ( "new" ) ) ) ;
36713669 let new_path = hir:: QPath :: TypeRelative ( ty, new_seg) ;
@@ -3705,7 +3703,7 @@ impl<'a> LoweringContext<'a> {
37053703 let struct_path = iter:: once ( "ops" )
37063704 . chain ( iter:: once ( path) )
37073705 . collect :: < Vec < _ > > ( ) ;
3708- let struct_path = self . std_path ( unstable_span, & struct_path, is_unit) ;
3706+ let struct_path = self . std_path ( unstable_span, & struct_path, None , is_unit) ;
37093707 let struct_path = hir:: QPath :: Resolved ( None , P ( struct_path) ) ;
37103708
37113709 let LoweredNodeId { node_id, hir_id } = self . lower_node_id ( e. id ) ;
@@ -3982,7 +3980,7 @@ impl<'a> LoweringContext<'a> {
39823980 let iter = P ( self . expr_ident ( head_sp, iter, iter_pat. id ) ) ;
39833981 let ref_mut_iter = self . expr_mut_addr_of ( head_sp, iter) ;
39843982 let next_path = & [ "iter" , "Iterator" , "next" ] ;
3985- let next_path = P ( self . expr_std_path ( head_sp, next_path, ThinVec :: new ( ) ) ) ;
3983+ let next_path = P ( self . expr_std_path ( head_sp, next_path, None , ThinVec :: new ( ) ) ) ;
39863984 let next_expr = P ( self . expr_call ( head_sp, next_path, hir_vec ! [ ref_mut_iter] ) ) ;
39873985 let arms = hir_vec ! [ pat_arm, break_arm] ;
39883986
@@ -4040,7 +4038,8 @@ impl<'a> LoweringContext<'a> {
40404038 // `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
40414039 let into_iter_expr = {
40424040 let into_iter_path = & [ "iter" , "IntoIterator" , "into_iter" ] ;
4043- let into_iter = P ( self . expr_std_path ( head_sp, into_iter_path, ThinVec :: new ( ) ) ) ;
4041+ let into_iter = P ( self . expr_std_path (
4042+ head_sp, into_iter_path, None , ThinVec :: new ( ) ) ) ;
40444043 P ( self . expr_call ( head_sp, into_iter, hir_vec ! [ head] ) )
40454044 } ;
40464045
@@ -4086,7 +4085,8 @@ impl<'a> LoweringContext<'a> {
40864085 let sub_expr = self . lower_expr ( sub_expr) ;
40874086
40884087 let path = & [ "ops" , "Try" , "into_result" ] ;
4089- let path = P ( self . expr_std_path ( unstable_span, path, ThinVec :: new ( ) ) ) ;
4088+ let path = P ( self . expr_std_path (
4089+ unstable_span, path, None , ThinVec :: new ( ) ) ) ;
40904090 P ( self . expr_call ( e. span , path, hir_vec ! [ sub_expr] ) )
40914091 } ;
40924092
@@ -4125,7 +4125,8 @@ impl<'a> LoweringContext<'a> {
41254125 let err_local = self . pat_ident ( e. span , err_ident) ;
41264126 let from_expr = {
41274127 let path = & [ "convert" , "From" , "from" ] ;
4128- let from = P ( self . expr_std_path ( e. span , path, ThinVec :: new ( ) ) ) ;
4128+ let from = P ( self . expr_std_path (
4129+ e. span , path, None , ThinVec :: new ( ) ) ) ;
41294130 let err_expr = self . expr_ident ( e. span , err_ident, err_local. id ) ;
41304131
41314132 self . expr_call ( e. span , from, hir_vec ! [ err_expr] )
@@ -4365,9 +4366,10 @@ impl<'a> LoweringContext<'a> {
43654366 & mut self ,
43664367 span : Span ,
43674368 components : & [ & str ] ,
4369+ params : Option < P < hir:: PathParameters > > ,
43684370 attrs : ThinVec < Attribute > ,
43694371 ) -> hir:: Expr {
4370- let path = self . std_path ( span, components, true ) ;
4372+ let path = self . std_path ( span, components, params , true ) ;
43714373 self . expr (
43724374 span,
43734375 hir:: ExprPath ( hir:: QPath :: Resolved ( None , P ( path) ) ) ,
@@ -4492,7 +4494,7 @@ impl<'a> LoweringContext<'a> {
44924494 components : & [ & str ] ,
44934495 subpats : hir:: HirVec < P < hir:: Pat > > ,
44944496 ) -> P < hir:: Pat > {
4495- let path = self . std_path ( span, components, true ) ;
4497+ let path = self . std_path ( span, components, None , true ) ;
44964498 let qpath = hir:: QPath :: Resolved ( None , P ( path) ) ;
44974499 let pt = if subpats. is_empty ( ) {
44984500 hir:: PatKind :: Path ( qpath)
@@ -4539,9 +4541,15 @@ impl<'a> LoweringContext<'a> {
45394541 /// Given suffix ["b","c","d"], returns path `::std::b::c::d` when
45404542 /// `fld.cx.use_std`, and `::core::b::c::d` otherwise.
45414543 /// The path is also resolved according to `is_value`.
4542- fn std_path ( & mut self , span : Span , components : & [ & str ] , is_value : bool ) -> hir:: Path {
4544+ fn std_path (
4545+ & mut self ,
4546+ span : Span ,
4547+ components : & [ & str ] ,
4548+ params : Option < P < hir:: PathParameters > > ,
4549+ is_value : bool
4550+ ) -> hir:: Path {
45434551 self . resolver
4544- . resolve_str_path ( span, self . crate_root , components, is_value)
4552+ . resolve_str_path ( span, self . crate_root , components, params , is_value)
45454553 }
45464554
45474555 fn ty_path ( & mut self , id : LoweredNodeId , span : Span , qpath : hir:: QPath ) -> P < hir:: Ty > {
@@ -4673,7 +4681,7 @@ impl<'a> LoweringContext<'a> {
46734681 unstable_span : Span ,
46744682 ) -> P < hir:: Expr > {
46754683 let path = & [ "ops" , "Try" , method] ;
4676- let from_err = P ( self . expr_std_path ( unstable_span, path,
4684+ let from_err = P ( self . expr_std_path ( unstable_span, path, None ,
46774685 ThinVec :: new ( ) ) ) ;
46784686 P ( self . expr_call ( e. span , from_err, hir_vec ! [ e] ) )
46794687 }
0 commit comments