@@ -168,7 +168,7 @@ fn create_steps<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
168168 check:: autoderef (
169169 fcx, span, self_ty, None , NoPreference ,
170170 |t, d| {
171- let adjustment = consider_reborrow ( t , d) ;
171+ let adjustment = AutoDeref ( d) ;
172172 steps. push ( CandidateStep { self_ty : t, adjustment : adjustment } ) ;
173173 None :: < ( ) > // keep iterating until we can't anymore
174174 } ) ;
@@ -185,14 +185,6 @@ fn create_steps<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
185185 }
186186
187187 return steps;
188-
189- fn consider_reborrow ( ty : Ty , d : uint ) -> PickAdjustment {
190- // Insert a `&*` or `&mut *` if this is a reference type:
191- match ty. sty {
192- ty:: ty_rptr( _, ref mt) => AutoRef ( mt. mutbl , box AutoDeref ( d+1 ) ) ,
193- _ => AutoDeref ( d) ,
194- }
195- }
196188}
197189
198190impl < ' a , ' tcx > ProbeContext < ' a , ' tcx > {
@@ -626,7 +618,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
626618 return None ;
627619 }
628620
629- match self . pick_adjusted_method ( step) {
621+ match self . pick_by_value_method ( step) {
630622 Some ( result) => return Some ( result) ,
631623 None => { }
632624 }
@@ -644,11 +636,34 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
644636 }
645637 }
646638
647- fn pick_adjusted_method ( & mut self ,
639+ fn pick_by_value_method ( & mut self ,
648640 step : & CandidateStep < ' tcx > )
649641 -> Option < PickResult < ' tcx > >
650642 {
651- self . pick_method ( step. self_ty ) . map ( |r| self . adjust ( r, step. adjustment . clone ( ) ) )
643+ /*!
644+ * For each type `T` in the step list, this attempts to find a
645+ * method where the (transformed) self type is exactly `T`. We
646+ * do however do one transformation on the adjustment: if we
647+ * are passing a region pointer in, we will potentially
648+ * *reborrow* it to a shorter lifetime. This allows us to
649+ * transparently pass `&mut` pointers, in particular, without
650+ * consuming them for their entire lifetime.
651+ */
652+
653+ let adjustment = match step. adjustment {
654+ AutoDeref ( d) => consider_reborrow ( step. self_ty , d) ,
655+ AutoUnsizeLength ( ..) | AutoRef ( ..) => step. adjustment . clone ( ) ,
656+ } ;
657+
658+ return self . pick_method ( step. self_ty ) . map ( |r| self . adjust ( r, adjustment. clone ( ) ) ) ;
659+
660+ fn consider_reborrow ( ty : Ty , d : uint ) -> PickAdjustment {
661+ // Insert a `&*` or `&mut *` if this is a reference type:
662+ match ty. sty {
663+ ty:: ty_rptr( _, ref mt) => AutoRef ( mt. mutbl , box AutoDeref ( d+1 ) ) ,
664+ _ => AutoDeref ( d) ,
665+ }
666+ }
652667 }
653668
654669 fn pick_autorefd_method ( & mut self ,
0 commit comments