@@ -438,23 +438,25 @@ fn convert_angle_bracketed_parameters<'tcx>(this: &AstConv<'tcx>,
438438{
439439 let regions: Vec < _ > =
440440 data. lifetimes . iter ( )
441- . map ( |l| ast_region_to_region ( this. tcx ( ) , l) )
442- . collect ( ) ;
441+ . map ( |l| ast_region_to_region ( this. tcx ( ) , l) )
442+ . collect ( ) ;
443443
444444 let region_substs =
445445 create_region_substs ( this, rscope, span, decl_generics, regions) ;
446446
447447 let types: Vec < _ > =
448448 data. types . iter ( )
449- . map ( |t| ast_ty_to_ty ( this, rscope, & * * t) )
450- . collect ( ) ;
449+ . enumerate ( )
450+ . map ( |( i, t) | ast_ty_arg_to_ty ( this, rscope, decl_generics,
451+ i, & region_substs, t) )
452+ . collect ( ) ;
451453
452454 let assoc_bindings: Vec < _ > =
453455 data. bindings . iter ( )
454- . map ( |b| ConvertedBinding { item_name : b. ident . name ,
455- ty : ast_ty_to_ty ( this, rscope, & * b. ty ) ,
456- span : b. span } )
457- . collect ( ) ;
456+ . map ( |b| ConvertedBinding { item_name : b. ident . name ,
457+ ty : ast_ty_to_ty ( this, rscope, & * b. ty ) ,
458+ span : b. span } )
459+ . collect ( ) ;
458460
459461 ( region_substs, types, assoc_bindings)
460462}
@@ -525,9 +527,11 @@ fn convert_parenthesized_parameters<'tcx>(this: &AstConv<'tcx>,
525527 create_region_substs ( this, rscope, span, decl_generics, Vec :: new ( ) ) ;
526528
527529 let binding_rscope = BindingRscope :: new ( ) ;
528- let inputs = data. inputs . iter ( )
529- . map ( |a_t| ast_ty_to_ty ( this, & binding_rscope, & * * a_t) )
530- . collect :: < Vec < Ty < ' tcx > > > ( ) ;
530+ let inputs =
531+ data. inputs . iter ( )
532+ . map ( |a_t| ast_ty_arg_to_ty ( this, & binding_rscope, decl_generics,
533+ 0 , & region_substs, a_t) )
534+ . collect :: < Vec < Ty < ' tcx > > > ( ) ;
531535
532536 let input_params: Vec < _ > = repeat ( String :: new ( ) ) . take ( inputs. len ( ) ) . collect ( ) ;
533537 let ( implied_output_region,
@@ -655,7 +659,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
655659
656660 let ( regions, types, assoc_bindings) = match path. segments . last ( ) . unwrap ( ) . parameters {
657661 ast:: AngleBracketedParameters ( ref data) => {
658- // For now, require that parenthetical5D notation be used
662+ // For now, require that parenthetical notation be used
659663 // only with `Fn()` etc.
660664 if !this. tcx ( ) . sess . features . borrow ( ) . unboxed_closures && trait_def. paren_sugar {
661665 span_err ! ( this. tcx( ) . sess, path. span, E0215 ,
@@ -1070,10 +1074,45 @@ fn qpath_to_ty<'tcx>(this: &AstConv<'tcx>,
10701074 qpath. item_path . identifier . name ) ;
10711075}
10721076
1073- // Parses the programmer's textual representation of a type into our
1074- // internal notion of a type.
1075- pub fn ast_ty_to_ty < ' tcx > (
1076- this : & AstConv < ' tcx > , rscope : & RegionScope , ast_ty : & ast:: Ty ) -> Ty < ' tcx >
1077+ /// Convert a type supplied as value for a type argument from AST into our
1078+ /// our internal representation. This is the same as `ast_ty_to_ty` but that
1079+ /// it applies the object lifetime default.
1080+ ///
1081+ /// # Parameters
1082+ ///
1083+ /// * `this`, `rscope`: the surrounding context
1084+ /// * `decl_generics`: the generics of the struct/enum/trait declaration being
1085+ /// referenced
1086+ /// * `index`: the index of the type parameter being instantiated from the list
1087+ /// (we assume it is in the `TypeSpace`)
1088+ /// * `region_substs`: a partial substitution consisting of
1089+ /// only the region type parameters being supplied to this type.
1090+ /// * `ast_ty`: the ast representation of the type being supplied
1091+ pub fn ast_ty_arg_to_ty < ' tcx > ( this : & AstConv < ' tcx > ,
1092+ rscope : & RegionScope ,
1093+ decl_generics : & ty:: Generics < ' tcx > ,
1094+ index : usize ,
1095+ region_substs : & Substs < ' tcx > ,
1096+ ast_ty : & ast:: Ty )
1097+ -> Ty < ' tcx >
1098+ {
1099+ let tcx = this. tcx ( ) ;
1100+
1101+ if let Some ( def) = decl_generics. types . opt_get ( TypeSpace , index) {
1102+ let object_lifetime_default = def. object_lifetime_default . subst ( tcx, region_substs) ;
1103+ let rscope1 = & ObjectLifetimeDefaultRscope :: new ( rscope, object_lifetime_default) ;
1104+ ast_ty_to_ty ( this, rscope1, ast_ty)
1105+ } else {
1106+ ast_ty_to_ty ( this, rscope, ast_ty)
1107+ }
1108+ }
1109+
1110+ /// Parses the programmer's textual representation of a type into our
1111+ /// internal notion of a type.
1112+ pub fn ast_ty_to_ty < ' tcx > ( this : & AstConv < ' tcx > ,
1113+ rscope : & RegionScope ,
1114+ ast_ty : & ast:: Ty )
1115+ -> Ty < ' tcx >
10771116{
10781117 debug ! ( "ast_ty_to_ty(ast_ty={})" ,
10791118 ast_ty. repr( this. tcx( ) ) ) ;
0 commit comments