]> git.lizzy.rs Git - rust.git/blob - src/librustc_passes/rvalue_promotion.rs
Auto merge of #52046 - cramertj:fix-generator-mir, r=eddyb
[rust.git] / src / librustc_passes / rvalue_promotion.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 // Verifies that the types and values of const and static items
12 // are safe. The rules enforced by this module are:
13 //
14 // - For each *mutable* static item, it checks that its **type**:
15 //     - doesn't have a destructor
16 //     - doesn't own a box
17 //
18 // - For each *immutable* static item, it checks that its **value**:
19 //       - doesn't own a box
20 //       - doesn't contain a struct literal or a call to an enum variant / struct constructor where
21 //           - the type of the struct/enum has a dtor
22 //
23 // Rules Enforced Elsewhere:
24 // - It's not possible to take the address of a static item with unsafe interior. This is enforced
25 // by borrowck::gather_loans
26
27 use rustc::ty::cast::CastKind;
28 use rustc::hir::def::{Def, CtorKind};
29 use rustc::hir::def_id::DefId;
30 use rustc::hir::map::blocks::FnLikeNode;
31 use rustc::middle::expr_use_visitor as euv;
32 use rustc::middle::mem_categorization as mc;
33 use rustc::middle::mem_categorization::Categorization;
34 use rustc::ty::{self, Ty, TyCtxt};
35 use rustc::ty::query::Providers;
36 use rustc::ty::subst::Substs;
37 use rustc::util::nodemap::{ItemLocalSet, NodeSet};
38 use rustc::hir;
39 use rustc_data_structures::sync::Lrc;
40 use syntax::ast;
41 use syntax::attr;
42 use syntax_pos::{Span, DUMMY_SP};
43
44 pub fn provide(providers: &mut Providers) {
45     *providers = Providers {
46         rvalue_promotable_map,
47         const_is_rvalue_promotable_to_static,
48         ..*providers
49     };
50 }
51
52 pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
53     for &body_id in &tcx.hir.krate().body_ids {
54         let def_id = tcx.hir.body_owner_def_id(body_id);
55         tcx.const_is_rvalue_promotable_to_static(def_id);
56     }
57     tcx.sess.abort_if_errors();
58 }
59
60 fn const_is_rvalue_promotable_to_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
61                                                   def_id: DefId)
62                                                   -> bool
63 {
64     assert!(def_id.is_local());
65
66     let node_id = tcx.hir.as_local_node_id(def_id)
67         .expect("rvalue_promotable_map invoked with non-local def-id");
68     let body_id = tcx.hir.body_owned_by(node_id);
69     let body_hir_id = tcx.hir.node_to_hir_id(body_id.node_id);
70     tcx.rvalue_promotable_map(def_id).contains(&body_hir_id.local_id)
71 }
72
73 fn rvalue_promotable_map<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
74                                    def_id: DefId)
75                                    -> Lrc<ItemLocalSet>
76 {
77     let outer_def_id = tcx.closure_base_def_id(def_id);
78     if outer_def_id != def_id {
79         return tcx.rvalue_promotable_map(outer_def_id);
80     }
81
82     let mut visitor = CheckCrateVisitor {
83         tcx,
84         tables: &ty::TypeckTables::empty(None),
85         in_fn: false,
86         in_static: false,
87         promotable: false,
88         mut_rvalue_borrows: NodeSet(),
89         param_env: ty::ParamEnv::empty(),
90         identity_substs: Substs::empty(),
91         result: ItemLocalSet(),
92     };
93
94     // `def_id` should be a `Body` owner
95     let node_id = tcx.hir.as_local_node_id(def_id)
96         .expect("rvalue_promotable_map invoked with non-local def-id");
97     let body_id = tcx.hir.body_owned_by(node_id);
98     visitor.visit_nested_body(body_id);
99
100     Lrc::new(visitor.result)
101 }
102
103 struct CheckCrateVisitor<'a, 'tcx: 'a> {
104     tcx: TyCtxt<'a, 'tcx, 'tcx>,
105     in_fn: bool,
106     in_static: bool,
107     promotable: bool,
108     mut_rvalue_borrows: NodeSet,
109     param_env: ty::ParamEnv<'tcx>,
110     identity_substs: &'tcx Substs<'tcx>,
111     tables: &'a ty::TypeckTables<'tcx>,
112     result: ItemLocalSet,
113 }
114
115 impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
116     // Returns true iff all the values of the type are promotable.
117     fn type_has_only_promotable_values(&mut self, ty: Ty<'gcx>) -> bool {
118         ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) &&
119             !ty.needs_drop(self.tcx, self.param_env)
120     }
121
122     fn handle_const_fn_call(&mut self, def_id: DefId, ret_ty: Ty<'gcx>, span: Span) {
123         self.promotable &= self.type_has_only_promotable_values(ret_ty);
124
125         self.promotable &= if let Some(fn_id) = self.tcx.hir.as_local_node_id(def_id) {
126             FnLikeNode::from_node(self.tcx.hir.get(fn_id)).map_or(false, |fn_like| {
127                 fn_like.constness() == hir::Constness::Const
128             })
129         } else {
130             self.tcx.is_const_fn(def_id)
131         };
132
133         if let Some(&attr::Stability {
134             rustc_const_unstable: Some(attr::RustcConstUnstable {
135                                            feature: ref feature_name
136                                        }),
137             .. }) = self.tcx.lookup_stability(def_id) {
138             self.promotable &=
139                 // feature-gate is enabled,
140                 self.tcx.features()
141                     .declared_lib_features
142                     .iter()
143                     .any(|&(ref sym, _)| sym == feature_name) ||
144
145                     // this comes from a crate with the feature-gate enabled,
146                     !def_id.is_local() ||
147
148                     // this comes from a macro that has #[allow_internal_unstable]
149                     span.allows_unstable();
150         }
151     }
152
153     /// While the `ExprUseVisitor` walks, we will identify which
154     /// expressions are borrowed, and insert their ids into this
155     /// table. Actually, we insert the "borrow-id", which is normally
156     /// the id of the expession being borrowed: but in the case of
157     /// `ref mut` borrows, the `id` of the pattern is
158     /// inserted. Therefore later we remove that entry from the table
159     /// and transfer it over to the value being matched. This will
160     /// then prevent said value from being promoted.
161     fn remove_mut_rvalue_borrow(&mut self, pat: &hir::Pat) -> bool {
162         let mut any_removed = false;
163         pat.walk(|p| {
164             any_removed |= self.mut_rvalue_borrows.remove(&p.id);
165             true
166         });
167         any_removed
168     }
169 }
170
171 impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
172     fn visit_nested_body(&mut self, body_id: hir::BodyId) {
173         let item_id = self.tcx.hir.body_owner(body_id);
174         let item_def_id = self.tcx.hir.local_def_id(item_id);
175
176         let outer_in_fn = self.in_fn;
177         let outer_tables = self.tables;
178         let outer_param_env = self.param_env;
179         let outer_identity_substs = self.identity_substs;
180
181         self.in_fn = false;
182         self.in_static = false;
183
184         match self.tcx.hir.body_owner_kind(item_id) {
185             hir::BodyOwnerKind::Fn => self.in_fn = true,
186             hir::BodyOwnerKind::Static(_) => self.in_static = true,
187             _ => {}
188         };
189
190
191         self.tables = self.tcx.typeck_tables_of(item_def_id);
192         self.param_env = self.tcx.param_env(item_def_id);
193         self.identity_substs = Substs::identity_for_item(self.tcx, item_def_id);
194
195         let body = self.tcx.hir.body(body_id);
196
197         let tcx = self.tcx;
198         let param_env = self.param_env;
199         let region_scope_tree = self.tcx.region_scope_tree(item_def_id);
200         euv::ExprUseVisitor::new(self, tcx, param_env, &region_scope_tree, self.tables, None)
201             .consume_body(body);
202
203         self.visit_expr(&body.value);
204         self.in_fn = outer_in_fn;
205         self.tables = outer_tables;
206         self.param_env = outer_param_env;
207         self.identity_substs = outer_identity_substs;
208     }
209
210     fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt) {
211         match stmt.node {
212             hir::StmtDecl(ref decl, _node_id) => {
213                 match &decl.node {
214                     hir::DeclLocal(local) => {
215                         self.promotable = false;
216                         if self.remove_mut_rvalue_borrow(&local.pat) {
217                             if let Some(init) = &local.init {
218                                 self.mut_rvalue_borrows.insert(init.id);
219                             }
220                         }
221
222                         match local.init {
223                             Some(ref expr) => self.visit_expr(&expr),
224                             None => {},
225                         }
226                     }
227                     // Item statements are allowed
228                     hir::DeclItem(_) => {}
229                 }
230             }
231             hir::StmtExpr(ref box_expr, _node_id) |
232             hir::StmtSemi(ref box_expr, _node_id) => {
233                 self.visit_expr(box_expr);
234                 self.promotable = false;
235             }
236         }
237     }
238
239     fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
240         let outer = self.promotable;
241         self.promotable = true;
242
243         let node_ty = self.tables.node_id_to_type(ex.hir_id);
244         check_expr(self, ex, node_ty);
245         check_adjustments(self, ex);
246
247         // Handle borrows on (or inside the autorefs of) this expression.
248         if self.mut_rvalue_borrows.remove(&ex.id) {
249             self.promotable = false;
250         }
251
252         if self.promotable {
253             self.result.insert(ex.hir_id.local_id);
254         }
255         self.promotable &= outer;
256     }
257
258     fn visit_block(&mut self, block: &'tcx hir::Block) {
259         for index in block.stmts.iter() {
260             self.visit_stmt(index)
261         }
262         match block.expr {
263             Some(ref box_expr) => { self.visit_expr(&*box_expr) },
264             None => {},
265         }
266     }
267 }
268
269 /// This function is used to enforce the constraints on
270 /// const/static items. It walks through the *value*
271 /// of the item walking down the expression and evaluating
272 /// every nested expression. If the expression is not part
273 /// of a const/static item, it is qualified for promotion
274 /// instead of producing errors.
275 fn check_expr<'a, 'tcx>(
276     v: &mut CheckCrateVisitor<'a, 'tcx>,
277     e: &'tcx hir::Expr, node_ty: Ty<'tcx>) {
278     match node_ty.sty {
279         ty::TyAdt(def, _) if def.has_dtor(v.tcx) => {
280             v.promotable = false;
281         }
282         _ => {}
283     }
284
285     match e.node {
286         hir::ExprBox(ref expr) => {
287             v.visit_expr(&expr);
288             v.promotable = false;
289         }
290         hir::ExprUnary(op, ref expr) => {
291             if v.tables.is_method_call(e) {
292                 v.promotable = false;
293             }
294             if op == hir::UnDeref {
295                 v.promotable = false;
296             }
297             v.visit_expr(expr);
298         }
299         hir::ExprBinary(op, ref lhs, ref rhs) => {
300             if v.tables.is_method_call(e) {
301                 v.promotable = false;
302             }
303             v.visit_expr(lhs);
304             v.visit_expr(rhs);
305             match v.tables.node_id_to_type(lhs.hir_id).sty {
306                 ty::TyRawPtr(_) => {
307                     assert!(op.node == hir::BiEq || op.node == hir::BiNe ||
308                         op.node == hir::BiLe || op.node == hir::BiLt ||
309                         op.node == hir::BiGe || op.node == hir::BiGt);
310
311                     v.promotable = false;
312                 }
313                 _ => {}
314             }
315         }
316         hir::ExprCast(ref from, _) => {
317             v.visit_expr(from);
318             debug!("Checking const cast(id={})", from.id);
319             match v.tables.cast_kinds().get(from.hir_id) {
320                 None => v.tcx.sess.delay_span_bug(e.span, "no kind for cast"),
321                 Some(&CastKind::PtrAddrCast) | Some(&CastKind::FnPtrAddrCast) => {
322                     v.promotable = false;
323                 }
324                 _ => {}
325             }
326         }
327         hir::ExprPath(ref qpath) => {
328             let def = v.tables.qpath_def(qpath, e.hir_id);
329             match def {
330                 Def::VariantCtor(..) | Def::StructCtor(..) |
331                 Def::Fn(..) | Def::Method(..) =>  {}
332
333                 // References to a static that are themselves within a static
334                 // are inherently promotable with the exception
335                 //  of "#[thread_local]" statics, which may not
336                 // outlive the current function
337                 Def::Static(did, _) => {
338
339                     if v.in_static {
340                         let mut thread_local = false;
341
342                         for attr in &v.tcx.get_attrs(did)[..] {
343                             if attr.check_name("thread_local") {
344                                 debug!("Reference to Static(id={:?}) is unpromotable \
345                                        due to a #[thread_local] attribute", did);
346                                 v.promotable = false;
347                                 thread_local = true;
348                                 break;
349                             }
350                         }
351
352                         if !thread_local {
353                             debug!("Allowing promotion of reference to Static(id={:?})", did);
354                         }
355                     } else {
356                         debug!("Reference to Static(id={:?}) is unpromotable as it is not \
357                                referenced from a static", did);
358                         v.promotable = false;
359
360                     }
361                 }
362
363                 Def::Const(did) |
364                 Def::AssociatedConst(did) => {
365                     let promotable = if v.tcx.trait_of_item(did).is_some() {
366                         // Don't peek inside trait associated constants.
367                         false
368                     } else {
369                         v.tcx.at(e.span).const_is_rvalue_promotable_to_static(did)
370                     };
371
372                     // Just in case the type is more specific than the definition,
373                     // e.g. impl associated const with type parameters, check it.
374                     // Also, trait associated consts are relaxed by this.
375                     v.promotable &= promotable || v.type_has_only_promotable_values(node_ty);
376                 }
377
378                 _ => {
379                     v.promotable = false;
380                 }
381             }
382         }
383         hir::ExprCall(ref callee, ref hirvec) => {
384             v.visit_expr(callee);
385             for index in hirvec.iter() {
386                 v.visit_expr(index)
387             }
388             let mut callee = &**callee;
389             loop {
390                 callee = match callee.node {
391                     hir::ExprBlock(ref block, _) => match block.expr {
392                         Some(ref tail) => &tail,
393                         None => break
394                     },
395                     _ => break
396                 };
397             }
398             // The callee is an arbitrary expression, it doesn't necessarily have a definition.
399             let def = if let hir::ExprPath(ref qpath) = callee.node {
400                 v.tables.qpath_def(qpath, callee.hir_id)
401             } else {
402                 Def::Err
403             };
404             match def {
405                 Def::StructCtor(_, CtorKind::Fn) |
406                 Def::VariantCtor(_, CtorKind::Fn) => {}
407                 Def::Fn(did) => {
408                     v.handle_const_fn_call(did, node_ty, e.span)
409                 }
410                 Def::Method(did) => {
411                     match v.tcx.associated_item(did).container {
412                         ty::ImplContainer(_) => {
413                             v.handle_const_fn_call(did, node_ty, e.span)
414                         }
415                         ty::TraitContainer(_) => v.promotable = false
416                     }
417                 }
418                 _ => v.promotable = false
419             }
420         }
421         hir::ExprMethodCall(ref _pathsegment, ref _span, ref hirvec) => {
422             for index in hirvec.iter() {
423                 v.visit_expr(index)
424             }
425             if let Some(def) = v.tables.type_dependent_defs().get(e.hir_id) {
426                 let def_id = def.def_id();
427                 match v.tcx.associated_item(def_id).container {
428                     ty::ImplContainer(_) => v.handle_const_fn_call(def_id, node_ty, e.span),
429                     ty::TraitContainer(_) => v.promotable = false
430                 }
431             } else {
432                 v.tcx.sess.delay_span_bug(e.span, "no type-dependent def for method call");
433             }
434         }
435         hir::ExprStruct(ref _qpath, ref hirvec, ref option_expr) => {
436             for index in hirvec.iter() {
437                 v.visit_expr(&index.expr);
438             }
439             match *option_expr {
440                 Some(ref expr) => { v.visit_expr(&expr) },
441                 None => {},
442             }
443             if let ty::TyAdt(adt, ..) = v.tables.expr_ty(e).sty {
444                 // unsafe_cell_type doesn't necessarily exist with no_core
445                 if Some(adt.did) == v.tcx.lang_items().unsafe_cell_type() {
446                     v.promotable = false;
447                 }
448             }
449         }
450
451         hir::ExprLit(_) => {}
452
453         hir::ExprAddrOf(_, ref expr) |
454         hir::ExprRepeat(ref expr, _) => {
455             v.visit_expr(expr);
456         }
457
458         hir::ExprClosure(_capture_clause, ref _box_fn_decl,
459                          body_id, _span, _option_generator_movability) => {
460             v.visit_nested_body(body_id);
461             // Paths in constant contexts cannot refer to local variables,
462             // as there are none, and thus closures can't have upvars there.
463             if v.tcx.with_freevars(e.id, |fv| !fv.is_empty()) {
464                 v.promotable = false;
465             }
466         }
467
468         hir::ExprField(ref expr, _ident) => {
469             v.visit_expr(expr);
470             if let Some(def) = v.tables.expr_ty(expr).ty_adt_def() {
471                 if def.is_union() {
472                     v.promotable = false
473                 }
474             }
475         }
476
477         hir::ExprBlock(ref box_block, ref _option_label) => {
478             v.visit_block(box_block);
479         }
480
481         hir::ExprIndex(ref lhs, ref rhs) => {
482             if v.tables.is_method_call(e) {
483                 v.promotable = false;
484             }
485             v.visit_expr(lhs);
486             v.visit_expr(rhs);
487         }
488
489         hir::ExprArray(ref hirvec) => {
490             for index in hirvec.iter() {
491                 v.visit_expr(index)
492             }
493         }
494
495         hir::ExprType(ref expr, ref _ty) => {
496             v.visit_expr(expr);
497         }
498
499         hir::ExprTup(ref hirvec) => {
500             for index in hirvec.iter() {
501                 v.visit_expr(index)
502             }
503         }
504
505
506         // Conditional control flow (possible to implement).
507         hir::ExprMatch(ref expr, ref hirvec_arm, ref _match_source) => {
508             // Compute the most demanding borrow from all the arms'
509             // patterns and set that on the discriminator.
510             let mut mut_borrow = false;
511             for pat in hirvec_arm.iter().flat_map(|arm| &arm.pats) {
512                 mut_borrow = v.remove_mut_rvalue_borrow(pat);
513             }
514             if mut_borrow {
515                 v.mut_rvalue_borrows.insert(expr.id);
516             }
517
518             v.visit_expr(expr);
519             for index in hirvec_arm.iter() {
520                 v.visit_expr(&*index.body);
521                 match index.guard {
522                     Some(ref expr) => v.visit_expr(&expr),
523                     None => {},
524                 }
525             }
526             v.promotable = false;
527         }
528
529         hir::ExprIf(ref lhs, ref rhs, ref option_expr) => {
530             v.visit_expr(lhs);
531             v.visit_expr(rhs);
532             match option_expr {
533                 Some(ref expr) => v.visit_expr(&expr),
534                 None => {},
535             }
536             v.promotable = false;
537         }
538
539         // Loops (not very meaningful in constants).
540         hir::ExprWhile(ref expr, ref box_block, ref _option_label) => {
541             v.visit_expr(expr);
542             v.visit_block(box_block);
543             v.promotable = false;
544         }
545
546         hir::ExprLoop(ref box_block, ref _option_label, ref _loop_source) => {
547             v.visit_block(box_block);
548             v.promotable = false;
549         }
550
551         // More control flow (also not very meaningful).
552         hir::ExprBreak(_, ref option_expr) | hir::ExprRet(ref option_expr) => {
553             match *option_expr {
554                 Some(ref expr) => { v.visit_expr(&expr) },
555                 None => {},
556             }
557             v.promotable = false;
558         }
559
560         hir::ExprContinue(_) => {
561             v.promotable = false;
562         }
563
564         // Generator expressions
565         hir::ExprYield(ref expr) => {
566             v.visit_expr(&expr);
567             v.promotable = false;
568         }
569
570         // Expressions with side-effects.
571         hir::ExprAssignOp(_, ref lhs, ref rhs) | hir::ExprAssign(ref lhs, ref rhs) => {
572             v.visit_expr(lhs);
573             v.visit_expr(rhs);
574             v.promotable = false;
575         }
576
577         hir::ExprInlineAsm(ref _inline_asm, ref hirvec_lhs, ref hirvec_rhs) => {
578             for index in hirvec_lhs.iter() {
579                 v.visit_expr(index)
580             }
581             for index in hirvec_rhs.iter() {
582                 v.visit_expr(index)
583             }
584             v.promotable = false;
585         }
586     }
587 }
588
589 /// Check the adjustments of an expression
590 fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr) {
591     use rustc::ty::adjustment::*;
592
593     let mut adjustments = v.tables.expr_adjustments(e).iter().peekable();
594     while let Some(adjustment) = adjustments.next() {
595         match adjustment.kind {
596             Adjust::NeverToAny |
597             Adjust::ReifyFnPointer |
598             Adjust::UnsafeFnPointer |
599             Adjust::ClosureFnPointer |
600             Adjust::MutToConstPointer |
601             Adjust::Borrow(_) |
602             Adjust::Unsize => {}
603
604             Adjust::Deref(_) => {
605                 if let Some(next_adjustment) = adjustments.peek() {
606                     if let Adjust::Borrow(_) = next_adjustment.kind {
607                         continue;
608                     }
609                 }
610                 v.promotable = false;
611                 break;
612             }
613         }
614     }
615 }
616
617 impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
618     fn consume(&mut self,
619                _consume_id: ast::NodeId,
620                _consume_span: Span,
621                _cmt: &mc::cmt_,
622                _mode: euv::ConsumeMode) {}
623
624     fn borrow(&mut self,
625               borrow_id: ast::NodeId,
626               _borrow_span: Span,
627               cmt: &mc::cmt_<'tcx>,
628               _loan_region: ty::Region<'tcx>,
629               bk: ty::BorrowKind,
630               loan_cause: euv::LoanCause) {
631         debug!(
632             "borrow(borrow_id={:?}, cmt={:?}, bk={:?}, loan_cause={:?})",
633             borrow_id,
634             cmt,
635             bk,
636             loan_cause,
637         );
638
639         // Kind of hacky, but we allow Unsafe coercions in constants.
640         // These occur when we convert a &T or *T to a *U, as well as
641         // when making a thin pointer (e.g., `*T`) into a fat pointer
642         // (e.g., `*Trait`).
643         match loan_cause {
644             euv::LoanCause::AutoUnsafe => {
645                 return;
646             }
647             _ => {}
648         }
649
650         let mut cur = cmt;
651         loop {
652             match cur.cat {
653                 Categorization::Rvalue(..) => {
654                     if loan_cause == euv::MatchDiscriminant {
655                         // Ignore the dummy immutable borrow created by EUV.
656                         break;
657                     }
658                     if bk.to_mutbl_lossy() == hir::MutMutable {
659                         self.mut_rvalue_borrows.insert(borrow_id);
660                     }
661                     break;
662                 }
663                 Categorization::StaticItem => {
664                     break;
665                 }
666                 Categorization::Deref(ref cmt, _) |
667                 Categorization::Downcast(ref cmt, _) |
668                 Categorization::Interior(ref cmt, _) => {
669                     cur = cmt;
670                 }
671
672                 Categorization::Upvar(..) |
673                 Categorization::Local(..) => break,
674             }
675         }
676     }
677
678     fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) {}
679     fn mutate(&mut self,
680               _assignment_id: ast::NodeId,
681               _assignment_span: Span,
682               _assignee_cmt: &mc::cmt_,
683               _mode: euv::MutateMode) {
684     }
685
686     fn matched_pat(&mut self, _: &hir::Pat, _: &mc::cmt_, _: euv::MatchMode) {}
687
688     fn consume_pat(&mut self, _consume_pat: &hir::Pat, _cmt: &mc::cmt_, _mode: euv::ConsumeMode) {}
689 }