@@ -2289,6 +2289,34 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2289
2289
2290
2290
obligations. map_move ( |o| self . register_predicate ( o) ) ;
2291
2291
}
2292
+
2293
+ // Only for fields! Returns <none> for methods>
2294
+ // Indifferent to privacy flags
2295
+ pub fn lookup_field_ty ( & self ,
2296
+ span : Span ,
2297
+ class_id : ast:: DefId ,
2298
+ items : & [ ty:: field_ty ] ,
2299
+ fieldname : ast:: Name ,
2300
+ substs : & subst:: Substs < ' tcx > )
2301
+ -> Option < Ty < ' tcx > >
2302
+ {
2303
+ let o_field = items. iter ( ) . find ( |f| f. name == fieldname) ;
2304
+ o_field. map ( |f| ty:: lookup_field_type ( self . tcx ( ) , class_id, f. id , substs) )
2305
+ . map ( |t| self . normalize_associated_types_in ( span, & t) )
2306
+ }
2307
+
2308
+ pub fn lookup_tup_field_ty ( & self ,
2309
+ span : Span ,
2310
+ class_id : ast:: DefId ,
2311
+ items : & [ ty:: field_ty ] ,
2312
+ idx : uint ,
2313
+ substs : & subst:: Substs < ' tcx > )
2314
+ -> Option < Ty < ' tcx > >
2315
+ {
2316
+ let o_field = if idx < items. len ( ) { Some ( & items[ idx] ) } else { None } ;
2317
+ o_field. map ( |f| ty:: lookup_field_type ( self . tcx ( ) , class_id, f. id , substs) )
2318
+ . map ( |t| self . normalize_associated_types_in ( span, & t) )
2319
+ }
2292
2320
}
2293
2321
2294
2322
impl < ' a , ' tcx > RegionScope for FnCtxt < ' a , ' tcx > {
@@ -3043,30 +3071,6 @@ pub fn impl_self_ty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
3043
3071
TypeAndSubsts { substs : substs, ty : substd_ty }
3044
3072
}
3045
3073
3046
- // Only for fields! Returns <none> for methods>
3047
- // Indifferent to privacy flags
3048
- pub fn lookup_field_ty < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
3049
- class_id : ast:: DefId ,
3050
- items : & [ ty:: field_ty ] ,
3051
- fieldname : ast:: Name ,
3052
- substs : & subst:: Substs < ' tcx > )
3053
- -> Option < Ty < ' tcx > > {
3054
-
3055
- let o_field = items. iter ( ) . find ( |f| f. name == fieldname) ;
3056
- o_field. map ( |f| ty:: lookup_field_type ( tcx, class_id, f. id , substs) )
3057
- }
3058
-
3059
- pub fn lookup_tup_field_ty < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
3060
- class_id : ast:: DefId ,
3061
- items : & [ ty:: field_ty ] ,
3062
- idx : uint ,
3063
- substs : & subst:: Substs < ' tcx > )
3064
- -> Option < Ty < ' tcx > > {
3065
-
3066
- let o_field = if idx < items. len ( ) { Some ( & items[ idx] ) } else { None } ;
3067
- o_field. map ( |f| ty:: lookup_field_type ( tcx, class_id, f. id , substs) )
3068
- }
3069
-
3070
3074
// Controls whether the arguments are automatically referenced. This is useful
3071
3075
// for overloaded binary and unary operators.
3072
3076
#[ derive( Copy , PartialEq ) ]
@@ -3530,8 +3534,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3530
3534
ty:: ty_struct( base_id, substs) => {
3531
3535
debug ! ( "struct named {}" , ppaux:: ty_to_string( tcx, base_t) ) ;
3532
3536
let fields = ty:: lookup_struct_fields ( tcx, base_id) ;
3533
- lookup_field_ty ( tcx , base_id, & fields[ ] ,
3534
- field. node . name , & ( * substs) )
3537
+ fcx . lookup_field_ty ( expr . span , base_id, & fields[ ] ,
3538
+ field. node . name , & ( * substs) )
3535
3539
}
3536
3540
_ => None
3537
3541
}
@@ -3593,8 +3597,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3593
3597
if tuple_like {
3594
3598
debug ! ( "tuple struct named {}" , ppaux:: ty_to_string( tcx, base_t) ) ;
3595
3599
let fields = ty:: lookup_struct_fields ( tcx, base_id) ;
3596
- lookup_tup_field_ty ( tcx , base_id, & fields[ ] ,
3597
- idx. node , & ( * substs) )
3600
+ fcx . lookup_tup_field_ty ( expr . span , base_id, & fields[ ] ,
3601
+ idx. node , & ( * substs) )
3598
3602
} else {
3599
3603
None
3600
3604
}
0 commit comments