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