]> git.lizzy.rs Git - rust.git/blob - src/librustc_typeck/check/upvar.rs
Rollup merge of #42330 - qnighy:macro-named-default, r=petrochenkov
[rust.git] / src / librustc_typeck / check / upvar.rs
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! ### Inferring borrow kinds for upvars
12 //!
13 //! Whenever there is a closure expression, we need to determine how each
14 //! upvar is used. We do this by initially assigning each upvar an
15 //! immutable "borrow kind" (see `ty::BorrowKind` for details) and then
16 //! "escalating" the kind as needed. The borrow kind proceeds according to
17 //! the following lattice:
18 //!
19 //!     ty::ImmBorrow -> ty::UniqueImmBorrow -> ty::MutBorrow
20 //!
21 //! So, for example, if we see an assignment `x = 5` to an upvar `x`, we
22 //! will promote its borrow kind to mutable borrow. If we see an `&mut x`
23 //! we'll do the same. Naturally, this applies not just to the upvar, but
24 //! to everything owned by `x`, so the result is the same for something
25 //! like `x.f = 5` and so on (presuming `x` is not a borrowed pointer to a
26 //! struct). These adjustments are performed in
27 //! `adjust_upvar_borrow_kind()` (you can trace backwards through the code
28 //! from there).
29 //!
30 //! The fact that we are inferring borrow kinds as we go results in a
31 //! semi-hacky interaction with mem-categorization. In particular,
32 //! mem-categorization will query the current borrow kind as it
33 //! categorizes, and we'll return the *current* value, but this may get
34 //! adjusted later. Therefore, in this module, we generally ignore the
35 //! borrow kind (and derived mutabilities) that are returned from
36 //! mem-categorization, since they may be inaccurate. (Another option
37 //! would be to use a unification scheme, where instead of returning a
38 //! concrete borrow kind like `ty::ImmBorrow`, we return a
39 //! `ty::InferBorrow(upvar_id)` or something like that, but this would
40 //! then mean that all later passes would have to check for these figments
41 //! and report an error, and it just seems like more mess in the end.)
42
43 use super::FnCtxt;
44
45 use middle::expr_use_visitor as euv;
46 use middle::mem_categorization as mc;
47 use middle::mem_categorization::Categorization;
48 use rustc::ty::{self, Ty};
49 use rustc::infer::UpvarRegion;
50 use syntax::ast;
51 use syntax_pos::Span;
52 use rustc::hir;
53 use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
54 use rustc::util::nodemap::NodeMap;
55
56 ///////////////////////////////////////////////////////////////////////////
57 // PUBLIC ENTRY POINTS
58
59 impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
60     pub fn closure_analyze(&self, body: &'gcx hir::Body) {
61         let mut seed = SeedBorrowKind::new(self);
62         seed.visit_body(body);
63
64         let mut adjust = AdjustBorrowKind::new(self, seed.temp_closure_kinds);
65         adjust.visit_body(body);
66
67         // it's our job to process these.
68         assert!(self.deferred_call_resolutions.borrow().is_empty());
69     }
70 }
71
72 ///////////////////////////////////////////////////////////////////////////
73 // SEED BORROW KIND
74
75 struct SeedBorrowKind<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
76     fcx: &'a FnCtxt<'a, 'gcx, 'tcx>,
77     temp_closure_kinds: NodeMap<(ty::ClosureKind, Option<(Span, ast::Name)>)>,
78 }
79
80 impl<'a, 'gcx, 'tcx> Visitor<'gcx> for SeedBorrowKind<'a, 'gcx, 'tcx> {
81     fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
82         NestedVisitorMap::None
83     }
84
85     fn visit_expr(&mut self, expr: &'gcx hir::Expr) {
86         match expr.node {
87             hir::ExprClosure(cc, _, body_id, _) => {
88                 let body = self.fcx.tcx.hir.body(body_id);
89                 self.visit_body(body);
90                 self.check_closure(expr, cc);
91             }
92
93             _ => { }
94         }
95
96         intravisit::walk_expr(self, expr);
97     }
98 }
99
100 impl<'a, 'gcx, 'tcx> SeedBorrowKind<'a, 'gcx, 'tcx> {
101     fn new(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>) -> SeedBorrowKind<'a, 'gcx, 'tcx> {
102         SeedBorrowKind { fcx: fcx, temp_closure_kinds: NodeMap() }
103     }
104
105     fn check_closure(&mut self,
106                      expr: &hir::Expr,
107                      capture_clause: hir::CaptureClause)
108     {
109         if !self.fcx.tables.borrow().closure_kinds.contains_key(&expr.id) {
110             self.temp_closure_kinds.insert(expr.id, (ty::ClosureKind::Fn, None));
111             debug!("check_closure: adding closure {:?} as Fn", expr.id);
112         }
113
114         self.fcx.tcx.with_freevars(expr.id, |freevars| {
115             for freevar in freevars {
116                 let def_id = freevar.def.def_id();
117                 let var_node_id = self.fcx.tcx.hir.as_local_node_id(def_id).unwrap();
118                 let upvar_id = ty::UpvarId { var_id: var_node_id,
119                                              closure_expr_id: expr.id };
120                 debug!("seed upvar_id {:?}", upvar_id);
121
122                 let capture_kind = match capture_clause {
123                     hir::CaptureByValue => {
124                         ty::UpvarCapture::ByValue
125                     }
126                     hir::CaptureByRef => {
127                         let origin = UpvarRegion(upvar_id, expr.span);
128                         let freevar_region = self.fcx.next_region_var(origin);
129                         let upvar_borrow = ty::UpvarBorrow { kind: ty::ImmBorrow,
130                                                              region: freevar_region };
131                         ty::UpvarCapture::ByRef(upvar_borrow)
132                     }
133                 };
134
135                 self.fcx.tables.borrow_mut().upvar_capture_map.insert(upvar_id, capture_kind);
136             }
137         });
138     }
139 }
140
141 ///////////////////////////////////////////////////////////////////////////
142 // ADJUST BORROW KIND
143
144 struct AdjustBorrowKind<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
145     fcx: &'a FnCtxt<'a, 'gcx, 'tcx>,
146     temp_closure_kinds: NodeMap<(ty::ClosureKind, Option<(Span, ast::Name)>)>,
147 }
148
149 impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
150     fn new(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>,
151            temp_closure_kinds: NodeMap<(ty::ClosureKind, Option<(Span, ast::Name)>)>)
152            -> AdjustBorrowKind<'a, 'gcx, 'tcx> {
153         AdjustBorrowKind { fcx: fcx, temp_closure_kinds: temp_closure_kinds }
154     }
155
156     fn analyze_closure(&mut self,
157                        id: ast::NodeId,
158                        span: Span,
159                        body: &hir::Body) {
160         /*!
161          * Analysis starting point.
162          */
163
164         debug!("analyze_closure(id={:?}, body.id={:?})", id, body.id());
165
166         {
167             let body_owner_def_id = self.fcx.tcx.hir.body_owner_def_id(body.id());
168             let region_maps = &self.fcx.tcx.region_maps(body_owner_def_id);
169             let mut euv =
170                 euv::ExprUseVisitor::with_options(self,
171                                                   self.fcx,
172                                                   region_maps,
173                                                   mc::MemCategorizationOptions {
174                                                       during_closure_kind_inference: true
175                                                   });
176             euv.consume_body(body);
177         }
178
179         // Now that we've analyzed the closure, we know how each
180         // variable is borrowed, and we know what traits the closure
181         // implements (Fn vs FnMut etc). We now have some updates to do
182         // with that information.
183         //
184         // Note that no closure type C may have an upvar of type C
185         // (though it may reference itself via a trait object). This
186         // results from the desugaring of closures to a struct like
187         // `Foo<..., UV0...UVn>`. If one of those upvars referenced
188         // C, then the type would have infinite size (and the
189         // inference algorithm will reject it).
190
191         // Extract the type variables UV0...UVn.
192         let (def_id, closure_substs) = match self.fcx.node_ty(id).sty {
193             ty::TyClosure(def_id, substs) => (def_id, substs),
194             ref t => {
195                 span_bug!(
196                     span,
197                     "type of closure expr {:?} is not a closure {:?}",
198                     id, t);
199             }
200         };
201
202         // Equate the type variables with the actual types.
203         let final_upvar_tys = self.final_upvar_tys(id);
204         debug!("analyze_closure: id={:?} closure_substs={:?} final_upvar_tys={:?}",
205                id, closure_substs, final_upvar_tys);
206         for (upvar_ty, final_upvar_ty) in
207             closure_substs.upvar_tys(def_id, self.fcx.tcx).zip(final_upvar_tys)
208         {
209             self.fcx.demand_eqtype(span, final_upvar_ty, upvar_ty);
210         }
211
212         // If we are also inferred the closure kind here, update the
213         // main table and process any deferred resolutions.
214         if let Some(&(kind, context)) = self.temp_closure_kinds.get(&id) {
215             self.fcx.tables.borrow_mut().closure_kinds.insert(id, (kind, context));
216             let closure_def_id = self.fcx.tcx.hir.local_def_id(id);
217             debug!("closure_kind({:?}) = {:?}", closure_def_id, kind);
218
219             let mut deferred_call_resolutions =
220                 self.fcx.remove_deferred_call_resolutions(closure_def_id);
221             for deferred_call_resolution in &mut deferred_call_resolutions {
222                 deferred_call_resolution.resolve(self.fcx);
223             }
224         }
225     }
226
227     // Returns a list of `ClosureUpvar`s for each upvar.
228     fn final_upvar_tys(&mut self, closure_id: ast::NodeId) -> Vec<Ty<'tcx>> {
229         // Presently an unboxed closure type cannot "escape" out of a
230         // function, so we will only encounter ones that originated in the
231         // local crate or were inlined into it along with some function.
232         // This may change if abstract return types of some sort are
233         // implemented.
234         let tcx = self.fcx.tcx;
235         tcx.with_freevars(closure_id, |freevars| {
236             freevars.iter().map(|freevar| {
237                 let def_id = freevar.def.def_id();
238                 let var_id = tcx.hir.as_local_node_id(def_id).unwrap();
239                 let freevar_ty = self.fcx.node_ty(var_id);
240                 let upvar_id = ty::UpvarId {
241                     var_id: var_id,
242                     closure_expr_id: closure_id
243                 };
244                 let capture = self.fcx.upvar_capture(upvar_id).unwrap();
245
246                 debug!("var_id={:?} freevar_ty={:?} capture={:?}",
247                        var_id, freevar_ty, capture);
248
249                 match capture {
250                     ty::UpvarCapture::ByValue => freevar_ty,
251                     ty::UpvarCapture::ByRef(borrow) =>
252                         tcx.mk_ref(borrow.region,
253                                     ty::TypeAndMut {
254                                         ty: freevar_ty,
255                                         mutbl: borrow.kind.to_mutbl_lossy(),
256                                     }),
257                 }
258             }).collect()
259         })
260     }
261
262     fn adjust_upvar_borrow_kind_for_consume(&mut self,
263                                             cmt: mc::cmt<'tcx>,
264                                             mode: euv::ConsumeMode)
265     {
266         debug!("adjust_upvar_borrow_kind_for_consume(cmt={:?}, mode={:?})",
267                cmt, mode);
268
269         // we only care about moves
270         match mode {
271             euv::Copy => { return; }
272             euv::Move(_) => { }
273         }
274
275         let tcx = self.fcx.tcx;
276
277         // watch out for a move of the deref of a borrowed pointer;
278         // for that to be legal, the upvar would have to be borrowed
279         // by value instead
280         let guarantor = cmt.guarantor();
281         debug!("adjust_upvar_borrow_kind_for_consume: guarantor={:?}",
282                guarantor);
283         match guarantor.cat {
284             Categorization::Deref(.., mc::BorrowedPtr(..)) |
285             Categorization::Deref(.., mc::Implicit(..)) => {
286                 match cmt.note {
287                     mc::NoteUpvarRef(upvar_id) => {
288                         debug!("adjust_upvar_borrow_kind_for_consume: \
289                                 setting upvar_id={:?} to by value",
290                                upvar_id);
291
292                         // to move out of an upvar, this must be a FnOnce closure
293                         self.adjust_closure_kind(upvar_id.closure_expr_id,
294                                                  ty::ClosureKind::FnOnce,
295                                                  guarantor.span,
296                                                  tcx.hir.name(upvar_id.var_id));
297
298                         let upvar_capture_map =
299                             &mut self.fcx.tables.borrow_mut().upvar_capture_map;
300                         upvar_capture_map.insert(upvar_id, ty::UpvarCapture::ByValue);
301                     }
302                     mc::NoteClosureEnv(upvar_id) => {
303                         // we get just a closureenv ref if this is a
304                         // `move` closure, or if the upvar has already
305                         // been inferred to by-value. In any case, we
306                         // must still adjust the kind of the closure
307                         // to be a FnOnce closure to permit moves out
308                         // of the environment.
309                         self.adjust_closure_kind(upvar_id.closure_expr_id,
310                                                  ty::ClosureKind::FnOnce,
311                                                  guarantor.span,
312                                                  tcx.hir.name(upvar_id.var_id));
313                     }
314                     mc::NoteNone => {
315                     }
316                 }
317             }
318             _ => { }
319         }
320     }
321
322     /// Indicates that `cmt` is being directly mutated (e.g., assigned
323     /// to). If cmt contains any by-ref upvars, this implies that
324     /// those upvars must be borrowed using an `&mut` borrow.
325     fn adjust_upvar_borrow_kind_for_mut(&mut self, cmt: mc::cmt<'tcx>) {
326         debug!("adjust_upvar_borrow_kind_for_mut(cmt={:?})",
327                cmt);
328
329         match cmt.cat.clone() {
330             Categorization::Deref(base, _, mc::Unique) |
331             Categorization::Interior(base, _) |
332             Categorization::Downcast(base, _) => {
333                 // Interior or owned data is mutable if base is
334                 // mutable, so iterate to the base.
335                 self.adjust_upvar_borrow_kind_for_mut(base);
336             }
337
338             Categorization::Deref(base, _, mc::BorrowedPtr(..)) |
339             Categorization::Deref(base, _, mc::Implicit(..)) => {
340                 if !self.try_adjust_upvar_deref(cmt, ty::MutBorrow) {
341                     // assignment to deref of an `&mut`
342                     // borrowed pointer implies that the
343                     // pointer itself must be unique, but not
344                     // necessarily *mutable*
345                     self.adjust_upvar_borrow_kind_for_unique(base);
346                 }
347             }
348
349             Categorization::Deref(.., mc::UnsafePtr(..)) |
350             Categorization::StaticItem |
351             Categorization::Rvalue(..) |
352             Categorization::Local(_) |
353             Categorization::Upvar(..) => {
354                 return;
355             }
356         }
357     }
358
359     fn adjust_upvar_borrow_kind_for_unique(&mut self, cmt: mc::cmt<'tcx>) {
360         debug!("adjust_upvar_borrow_kind_for_unique(cmt={:?})",
361                cmt);
362
363         match cmt.cat.clone() {
364             Categorization::Deref(base, _, mc::Unique) |
365             Categorization::Interior(base, _) |
366             Categorization::Downcast(base, _) => {
367                 // Interior or owned data is unique if base is
368                 // unique.
369                 self.adjust_upvar_borrow_kind_for_unique(base);
370             }
371
372             Categorization::Deref(base, _, mc::BorrowedPtr(..)) |
373             Categorization::Deref(base, _, mc::Implicit(..)) => {
374                 if !self.try_adjust_upvar_deref(cmt, ty::UniqueImmBorrow) {
375                     // for a borrowed pointer to be unique, its
376                     // base must be unique
377                     self.adjust_upvar_borrow_kind_for_unique(base);
378                 }
379             }
380
381             Categorization::Deref(.., mc::UnsafePtr(..)) |
382             Categorization::StaticItem |
383             Categorization::Rvalue(..) |
384             Categorization::Local(_) |
385             Categorization::Upvar(..) => {
386             }
387         }
388     }
389
390     fn try_adjust_upvar_deref(&mut self,
391                               cmt: mc::cmt<'tcx>,
392                               borrow_kind: ty::BorrowKind)
393                               -> bool
394     {
395         assert!(match borrow_kind {
396             ty::MutBorrow => true,
397             ty::UniqueImmBorrow => true,
398
399             // imm borrows never require adjusting any kinds, so we don't wind up here
400             ty::ImmBorrow => false,
401         });
402
403         let tcx = self.fcx.tcx;
404
405         match cmt.note {
406             mc::NoteUpvarRef(upvar_id) => {
407                 // if this is an implicit deref of an
408                 // upvar, then we need to modify the
409                 // borrow_kind of the upvar to make sure it
410                 // is inferred to mutable if necessary
411                 {
412                     let upvar_capture_map = &mut self.fcx.tables.borrow_mut().upvar_capture_map;
413                     let ub = upvar_capture_map.get_mut(&upvar_id).unwrap();
414                     self.adjust_upvar_borrow_kind(upvar_id, ub, borrow_kind);
415                 }
416
417                 // also need to be in an FnMut closure since this is not an ImmBorrow
418                 self.adjust_closure_kind(upvar_id.closure_expr_id,
419                                          ty::ClosureKind::FnMut,
420                                          cmt.span,
421                                          tcx.hir.name(upvar_id.var_id));
422
423                 true
424             }
425             mc::NoteClosureEnv(upvar_id) => {
426                 // this kind of deref occurs in a `move` closure, or
427                 // for a by-value upvar; in either case, to mutate an
428                 // upvar, we need to be an FnMut closure
429                 self.adjust_closure_kind(upvar_id.closure_expr_id,
430                                          ty::ClosureKind::FnMut,
431                                          cmt.span,
432                                          tcx.hir.name(upvar_id.var_id));
433
434                 true
435             }
436             mc::NoteNone => {
437                 false
438             }
439         }
440     }
441
442     /// We infer the borrow_kind with which to borrow upvars in a stack closure.
443     /// The borrow_kind basically follows a lattice of `imm < unique-imm < mut`,
444     /// moving from left to right as needed (but never right to left).
445     /// Here the argument `mutbl` is the borrow_kind that is required by
446     /// some particular use.
447     fn adjust_upvar_borrow_kind(&mut self,
448                                 upvar_id: ty::UpvarId,
449                                 upvar_capture: &mut ty::UpvarCapture,
450                                 kind: ty::BorrowKind) {
451         debug!("adjust_upvar_borrow_kind(upvar_id={:?}, upvar_capture={:?}, kind={:?})",
452                upvar_id, upvar_capture, kind);
453
454         match *upvar_capture {
455             ty::UpvarCapture::ByValue => {
456                 // Upvar is already by-value, the strongest criteria.
457             }
458             ty::UpvarCapture::ByRef(ref mut upvar_borrow) => {
459                 match (upvar_borrow.kind, kind) {
460                     // Take RHS:
461                     (ty::ImmBorrow, ty::UniqueImmBorrow) |
462                     (ty::ImmBorrow, ty::MutBorrow) |
463                     (ty::UniqueImmBorrow, ty::MutBorrow) => {
464                         upvar_borrow.kind = kind;
465                     }
466                     // Take LHS:
467                     (ty::ImmBorrow, ty::ImmBorrow) |
468                     (ty::UniqueImmBorrow, ty::ImmBorrow) |
469                     (ty::UniqueImmBorrow, ty::UniqueImmBorrow) |
470                     (ty::MutBorrow, _) => {
471                     }
472                 }
473             }
474         }
475     }
476
477     fn adjust_closure_kind(&mut self,
478                            closure_id: ast::NodeId,
479                            new_kind: ty::ClosureKind,
480                            upvar_span: Span,
481                            var_name: ast::Name) {
482         debug!("adjust_closure_kind(closure_id={}, new_kind={:?}, upvar_span={:?}, var_name={})",
483                closure_id, new_kind, upvar_span, var_name);
484
485         if let Some(&(existing_kind, _)) = self.temp_closure_kinds.get(&closure_id) {
486             debug!("adjust_closure_kind: closure_id={}, existing_kind={:?}, new_kind={:?}",
487                    closure_id, existing_kind, new_kind);
488
489             match (existing_kind, new_kind) {
490                 (ty::ClosureKind::Fn, ty::ClosureKind::Fn) |
491                 (ty::ClosureKind::FnMut, ty::ClosureKind::Fn) |
492                 (ty::ClosureKind::FnMut, ty::ClosureKind::FnMut) |
493                 (ty::ClosureKind::FnOnce, _) => {
494                     // no change needed
495                 }
496
497                 (ty::ClosureKind::Fn, ty::ClosureKind::FnMut) |
498                 (ty::ClosureKind::Fn, ty::ClosureKind::FnOnce) |
499                 (ty::ClosureKind::FnMut, ty::ClosureKind::FnOnce) => {
500                     // new kind is stronger than the old kind
501                     self.temp_closure_kinds.insert(
502                         closure_id,
503                         (new_kind, Some((upvar_span, var_name)))
504                     );
505                 }
506             }
507         }
508     }
509 }
510
511 impl<'a, 'gcx, 'tcx> Visitor<'gcx> for AdjustBorrowKind<'a, 'gcx, 'tcx> {
512     fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
513         NestedVisitorMap::None
514     }
515
516     fn visit_fn(&mut self,
517                 fn_kind: intravisit::FnKind<'gcx>,
518                 decl: &'gcx hir::FnDecl,
519                 body: hir::BodyId,
520                 span: Span,
521                 id: ast::NodeId)
522     {
523         intravisit::walk_fn(self, fn_kind, decl, body, span, id);
524
525         let body = self.fcx.tcx.hir.body(body);
526         self.visit_body(body);
527         self.analyze_closure(id, span, body);
528     }
529 }
530
531 impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a, 'gcx, 'tcx> {
532     fn consume(&mut self,
533                _consume_id: ast::NodeId,
534                _consume_span: Span,
535                cmt: mc::cmt<'tcx>,
536                mode: euv::ConsumeMode)
537     {
538         debug!("consume(cmt={:?},mode={:?})", cmt, mode);
539         self.adjust_upvar_borrow_kind_for_consume(cmt, mode);
540     }
541
542     fn matched_pat(&mut self,
543                    _matched_pat: &hir::Pat,
544                    _cmt: mc::cmt<'tcx>,
545                    _mode: euv::MatchMode)
546     {}
547
548     fn consume_pat(&mut self,
549                    _consume_pat: &hir::Pat,
550                    cmt: mc::cmt<'tcx>,
551                    mode: euv::ConsumeMode)
552     {
553         debug!("consume_pat(cmt={:?},mode={:?})", cmt, mode);
554         self.adjust_upvar_borrow_kind_for_consume(cmt, mode);
555     }
556
557     fn borrow(&mut self,
558               borrow_id: ast::NodeId,
559               _borrow_span: Span,
560               cmt: mc::cmt<'tcx>,
561               _loan_region: ty::Region<'tcx>,
562               bk: ty::BorrowKind,
563               _loan_cause: euv::LoanCause)
564     {
565         debug!("borrow(borrow_id={}, cmt={:?}, bk={:?})",
566                borrow_id, cmt, bk);
567
568         match bk {
569             ty::ImmBorrow => { }
570             ty::UniqueImmBorrow => {
571                 self.adjust_upvar_borrow_kind_for_unique(cmt);
572             }
573             ty::MutBorrow => {
574                 self.adjust_upvar_borrow_kind_for_mut(cmt);
575             }
576         }
577     }
578
579     fn decl_without_init(&mut self,
580                          _id: ast::NodeId,
581                          _span: Span)
582     {}
583
584     fn mutate(&mut self,
585               _assignment_id: ast::NodeId,
586               _assignment_span: Span,
587               assignee_cmt: mc::cmt<'tcx>,
588               _mode: euv::MutateMode)
589     {
590         debug!("mutate(assignee_cmt={:?})",
591                assignee_cmt);
592
593         self.adjust_upvar_borrow_kind_for_mut(assignee_cmt);
594     }
595 }