@@ -2239,6 +2239,34 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2239
2239
2240
2240
obligations. map_move ( |o| self . register_predicate ( o) ) ;
2241
2241
}
2242
+
2243
+ // Only for fields! Returns <none> for methods>
2244
+ // Indifferent to privacy flags
2245
+ pub fn lookup_field_ty ( & self ,
2246
+ span : Span ,
2247
+ class_id : ast:: DefId ,
2248
+ items : & [ ty:: field_ty ] ,
2249
+ fieldname : ast:: Name ,
2250
+ substs : & subst:: Substs < ' tcx > )
2251
+ -> Option < Ty < ' tcx > >
2252
+ {
2253
+ let o_field = items. iter ( ) . find ( |f| f. name == fieldname) ;
2254
+ o_field. map ( |f| ty:: lookup_field_type ( self . tcx ( ) , class_id, f. id , substs) )
2255
+ . map ( |t| self . normalize_associated_types_in ( span, & t) )
2256
+ }
2257
+
2258
+ pub fn lookup_tup_field_ty ( & self ,
2259
+ span : Span ,
2260
+ class_id : ast:: DefId ,
2261
+ items : & [ ty:: field_ty ] ,
2262
+ idx : uint ,
2263
+ substs : & subst:: Substs < ' tcx > )
2264
+ -> Option < Ty < ' tcx > >
2265
+ {
2266
+ let o_field = if idx < items. len ( ) { Some ( & items[ idx] ) } else { None } ;
2267
+ o_field. map ( |f| ty:: lookup_field_type ( self . tcx ( ) , class_id, f. id , substs) )
2268
+ . map ( |t| self . normalize_associated_types_in ( span, & t) )
2269
+ }
2242
2270
}
2243
2271
2244
2272
impl < ' a , ' tcx > RegionScope for FnCtxt < ' a , ' tcx > {
@@ -2953,30 +2981,6 @@ pub fn impl_self_ty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
2953
2981
TypeAndSubsts { substs : substs, ty : substd_ty }
2954
2982
}
2955
2983
2956
- // Only for fields! Returns <none> for methods>
2957
- // Indifferent to privacy flags
2958
- pub fn lookup_field_ty < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
2959
- class_id : ast:: DefId ,
2960
- items : & [ ty:: field_ty ] ,
2961
- fieldname : ast:: Name ,
2962
- substs : & subst:: Substs < ' tcx > )
2963
- -> Option < Ty < ' tcx > > {
2964
-
2965
- let o_field = items. iter ( ) . find ( |f| f. name == fieldname) ;
2966
- o_field. map ( |f| ty:: lookup_field_type ( tcx, class_id, f. id , substs) )
2967
- }
2968
-
2969
- pub fn lookup_tup_field_ty < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
2970
- class_id : ast:: DefId ,
2971
- items : & [ ty:: field_ty ] ,
2972
- idx : uint ,
2973
- substs : & subst:: Substs < ' tcx > )
2974
- -> Option < Ty < ' tcx > > {
2975
-
2976
- let o_field = if idx < items. len ( ) { Some ( & items[ idx] ) } else { None } ;
2977
- o_field. map ( |f| ty:: lookup_field_type ( tcx, class_id, f. id , substs) )
2978
- }
2979
-
2980
2984
// Controls whether the arguments are automatically referenced. This is useful
2981
2985
// for overloaded binary and unary operators.
2982
2986
#[ derive( Copy , PartialEq ) ]
@@ -3398,8 +3402,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3398
3402
ty:: ty_struct( base_id, substs) => {
3399
3403
debug ! ( "struct named {}" , ppaux:: ty_to_string( tcx, base_t) ) ;
3400
3404
let fields = ty:: lookup_struct_fields ( tcx, base_id) ;
3401
- lookup_field_ty ( tcx , base_id, & fields[ ] ,
3402
- field. node . name , & ( * substs) )
3405
+ fcx . lookup_field_ty ( expr . span , base_id, & fields[ ] ,
3406
+ field. node . name , & ( * substs) )
3403
3407
}
3404
3408
_ => None
3405
3409
}
@@ -3461,8 +3465,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3461
3465
if tuple_like {
3462
3466
debug ! ( "tuple struct named {}" , ppaux:: ty_to_string( tcx, base_t) ) ;
3463
3467
let fields = ty:: lookup_struct_fields ( tcx, base_id) ;
3464
- lookup_tup_field_ty ( tcx , base_id, & fields[ ] ,
3465
- idx. node , & ( * substs) )
3468
+ fcx . lookup_tup_field_ty ( expr . span , base_id, & fields[ ] ,
3469
+ idx. node , & ( * substs) )
3466
3470
} else {
3467
3471
None
3468
3472
}
0 commit comments