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