@@ -168,6 +168,7 @@ pub trait Resolver {
168
168
span : Span ,
169
169
crate_root : Option < & str > ,
170
170
components : & [ & str ] ,
171
+ params : Option < P < hir:: PathParameters > >
171
172
is_value: bool ,
172
173
) -> hir:: Path ;
173
174
}
@@ -876,7 +877,7 @@ impl<'a> LoweringContext<'a> {
876
877
877
878
let unstable_span = self . allow_internal_unstable ( CompilerDesugaringKind :: Async , span) ;
878
879
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 ( ) ) ;
880
881
hir:: ExprCall ( P ( gen_future) , hir_vec ! [ generator] )
881
882
}
882
883
@@ -2115,24 +2116,21 @@ impl<'a> LoweringContext<'a> {
2115
2116
}
2116
2117
} ;
2117
2118
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 ) ;
2136
2134
2137
2135
// FIXME(cramertj) collect input lifetimes to function and add them to
2138
2136
// the output `impl Trait` type here.
@@ -3665,7 +3663,7 @@ impl<'a> LoweringContext<'a> {
3665
3663
let id = self . next_id ( ) ;
3666
3664
let e1 = self . lower_expr ( e1) ;
3667
3665
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 ) ) ;
3669
3667
let ty = self . ty_path ( id, span, hir:: QPath :: Resolved ( None , ty_path) ) ;
3670
3668
let new_seg = P ( hir:: PathSegment :: from_name ( Symbol :: intern ( "new" ) ) ) ;
3671
3669
let new_path = hir:: QPath :: TypeRelative ( ty, new_seg) ;
@@ -3705,7 +3703,7 @@ impl<'a> LoweringContext<'a> {
3705
3703
let struct_path = iter:: once ( "ops" )
3706
3704
. chain ( iter:: once ( path) )
3707
3705
. 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) ;
3709
3707
let struct_path = hir:: QPath :: Resolved ( None , P ( struct_path) ) ;
3710
3708
3711
3709
let LoweredNodeId { node_id, hir_id } = self . lower_node_id ( e. id ) ;
@@ -3982,7 +3980,7 @@ impl<'a> LoweringContext<'a> {
3982
3980
let iter = P ( self . expr_ident ( head_sp, iter, iter_pat. id ) ) ;
3983
3981
let ref_mut_iter = self . expr_mut_addr_of ( head_sp, iter) ;
3984
3982
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 ( ) ) ) ;
3986
3984
let next_expr = P ( self . expr_call ( head_sp, next_path, hir_vec ! [ ref_mut_iter] ) ) ;
3987
3985
let arms = hir_vec ! [ pat_arm, break_arm] ;
3988
3986
@@ -4040,7 +4038,8 @@ impl<'a> LoweringContext<'a> {
4040
4038
// `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
4041
4039
let into_iter_expr = {
4042
4040
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 ( ) ) ) ;
4044
4043
P ( self . expr_call ( head_sp, into_iter, hir_vec ! [ head] ) )
4045
4044
} ;
4046
4045
@@ -4086,7 +4085,8 @@ impl<'a> LoweringContext<'a> {
4086
4085
let sub_expr = self . lower_expr ( sub_expr) ;
4087
4086
4088
4087
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 ( ) ) ) ;
4090
4090
P ( self . expr_call ( e. span , path, hir_vec ! [ sub_expr] ) )
4091
4091
} ;
4092
4092
@@ -4125,7 +4125,8 @@ impl<'a> LoweringContext<'a> {
4125
4125
let err_local = self . pat_ident ( e. span , err_ident) ;
4126
4126
let from_expr = {
4127
4127
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 ( ) ) ) ;
4129
4130
let err_expr = self . expr_ident ( e. span , err_ident, err_local. id ) ;
4130
4131
4131
4132
self . expr_call ( e. span , from, hir_vec ! [ err_expr] )
@@ -4365,9 +4366,10 @@ impl<'a> LoweringContext<'a> {
4365
4366
& mut self ,
4366
4367
span : Span ,
4367
4368
components : & [ & str ] ,
4369
+ params : Option < P < hir:: PathParameters > > ,
4368
4370
attrs : ThinVec < Attribute > ,
4369
4371
) -> hir:: Expr {
4370
- let path = self . std_path ( span, components, true ) ;
4372
+ let path = self . std_path ( span, components, params , true ) ;
4371
4373
self . expr (
4372
4374
span,
4373
4375
hir:: ExprPath ( hir:: QPath :: Resolved ( None , P ( path) ) ) ,
@@ -4492,7 +4494,7 @@ impl<'a> LoweringContext<'a> {
4492
4494
components : & [ & str ] ,
4493
4495
subpats : hir:: HirVec < P < hir:: Pat > > ,
4494
4496
) -> P < hir:: Pat > {
4495
- let path = self . std_path ( span, components, true ) ;
4497
+ let path = self . std_path ( span, components, None , true ) ;
4496
4498
let qpath = hir:: QPath :: Resolved ( None , P ( path) ) ;
4497
4499
let pt = if subpats. is_empty ( ) {
4498
4500
hir:: PatKind :: Path ( qpath)
@@ -4539,9 +4541,15 @@ impl<'a> LoweringContext<'a> {
4539
4541
/// Given suffix ["b","c","d"], returns path `::std::b::c::d` when
4540
4542
/// `fld.cx.use_std`, and `::core::b::c::d` otherwise.
4541
4543
/// 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 {
4543
4551
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)
4545
4553
}
4546
4554
4547
4555
fn ty_path ( & mut self , id : LoweredNodeId , span : Span , qpath : hir:: QPath ) -> P < hir:: Ty > {
@@ -4673,7 +4681,7 @@ impl<'a> LoweringContext<'a> {
4673
4681
unstable_span : Span ,
4674
4682
) -> P < hir:: Expr > {
4675
4683
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 ,
4677
4685
ThinVec :: new ( ) ) ) ;
4678
4686
P ( self . expr_call ( e. span , from_err, hir_vec ! [ e] ) )
4679
4687
}
0 commit comments