@@ -19,7 +19,7 @@ use rustc::ty::{ToPredicate, TypeFoldable};
19
19
use rustc:: ty:: adjustment:: { Adjustment , Adjust , OverloadedDeref } ;
20
20
21
21
use syntax_pos:: Span ;
22
- use syntax:: ast:: { NodeId , Ident } ;
22
+ use syntax:: ast:: { self , Ident } ;
23
23
24
24
use std:: iter;
25
25
@@ -31,7 +31,7 @@ enum AutoderefKind {
31
31
32
32
pub struct Autoderef < ' a , ' gcx : ' tcx , ' tcx : ' a > {
33
33
infcx : & ' a InferCtxt < ' a , ' gcx , ' tcx > ,
34
- body_id : NodeId ,
34
+ body_id : ast :: NodeId ,
35
35
param_env : ty:: ParamEnv < ' tcx > ,
36
36
steps : Vec < ( Ty < ' tcx > , AutoderefKind ) > ,
37
37
cur_ty : Ty < ' tcx > ,
@@ -107,6 +107,26 @@ impl<'a, 'gcx, 'tcx> Iterator for Autoderef<'a, 'gcx, 'tcx> {
107
107
}
108
108
109
109
impl < ' a , ' gcx , ' tcx > Autoderef < ' a , ' gcx , ' tcx > {
110
+ pub fn new ( infcx : & ' a InferCtxt < ' a , ' gcx , ' tcx > ,
111
+ param_env : ty:: ParamEnv < ' tcx > ,
112
+ body_id : ast:: NodeId ,
113
+ span : Span ,
114
+ base_ty : Ty < ' tcx > )
115
+ -> Autoderef < ' a , ' gcx , ' tcx >
116
+ {
117
+ Autoderef {
118
+ infcx,
119
+ body_id,
120
+ param_env,
121
+ steps : vec ! [ ] ,
122
+ cur_ty : infcx. resolve_type_vars_if_possible ( & base_ty) ,
123
+ obligations : vec ! [ ] ,
124
+ at_start : true ,
125
+ include_raw_pointers : false ,
126
+ span,
127
+ }
128
+ }
129
+
110
130
fn overloaded_deref_ty ( & mut self , ty : Ty < ' tcx > ) -> Option < Ty < ' tcx > > {
111
131
debug ! ( "overloaded_deref_ty({:?})" , ty) ;
112
132
@@ -231,17 +251,7 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
231
251
232
252
impl < ' a , ' gcx , ' tcx > FnCtxt < ' a , ' gcx , ' tcx > {
233
253
pub fn autoderef ( & ' a self , span : Span , base_ty : Ty < ' tcx > ) -> Autoderef < ' a , ' gcx , ' tcx > {
234
- Autoderef {
235
- infcx : & self . infcx ,
236
- body_id : self . body_id ,
237
- param_env : self . param_env ,
238
- steps : vec ! [ ] ,
239
- cur_ty : self . resolve_type_vars_if_possible ( & base_ty) ,
240
- obligations : vec ! [ ] ,
241
- at_start : true ,
242
- include_raw_pointers : false ,
243
- span,
244
- }
254
+ Autoderef :: new ( self , self . param_env , self . body_id , span, base_ty)
245
255
}
246
256
247
257
pub fn try_overloaded_deref ( & self ,
0 commit comments