1 use crate::consts::{constant_context, constant_simple};
2 use crate::utils::differing_macro_contexts;
4 use rustc::lint::LateContext;
5 use rustc::ty::TypeckTables;
6 use std::collections::hash_map::DefaultHasher;
7 use std::hash::{Hash, Hasher};
11 /// Type used to check whether two ast are the same. This is different from the
13 /// `==` on ast types as this operator would compare true equality with ID and
16 /// Note that some expressions kinds are not considered but could be added.
17 pub struct SpanlessEq<'a, 'tcx: 'a> {
18 /// Context used to evaluate constant expressions.
19 cx: &'a LateContext<'a, 'tcx>,
20 tables: &'a TypeckTables<'tcx>,
21 /// If is true, never consider as equal expressions containing function
26 impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
27 pub fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
35 pub fn ignore_fn(self) -> Self {
38 tables: self.cx.tables,
43 /// Checks whether two statements are the same.
44 pub fn eq_stmt(&mut self, left: &Stmt, right: &Stmt) -> bool {
45 match (&left.node, &right.node) {
46 (&StmtKind::Local(ref l), &StmtKind::Local(ref r)) => {
47 self.eq_pat(&l.pat, &r.pat)
48 && both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r))
49 && both(&l.init, &r.init, |l, r| self.eq_expr(l, r))
51 (&StmtKind::Expr(ref l), &StmtKind::Expr(ref r)) | (&StmtKind::Semi(ref l), &StmtKind::Semi(ref r)) => {
58 /// Checks whether two blocks are the same.
59 pub fn eq_block(&mut self, left: &Block, right: &Block) -> bool {
60 over(&left.stmts, &right.stmts, |l, r| self.eq_stmt(l, r))
61 && both(&left.expr, &right.expr, |l, r| self.eq_expr(l, r))
64 #[allow(clippy::similar_names)]
65 pub fn eq_expr(&mut self, left: &Expr, right: &Expr) -> bool {
66 if self.ignore_fn && differing_macro_contexts(left.span, right.span) {
70 if let (Some(l), Some(r)) = (
71 constant_simple(self.cx, self.tables, left),
72 constant_simple(self.cx, self.tables, right),
79 match (&left.node, &right.node) {
80 (&ExprKind::AddrOf(l_mut, ref le), &ExprKind::AddrOf(r_mut, ref re)) => {
81 l_mut == r_mut && self.eq_expr(le, re)
83 (&ExprKind::Continue(li), &ExprKind::Continue(ri)) => {
84 both(&li.label, &ri.label, |l, r| l.ident.as_str() == r.ident.as_str())
86 (&ExprKind::Assign(ref ll, ref lr), &ExprKind::Assign(ref rl, ref rr)) => {
87 self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
89 (&ExprKind::AssignOp(ref lo, ref ll, ref lr), &ExprKind::AssignOp(ref ro, ref rl, ref rr)) => {
90 lo.node == ro.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
92 (&ExprKind::Block(ref l, _), &ExprKind::Block(ref r, _)) => self.eq_block(l, r),
93 (&ExprKind::Binary(l_op, ref ll, ref lr), &ExprKind::Binary(r_op, ref rl, ref rr)) => {
94 l_op.node == r_op.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
95 || swap_binop(l_op.node, ll, lr).map_or(false, |(l_op, ll, lr)| {
96 l_op == r_op.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
99 (&ExprKind::Break(li, ref le), &ExprKind::Break(ri, ref re)) => {
100 both(&li.label, &ri.label, |l, r| l.ident.as_str() == r.ident.as_str())
101 && both(le, re, |l, r| self.eq_expr(l, r))
103 (&ExprKind::Box(ref l), &ExprKind::Box(ref r)) => self.eq_expr(l, r),
104 (&ExprKind::Call(ref l_fun, ref l_args), &ExprKind::Call(ref r_fun, ref r_args)) => {
105 !self.ignore_fn && self.eq_expr(l_fun, r_fun) && self.eq_exprs(l_args, r_args)
107 (&ExprKind::Cast(ref lx, ref lt), &ExprKind::Cast(ref rx, ref rt))
108 | (&ExprKind::Type(ref lx, ref lt), &ExprKind::Type(ref rx, ref rt)) => {
109 self.eq_expr(lx, rx) && self.eq_ty(lt, rt)
111 (&ExprKind::Field(ref l_f_exp, ref l_f_ident), &ExprKind::Field(ref r_f_exp, ref r_f_ident)) => {
112 l_f_ident.name == r_f_ident.name && self.eq_expr(l_f_exp, r_f_exp)
114 (&ExprKind::Index(ref la, ref li), &ExprKind::Index(ref ra, ref ri)) => {
115 self.eq_expr(la, ra) && self.eq_expr(li, ri)
117 (&ExprKind::If(ref lc, ref lt, ref le), &ExprKind::If(ref rc, ref rt, ref re)) => {
118 self.eq_expr(lc, rc) && self.eq_expr(&**lt, &**rt) && both(le, re, |l, r| self.eq_expr(l, r))
120 (&ExprKind::Lit(ref l), &ExprKind::Lit(ref r)) => l.node == r.node,
121 (&ExprKind::Loop(ref lb, ref ll, ref lls), &ExprKind::Loop(ref rb, ref rl, ref rls)) => {
122 lls == rls && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.ident.as_str() == r.ident.as_str())
124 (&ExprKind::Match(ref le, ref la, ref ls), &ExprKind::Match(ref re, ref ra, ref rs)) => {
126 && self.eq_expr(le, re)
127 && over(la, ra, |l, r| {
128 self.eq_expr(&l.body, &r.body)
129 && both(&l.guard, &r.guard, |l, r| self.eq_guard(l, r))
130 && over(&l.pats, &r.pats, |l, r| self.eq_pat(l, r))
133 (&ExprKind::MethodCall(ref l_path, _, ref l_args), &ExprKind::MethodCall(ref r_path, _, ref r_args)) => {
134 !self.ignore_fn && self.eq_path_segment(l_path, r_path) && self.eq_exprs(l_args, r_args)
136 (&ExprKind::Repeat(ref le, ref ll_id), &ExprKind::Repeat(ref re, ref rl_id)) => {
137 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body));
138 let ll = celcx.expr(&self.cx.tcx.hir().body(ll_id.body).value);
139 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body));
140 let rl = celcx.expr(&self.cx.tcx.hir().body(rl_id.body).value);
142 self.eq_expr(le, re) && ll == rl
144 (&ExprKind::Ret(ref l), &ExprKind::Ret(ref r)) => both(l, r, |l, r| self.eq_expr(l, r)),
145 (&ExprKind::Path(ref l), &ExprKind::Path(ref r)) => self.eq_qpath(l, r),
146 (&ExprKind::Struct(ref l_path, ref lf, ref lo), &ExprKind::Struct(ref r_path, ref rf, ref ro)) => {
147 self.eq_qpath(l_path, r_path)
148 && both(lo, ro, |l, r| self.eq_expr(l, r))
149 && over(lf, rf, |l, r| self.eq_field(l, r))
151 (&ExprKind::Tup(ref l_tup), &ExprKind::Tup(ref r_tup)) => self.eq_exprs(l_tup, r_tup),
152 (&ExprKind::Unary(l_op, ref le), &ExprKind::Unary(r_op, ref re)) => l_op == r_op && self.eq_expr(le, re),
153 (&ExprKind::Array(ref l), &ExprKind::Array(ref r)) => self.eq_exprs(l, r),
154 (&ExprKind::While(ref lc, ref lb, ref ll), &ExprKind::While(ref rc, ref rb, ref rl)) => {
156 && self.eq_block(lb, rb)
157 && both(ll, rl, |l, r| l.ident.as_str() == r.ident.as_str())
159 (&ExprKind::Use(ref le), &ExprKind::Use(ref re)) => self.eq_expr(le, re),
164 fn eq_exprs(&mut self, left: &P<[Expr]>, right: &P<[Expr]>) -> bool {
165 over(left, right, |l, r| self.eq_expr(l, r))
168 fn eq_field(&mut self, left: &Field, right: &Field) -> bool {
169 left.ident.name == right.ident.name && self.eq_expr(&left.expr, &right.expr)
172 fn eq_guard(&mut self, left: &Guard, right: &Guard) -> bool {
173 match (left, right) {
174 (Guard::If(l), Guard::If(r)) => self.eq_expr(l, r),
178 fn eq_generic_arg(&mut self, left: &GenericArg, right: &GenericArg) -> bool {
179 match (left, right) {
180 (GenericArg::Lifetime(l_lt), GenericArg::Lifetime(r_lt)) => self.eq_lifetime(l_lt, r_lt),
181 (GenericArg::Type(l_ty), GenericArg::Type(r_ty)) => self.eq_ty(l_ty, r_ty),
186 fn eq_lifetime(&mut self, left: &Lifetime, right: &Lifetime) -> bool {
187 left.name == right.name
190 /// Checks whether two patterns are the same.
191 pub fn eq_pat(&mut self, left: &Pat, right: &Pat) -> bool {
192 match (&left.node, &right.node) {
193 (&PatKind::Box(ref l), &PatKind::Box(ref r)) => self.eq_pat(l, r),
194 (&PatKind::TupleStruct(ref lp, ref la, ls), &PatKind::TupleStruct(ref rp, ref ra, rs)) => {
195 self.eq_qpath(lp, rp) && over(la, ra, |l, r| self.eq_pat(l, r)) && ls == rs
197 (&PatKind::Binding(ref lb, .., ref li, ref lp), &PatKind::Binding(ref rb, .., ref ri, ref rp)) => {
198 lb == rb && li.name.as_str() == ri.name.as_str() && both(lp, rp, |l, r| self.eq_pat(l, r))
200 (&PatKind::Path(ref l), &PatKind::Path(ref r)) => self.eq_qpath(l, r),
201 (&PatKind::Lit(ref l), &PatKind::Lit(ref r)) => self.eq_expr(l, r),
202 (&PatKind::Tuple(ref l, ls), &PatKind::Tuple(ref r, rs)) => {
203 ls == rs && over(l, r, |l, r| self.eq_pat(l, r))
205 (&PatKind::Range(ref ls, ref le, ref li), &PatKind::Range(ref rs, ref re, ref ri)) => {
206 self.eq_expr(ls, rs) && self.eq_expr(le, re) && (*li == *ri)
208 (&PatKind::Ref(ref le, ref lm), &PatKind::Ref(ref re, ref rm)) => lm == rm && self.eq_pat(le, re),
209 (&PatKind::Slice(ref ls, ref li, ref le), &PatKind::Slice(ref rs, ref ri, ref re)) => {
210 over(ls, rs, |l, r| self.eq_pat(l, r))
211 && over(le, re, |l, r| self.eq_pat(l, r))
212 && both(li, ri, |l, r| self.eq_pat(l, r))
214 (&PatKind::Wild, &PatKind::Wild) => true,
219 #[allow(clippy::similar_names)]
220 fn eq_qpath(&mut self, left: &QPath, right: &QPath) -> bool {
221 match (left, right) {
222 (&QPath::Resolved(ref lty, ref lpath), &QPath::Resolved(ref rty, ref rpath)) => {
223 both(lty, rty, |l, r| self.eq_ty(l, r)) && self.eq_path(lpath, rpath)
225 (&QPath::TypeRelative(ref lty, ref lseg), &QPath::TypeRelative(ref rty, ref rseg)) => {
226 self.eq_ty(lty, rty) && self.eq_path_segment(lseg, rseg)
232 fn eq_path(&mut self, left: &Path, right: &Path) -> bool {
233 left.is_global() == right.is_global()
234 && over(&left.segments, &right.segments, |l, r| self.eq_path_segment(l, r))
237 fn eq_path_parameters(&mut self, left: &GenericArgs, right: &GenericArgs) -> bool {
238 if !(left.parenthesized || right.parenthesized) {
239 over(&left.args, &right.args, |l, r| self.eq_generic_arg(l, r)) // FIXME(flip1995): may not work
240 && over(&left.bindings, &right.bindings, |l, r| self.eq_type_binding(l, r))
241 } else if left.parenthesized && right.parenthesized {
242 over(left.inputs(), right.inputs(), |l, r| self.eq_ty(l, r))
243 && both(&Some(&left.bindings[0].ty), &Some(&right.bindings[0].ty), |l, r| {
251 pub fn eq_path_segments(&mut self, left: &[PathSegment], right: &[PathSegment]) -> bool {
252 left.len() == right.len() && left.iter().zip(right).all(|(l, r)| self.eq_path_segment(l, r))
255 pub fn eq_path_segment(&mut self, left: &PathSegment, right: &PathSegment) -> bool {
256 // The == of idents doesn't work with different contexts,
257 // we have to be explicit about hygiene
258 if left.ident.as_str() != right.ident.as_str() {
261 match (&left.args, &right.args) {
262 (&None, &None) => true,
263 (&Some(ref l), &Some(ref r)) => self.eq_path_parameters(l, r),
268 pub fn eq_ty(&mut self, left: &Ty, right: &Ty) -> bool {
269 self.eq_ty_kind(&left.node, &right.node)
272 #[allow(clippy::similar_names)]
273 pub fn eq_ty_kind(&mut self, left: &TyKind, right: &TyKind) -> bool {
274 match (left, right) {
275 (&TyKind::Slice(ref l_vec), &TyKind::Slice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
276 (&TyKind::Array(ref lt, ref ll_id), &TyKind::Array(ref rt, ref rl_id)) => {
277 let full_table = self.tables;
279 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body));
280 self.tables = self.cx.tcx.body_tables(ll_id.body);
281 let ll = celcx.expr(&self.cx.tcx.hir().body(ll_id.body).value);
283 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body));
284 self.tables = self.cx.tcx.body_tables(rl_id.body);
285 let rl = celcx.expr(&self.cx.tcx.hir().body(rl_id.body).value);
287 let eq_ty = self.eq_ty(lt, rt);
288 self.tables = full_table;
291 (&TyKind::Ptr(ref l_mut), &TyKind::Ptr(ref r_mut)) => {
292 l_mut.mutbl == r_mut.mutbl && self.eq_ty(&*l_mut.ty, &*r_mut.ty)
294 (&TyKind::Rptr(_, ref l_rmut), &TyKind::Rptr(_, ref r_rmut)) => {
295 l_rmut.mutbl == r_rmut.mutbl && self.eq_ty(&*l_rmut.ty, &*r_rmut.ty)
297 (&TyKind::Path(ref l), &TyKind::Path(ref r)) => self.eq_qpath(l, r),
298 (&TyKind::Tup(ref l), &TyKind::Tup(ref r)) => over(l, r, |l, r| self.eq_ty(l, r)),
299 (&TyKind::Infer, &TyKind::Infer) => true,
304 fn eq_type_binding(&mut self, left: &TypeBinding, right: &TypeBinding) -> bool {
305 left.ident.name == right.ident.name && self.eq_ty(&left.ty, &right.ty)
309 fn swap_binop<'a>(binop: BinOpKind, lhs: &'a Expr, rhs: &'a Expr) -> Option<(BinOpKind, &'a Expr, &'a Expr)> {
317 | BinOpKind::BitOr => Some((binop, rhs, lhs)),
318 BinOpKind::Lt => Some((BinOpKind::Gt, rhs, lhs)),
319 BinOpKind::Le => Some((BinOpKind::Ge, rhs, lhs)),
320 BinOpKind::Ge => Some((BinOpKind::Le, rhs, lhs)),
321 BinOpKind::Gt => Some((BinOpKind::Lt, rhs, lhs)),
328 | BinOpKind::Or => None,
332 /// Checks if the two `Option`s are both `None` or some equal values as per
334 fn both<X, F>(l: &Option<X>, r: &Option<X>, mut eq_fn: F) -> bool
336 F: FnMut(&X, &X) -> bool,
339 .map_or_else(|| r.is_none(), |x| r.as_ref().map_or(false, |y| eq_fn(x, y)))
342 /// Checks if two slices are equal as per `eq_fn`.
343 fn over<X, F>(left: &[X], right: &[X], mut eq_fn: F) -> bool
345 F: FnMut(&X, &X) -> bool,
347 left.len() == right.len() && left.iter().zip(right).all(|(x, y)| eq_fn(x, y))
350 /// Type used to hash an ast element. This is different from the `Hash` trait
351 /// on ast types as this
352 /// trait would consider IDs and spans.
354 /// All expressions kind are hashed, but some might have a weaker hash.
355 pub struct SpanlessHash<'a, 'tcx: 'a> {
356 /// Context used to evaluate constant expressions.
357 cx: &'a LateContext<'a, 'tcx>,
358 tables: &'a TypeckTables<'tcx>,
362 impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
363 pub fn new(cx: &'a LateContext<'a, 'tcx>, tables: &'a TypeckTables<'tcx>) -> Self {
367 s: DefaultHasher::new(),
371 pub fn finish(&self) -> u64 {
375 pub fn hash_block(&mut self, b: &Block) {
380 if let Some(ref e) = b.expr {
385 BlockCheckMode::DefaultBlock => 0,
386 BlockCheckMode::UnsafeBlock(_) => 1,
387 BlockCheckMode::PushUnsafeBlock(_) => 2,
388 BlockCheckMode::PopUnsafeBlock(_) => 3,
393 #[allow(clippy::many_single_char_names, clippy::too_many_lines)]
394 pub fn hash_expr(&mut self, e: &Expr) {
395 if let Some(e) = constant_simple(self.cx, self.tables, e) {
396 return e.hash(&mut self.s);
400 ExprKind::AddrOf(m, ref e) => {
401 let c: fn(_, _) -> _ = ExprKind::AddrOf;
406 ExprKind::Continue(i) => {
407 let c: fn(_) -> _ = ExprKind::Continue;
409 if let Some(i) = i.label {
410 self.hash_name(i.ident.name);
413 ExprKind::Yield(ref e) => {
414 let c: fn(_) -> _ = ExprKind::Yield;
418 ExprKind::Assign(ref l, ref r) => {
419 let c: fn(_, _) -> _ = ExprKind::Assign;
424 ExprKind::AssignOp(ref o, ref l, ref r) => {
425 let c: fn(_, _, _) -> _ = ExprKind::AssignOp;
431 ExprKind::Block(ref b, _) => {
432 let c: fn(_, _) -> _ = ExprKind::Block;
436 ExprKind::Binary(op, ref l, ref r) => {
437 let c: fn(_, _, _) -> _ = ExprKind::Binary;
439 op.node.hash(&mut self.s);
443 ExprKind::Break(i, ref j) => {
444 let c: fn(_, _) -> _ = ExprKind::Break;
446 if let Some(i) = i.label {
447 self.hash_name(i.ident.name);
449 if let Some(ref j) = *j {
453 ExprKind::Box(ref e) => {
454 let c: fn(_) -> _ = ExprKind::Box;
458 ExprKind::Call(ref fun, ref args) => {
459 let c: fn(_, _) -> _ = ExprKind::Call;
462 self.hash_exprs(args);
464 ExprKind::Cast(ref e, ref _ty) => {
465 let c: fn(_, _) -> _ = ExprKind::Cast;
470 ExprKind::Closure(cap, _, eid, _, _) => {
471 let c: fn(_, _, _, _, _) -> _ = ExprKind::Closure;
474 CaptureClause::CaptureByValue => 0,
475 CaptureClause::CaptureByRef => 1,
478 self.hash_expr(&self.cx.tcx.hir().body(eid).value);
480 ExprKind::Field(ref e, ref f) => {
481 let c: fn(_, _) -> _ = ExprKind::Field;
484 self.hash_name(f.name);
486 ExprKind::Index(ref a, ref i) => {
487 let c: fn(_, _) -> _ = ExprKind::Index;
492 ExprKind::InlineAsm(..) => {
493 let c: fn(_, _, _) -> _ = ExprKind::InlineAsm;
496 ExprKind::If(ref cond, ref t, ref e) => {
497 let c: fn(_, _, _) -> _ = ExprKind::If;
499 self.hash_expr(cond);
500 self.hash_expr(&**t);
501 if let Some(ref e) = *e {
505 ExprKind::Lit(ref l) => {
506 let c: fn(_) -> _ = ExprKind::Lit;
510 ExprKind::Loop(ref b, ref i, _) => {
511 let c: fn(_, _, _) -> _ = ExprKind::Loop;
514 if let Some(i) = *i {
515 self.hash_name(i.ident.name);
518 ExprKind::Match(ref e, ref arms, ref s) => {
519 let c: fn(_, _, _) -> _ = ExprKind::Match;
525 if let Some(ref e) = arm.guard {
528 self.hash_expr(&arm.body);
533 ExprKind::MethodCall(ref path, ref _tys, ref args) => {
534 let c: fn(_, _, _) -> _ = ExprKind::MethodCall;
536 self.hash_name(path.ident.name);
537 self.hash_exprs(args);
539 ExprKind::Repeat(ref e, ref l_id) => {
540 let c: fn(_, _) -> _ = ExprKind::Repeat;
543 let full_table = self.tables;
544 self.tables = self.cx.tcx.body_tables(l_id.body);
545 self.hash_expr(&self.cx.tcx.hir().body(l_id.body).value);
546 self.tables = full_table;
548 ExprKind::Ret(ref e) => {
549 let c: fn(_) -> _ = ExprKind::Ret;
551 if let Some(ref e) = *e {
555 ExprKind::Path(ref qpath) => {
556 let c: fn(_) -> _ = ExprKind::Path;
558 self.hash_qpath(qpath);
560 ExprKind::Struct(ref path, ref fields, ref expr) => {
561 let c: fn(_, _, _) -> _ = ExprKind::Struct;
564 self.hash_qpath(path);
567 self.hash_name(f.ident.name);
568 self.hash_expr(&f.expr);
571 if let Some(ref e) = *expr {
575 ExprKind::Tup(ref tup) => {
576 let c: fn(_) -> _ = ExprKind::Tup;
578 self.hash_exprs(tup);
580 ExprKind::Type(ref e, ref _ty) => {
581 let c: fn(_, _) -> _ = ExprKind::Type;
586 ExprKind::Unary(lop, ref le) => {
587 let c: fn(_, _) -> _ = ExprKind::Unary;
590 lop.hash(&mut self.s);
593 ExprKind::Array(ref v) => {
594 let c: fn(_) -> _ = ExprKind::Array;
599 ExprKind::While(ref cond, ref b, l) => {
600 let c: fn(_, _, _) -> _ = ExprKind::While;
603 self.hash_expr(cond);
606 self.hash_name(l.ident.name);
610 ExprKind::Use(ref e) => {
611 let c: fn(_) -> _ = ExprKind::Use;
618 pub fn hash_exprs(&mut self, e: &P<[Expr]>) {
624 pub fn hash_name(&mut self, n: Name) {
625 n.as_str().hash(&mut self.s);
628 pub fn hash_qpath(&mut self, p: &QPath) {
630 QPath::Resolved(_, ref path) => {
631 self.hash_path(path);
633 QPath::TypeRelative(_, ref path) => {
634 self.hash_name(path.ident.name);
637 // self.cx.tables.qpath_def(p, id).hash(&mut self.s);
640 pub fn hash_path(&mut self, p: &Path) {
641 p.is_global().hash(&mut self.s);
642 for p in &p.segments {
643 self.hash_name(p.ident.name);
647 pub fn hash_stmt(&mut self, b: &Stmt) {
649 StmtKind::Local(ref local) => {
650 let c: fn(_) -> _ = StmtKind::Local;
652 if let Some(ref init) = local.init {
653 self.hash_expr(init);
656 StmtKind::Item(..) => {
657 let c: fn(_) -> _ = StmtKind::Item;
660 StmtKind::Expr(ref expr) => {
661 let c: fn(_) -> _ = StmtKind::Expr;
663 self.hash_expr(expr);
665 StmtKind::Semi(ref expr) => {
666 let c: fn(_) -> _ = StmtKind::Semi;
668 self.hash_expr(expr);
673 pub fn hash_guard(&mut self, g: &Guard) {
675 Guard::If(ref expr) => {
676 let c: fn(_) -> _ = Guard::If;
678 self.hash_expr(expr);