]> git.lizzy.rs Git - rust.git/blob - src/librustc_passes/rvalue_promotion.rs
Rollup merge of #61419 - scottmcm:casing-is-on-strings, r=cramertj
[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::symbol::sym;
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                                    -> &'tcx 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     tcx.arena.alloc(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(
203             self,
204             tcx,
205             item_def_id,
206             param_env,
207             &region_scope_tree,
208             tables,
209             None,
210         ).consume_body(body);
211
212         let body_promotable = self.check_expr(&body.value);
213         self.in_fn = outer_in_fn;
214         self.tables = outer_tables;
215         self.param_env = outer_param_env;
216         self.identity_substs = outer_identity_substs;
217         body_promotable
218     }
219
220     fn check_stmt(&mut self, stmt: &'tcx hir::Stmt) -> Promotability {
221         match stmt.node {
222             hir::StmtKind::Local(ref local) => {
223                 if self.remove_mut_rvalue_borrow(&local.pat) {
224                     if let Some(init) = &local.init {
225                         self.mut_rvalue_borrows.insert(init.hir_id);
226                     }
227                 }
228
229                 if let Some(ref expr) = local.init {
230                     let _ = self.check_expr(&expr);
231                 }
232                 NotPromotable
233             }
234             // Item statements are allowed
235             hir::StmtKind::Item(..) => Promotable,
236             hir::StmtKind::Expr(ref box_expr) |
237             hir::StmtKind::Semi(ref box_expr) => {
238                 let _ = self.check_expr(box_expr);
239                 NotPromotable
240             }
241         }
242     }
243
244     fn check_expr(&mut self, ex: &'tcx hir::Expr) -> Promotability {
245         let node_ty = self.tables.node_type(ex.hir_id);
246         let mut outer = check_expr_kind(self, ex, node_ty);
247         outer &= check_adjustments(self, ex);
248
249         // Handle borrows on (or inside the autorefs of) this expression.
250         if self.mut_rvalue_borrows.remove(&ex.hir_id) {
251             outer = NotPromotable
252         }
253
254         if outer == Promotable {
255             self.result.insert(ex.hir_id.local_id);
256         }
257         outer
258     }
259
260     fn check_block(&mut self, block: &'tcx hir::Block) -> Promotability {
261         let mut iter_result = Promotable;
262         for index in block.stmts.iter() {
263             iter_result &= self.check_stmt(index);
264         }
265         match block.expr {
266             Some(ref box_expr) => iter_result & self.check_expr(&*box_expr),
267             None => iter_result,
268         }
269     }
270 }
271
272 /// This function is used to enforce the constraints on
273 /// const/static items. It walks through the *value*
274 /// of the item walking down the expression and evaluating
275 /// every nested expression. If the expression is not part
276 /// of a const/static item, it is qualified for promotion
277 /// instead of producing errors.
278 fn check_expr_kind<'a, 'tcx>(
279     v: &mut CheckCrateVisitor<'a, 'tcx>,
280     e: &'tcx hir::Expr, node_ty: Ty<'tcx>) -> Promotability {
281
282     let ty_result = match node_ty.sty {
283         ty::Adt(def, _) if def.has_dtor(v.tcx) => {
284             NotPromotable
285         }
286         _ => Promotable
287     };
288
289     let node_result = match e.node {
290         hir::ExprKind::Box(ref expr) => {
291             let _ = v.check_expr(&expr);
292             NotPromotable
293         }
294         hir::ExprKind::Unary(op, ref expr) => {
295             let expr_promotability = v.check_expr(expr);
296             if v.tables.is_method_call(e) || op == hir::UnDeref {
297                 return NotPromotable;
298             }
299             expr_promotability
300         }
301         hir::ExprKind::Binary(op, ref lhs, ref rhs) => {
302             let lefty = v.check_expr(lhs);
303             let righty = v.check_expr(rhs);
304             if v.tables.is_method_call(e) {
305                 return NotPromotable;
306             }
307             match v.tables.node_type(lhs.hir_id).sty {
308                 ty::RawPtr(_) | ty::FnPtr(..) => {
309                     assert!(op.node == hir::BinOpKind::Eq || op.node == hir::BinOpKind::Ne ||
310                             op.node == hir::BinOpKind::Le || op.node == hir::BinOpKind::Lt ||
311                             op.node == hir::BinOpKind::Ge || op.node == hir::BinOpKind::Gt);
312
313                     NotPromotable
314                 }
315                 _ => lefty & righty
316             }
317         }
318         hir::ExprKind::Cast(ref from, _) => {
319             let expr_promotability = v.check_expr(from);
320             debug!("Checking const cast(id={})", from.hir_id);
321             let cast_in = CastTy::from_ty(v.tables.expr_ty(from));
322             let cast_out = CastTy::from_ty(v.tables.expr_ty(e));
323             match (cast_in, cast_out) {
324                 (Some(CastTy::FnPtr), Some(CastTy::Int(_))) |
325                 (Some(CastTy::Ptr(_)), Some(CastTy::Int(_))) => NotPromotable,
326                 (_, _) => expr_promotability
327             }
328         }
329         hir::ExprKind::Path(ref qpath) => {
330             let res = v.tables.qpath_res(qpath, e.hir_id);
331             match res {
332                 Res::Def(DefKind::Ctor(..), _)
333                 | Res::Def(DefKind::Fn, _)
334                 | Res::Def(DefKind::Method, _)
335                 | Res::SelfCtor(..) =>
336                     Promotable,
337
338                 // References to a static that are themselves within a static
339                 // are inherently promotable with the exception
340                 //  of "#[thread_local]" statics, which may not
341                 // outlive the current function
342                 Res::Def(DefKind::Static, did) => {
343
344                     if v.in_static {
345                         for attr in &v.tcx.get_attrs(did)[..] {
346                             if attr.check_name(sym::thread_local) {
347                                 debug!("Reference to Static(id={:?}) is unpromotable \
348                                        due to a #[thread_local] attribute", did);
349                                 return NotPromotable;
350                             }
351                         }
352                         Promotable
353                     } else {
354                         debug!("Reference to Static(id={:?}) is unpromotable as it is not \
355                                referenced from a static", did);
356                         NotPromotable
357                     }
358                 }
359
360                 Res::Def(DefKind::Const, did) |
361                 Res::Def(DefKind::AssocConst, did) => {
362                     let promotable = if v.tcx.trait_of_item(did).is_some() {
363                         // Don't peek inside trait associated constants.
364                         NotPromotable
365                     } else if v.tcx.at(e.span).const_is_rvalue_promotable_to_static(did) {
366                         Promotable
367                     } else {
368                         NotPromotable
369                     };
370                     // Just in case the type is more specific than the definition,
371                     // e.g., impl associated const with type parameters, check it.
372                     // Also, trait associated consts are relaxed by this.
373                     promotable | v.type_promotability(node_ty)
374                 }
375                 _ => NotPromotable
376             }
377         }
378         hir::ExprKind::Call(ref callee, ref hirvec) => {
379             let mut call_result = v.check_expr(callee);
380             for index in hirvec.iter() {
381                 call_result &= v.check_expr(index);
382             }
383             let mut callee = &**callee;
384             loop {
385                 callee = match callee.node {
386                     hir::ExprKind::Block(ref block, _) => match block.expr {
387                         Some(ref tail) => &tail,
388                         None => break
389                     },
390                     _ => break
391                 };
392             }
393             // The callee is an arbitrary expression, it doesn't necessarily have a definition.
394             let def = if let hir::ExprKind::Path(ref qpath) = callee.node {
395                 v.tables.qpath_res(qpath, callee.hir_id)
396             } else {
397                 Res::Err
398             };
399             let def_result = match def {
400                 Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) |
401                 Res::SelfCtor(..) => Promotable,
402                 Res::Def(DefKind::Fn, did) => v.handle_const_fn_call(did),
403                 Res::Def(DefKind::Method, did) => {
404                     match v.tcx.associated_item(did).container {
405                         ty::ImplContainer(_) => v.handle_const_fn_call(did),
406                         ty::TraitContainer(_) => NotPromotable,
407                     }
408                 }
409                 _ => NotPromotable,
410             };
411             def_result & call_result
412         }
413         hir::ExprKind::MethodCall(ref _pathsegment, ref _span, ref hirvec) => {
414             let mut method_call_result = Promotable;
415             for index in hirvec.iter() {
416                 method_call_result &= v.check_expr(index);
417             }
418             if let Some(def_id) = v.tables.type_dependent_def_id(e.hir_id) {
419                 match v.tcx.associated_item(def_id).container {
420                     ty::ImplContainer(_) => method_call_result & v.handle_const_fn_call(def_id),
421                     ty::TraitContainer(_) => NotPromotable,
422                 }
423             } else {
424                 v.tcx.sess.delay_span_bug(e.span, "no type-dependent def for method call");
425                 NotPromotable
426             }
427         }
428         hir::ExprKind::Struct(ref _qpath, ref hirvec, ref option_expr) => {
429             let mut struct_result = Promotable;
430             for index in hirvec.iter() {
431                 struct_result &= v.check_expr(&index.expr);
432             }
433             if let Some(ref expr) = *option_expr {
434                 struct_result &= v.check_expr(&expr);
435             }
436             if let ty::Adt(adt, ..) = v.tables.expr_ty(e).sty {
437                 // unsafe_cell_type doesn't necessarily exist with no_core
438                 if Some(adt.did) == v.tcx.lang_items().unsafe_cell_type() {
439                     return NotPromotable;
440                 }
441             }
442             struct_result
443         }
444
445         hir::ExprKind::Lit(_) |
446         hir::ExprKind::Err => Promotable,
447
448         hir::ExprKind::AddrOf(_, ref expr) |
449         hir::ExprKind::Repeat(ref expr, _) |
450         hir::ExprKind::Type(ref expr, _) |
451         hir::ExprKind::DropTemps(ref expr) => {
452             v.check_expr(&expr)
453         }
454
455         hir::ExprKind::Closure(_capture_clause, ref _box_fn_decl,
456                                body_id, _span, _option_generator_movability) => {
457             let nested_body_promotable = v.check_nested_body(body_id);
458             // Paths in constant contexts cannot refer to local variables,
459             // as there are none, and thus closures can't have upvars there.
460             let closure_def_id = v.tcx.hir().local_def_id_from_hir_id(e.hir_id);
461             if !v.tcx.upvars(closure_def_id).map_or(true, |v| v.is_empty()) {
462                 NotPromotable
463             } else {
464                 nested_body_promotable
465             }
466         }
467
468         hir::ExprKind::Field(ref expr, _ident) => {
469             let expr_promotability = v.check_expr(&expr);
470             if let Some(def) = v.tables.expr_ty(expr).ty_adt_def() {
471                 if def.is_union() {
472                     return NotPromotable;
473                 }
474             }
475             expr_promotability
476         }
477
478         hir::ExprKind::Block(ref box_block, ref _option_label) => {
479             v.check_block(box_block)
480         }
481
482         hir::ExprKind::Index(ref lhs, ref rhs) => {
483             let lefty = v.check_expr(lhs);
484             let righty = v.check_expr(rhs);
485             if v.tables.is_method_call(e) {
486                 return NotPromotable;
487             }
488             lefty & righty
489         }
490
491         hir::ExprKind::Array(ref hirvec) => {
492             let mut array_result = Promotable;
493             for index in hirvec.iter() {
494                 array_result &= v.check_expr(index);
495             }
496             array_result
497         }
498
499         hir::ExprKind::Tup(ref hirvec) => {
500             let mut tup_result = Promotable;
501             for index in hirvec.iter() {
502                 tup_result &= v.check_expr(index);
503             }
504             tup_result
505         }
506
507         // Conditional control flow (possible to implement).
508         hir::ExprKind::Match(ref expr, ref hirvec_arm, ref _match_source) => {
509             // Compute the most demanding borrow from all the arms'
510             // patterns and set that on the discriminator.
511             let mut mut_borrow = false;
512             for pat in hirvec_arm.iter().flat_map(|arm| &arm.pats) {
513                 mut_borrow = v.remove_mut_rvalue_borrow(pat);
514             }
515             if mut_borrow {
516                 v.mut_rvalue_borrows.insert(expr.hir_id);
517             }
518
519             let _ = v.check_expr(expr);
520             for index in hirvec_arm.iter() {
521                 let _ = v.check_expr(&*index.body);
522                 if let Some(hir::Guard::If(ref expr)) = index.guard {
523                     let _ = v.check_expr(&expr);
524                 }
525             }
526             NotPromotable
527         }
528
529         // Loops (not very meaningful in constants).
530         hir::ExprKind::While(ref expr, ref box_block, ref _option_label) => {
531             let _ = v.check_expr(expr);
532             let _ = v.check_block(box_block);
533             NotPromotable
534         }
535
536         hir::ExprKind::Loop(ref box_block, ref _option_label, ref _loop_source) => {
537             let _ = v.check_block(box_block);
538             NotPromotable
539         }
540
541         // More control flow (also not very meaningful).
542         hir::ExprKind::Break(_, ref option_expr) | hir::ExprKind::Ret(ref option_expr) => {
543             if let Some(ref expr) = *option_expr {
544                  let _ = v.check_expr(&expr);
545             }
546             NotPromotable
547         }
548
549         hir::ExprKind::Continue(_) => {
550             NotPromotable
551         }
552
553         // Generator expressions
554         hir::ExprKind::Yield(ref expr) => {
555             let _ = v.check_expr(&expr);
556             NotPromotable
557         }
558
559         // Expressions with side-effects.
560         hir::ExprKind::AssignOp(_, ref lhs, ref rhs) | hir::ExprKind::Assign(ref lhs, ref rhs) => {
561             let _ = v.check_expr(lhs);
562             let _ = v.check_expr(rhs);
563             NotPromotable
564         }
565
566         hir::ExprKind::InlineAsm(ref _inline_asm, ref hirvec_lhs, ref hirvec_rhs) => {
567             for index in hirvec_lhs.iter().chain(hirvec_rhs.iter()) {
568                 let _ = v.check_expr(index);
569             }
570             NotPromotable
571         }
572     };
573     ty_result & node_result
574 }
575
576 /// Checks the adjustments of an expression.
577 fn check_adjustments<'a, 'tcx>(
578     v: &mut CheckCrateVisitor<'a, 'tcx>,
579     e: &hir::Expr) -> Promotability {
580     use rustc::ty::adjustment::*;
581
582     let mut adjustments = v.tables.expr_adjustments(e).iter().peekable();
583     while let Some(adjustment) = adjustments.next() {
584         match adjustment.kind {
585             Adjust::NeverToAny |
586             Adjust::Pointer(_) |
587             Adjust::Borrow(_) => {}
588
589             Adjust::Deref(_) => {
590                 if let Some(next_adjustment) = adjustments.peek() {
591                     if let Adjust::Borrow(_) = next_adjustment.kind {
592                         continue;
593                     }
594                 }
595                 return NotPromotable;
596             }
597         }
598     }
599     Promotable
600 }
601
602 impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
603     fn consume(&mut self,
604                _consume_id: hir::HirId,
605                _consume_span: Span,
606                _cmt: &mc::cmt_<'_>,
607                _mode: euv::ConsumeMode) {}
608
609     fn borrow(&mut self,
610               borrow_id: hir::HirId,
611               _borrow_span: Span,
612               cmt: &mc::cmt_<'tcx>,
613               _loan_region: ty::Region<'tcx>,
614               bk: ty::BorrowKind,
615               loan_cause: euv::LoanCause) {
616         debug!(
617             "borrow(borrow_id={:?}, cmt={:?}, bk={:?}, loan_cause={:?})",
618             borrow_id,
619             cmt,
620             bk,
621             loan_cause,
622         );
623
624         // Kind of hacky, but we allow Unsafe coercions in constants.
625         // These occur when we convert a &T or *T to a *U, as well as
626         // when making a thin pointer (e.g., `*T`) into a fat pointer
627         // (e.g., `*Trait`).
628         if let euv::LoanCause::AutoUnsafe = loan_cause {
629             return;
630         }
631
632         let mut cur = cmt;
633         loop {
634             match cur.cat {
635                 Categorization::ThreadLocal(..) |
636                 Categorization::Rvalue(..) => {
637                     if loan_cause == euv::MatchDiscriminant {
638                         // Ignore the dummy immutable borrow created by EUV.
639                         break;
640                     }
641                     if bk.to_mutbl_lossy() == hir::MutMutable {
642                         self.mut_rvalue_borrows.insert(borrow_id);
643                     }
644                     break;
645                 }
646                 Categorization::StaticItem => {
647                     break;
648                 }
649                 Categorization::Deref(ref cmt, _) |
650                 Categorization::Downcast(ref cmt, _) |
651                 Categorization::Interior(ref cmt, _) => {
652                     cur = cmt;
653                 }
654
655                 Categorization::Upvar(..) |
656                 Categorization::Local(..) => break,
657             }
658         }
659     }
660
661     fn decl_without_init(&mut self, _id: hir::HirId, _span: Span) {}
662     fn mutate(&mut self,
663               _assignment_id: hir::HirId,
664               _assignment_span: Span,
665               _assignee_cmt: &mc::cmt_<'_>,
666               _mode: euv::MutateMode) {
667     }
668
669     fn matched_pat(&mut self, _: &hir::Pat, _: &mc::cmt_<'_>, _: euv::MatchMode) {}
670
671     fn consume_pat(&mut self,
672                    _consume_pat: &hir::Pat,
673                    _cmt: &mc::cmt_<'_>,
674                    _mode: euv::ConsumeMode) {}
675 }