1 use crate::consts::{constant_context, constant_simple};
2 use crate::utils::differing_macro_contexts;
3 use rustc::hir::ptr::P;
5 use rustc::ich::StableHashingContextProvider;
6 use rustc::lint::LateContext;
7 use rustc::ty::TypeckTables;
8 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
10 use syntax::ast::Name;
12 /// Type used to check whether two ast are the same. This is different from the
14 /// `==` on ast types as this operator would compare true equality with ID and
17 /// Note that some expressions kinds are not considered but could be added.
18 pub struct SpanlessEq<'a, 'tcx> {
19 /// Context used to evaluate constant expressions.
20 cx: &'a LateContext<'a, 'tcx>,
21 tables: &'a TypeckTables<'tcx>,
22 /// If is true, never consider as equal expressions containing function
27 impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
28 pub fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
36 pub fn ignore_fn(self) -> Self {
39 tables: self.cx.tables,
44 /// Checks whether two statements are the same.
45 pub fn eq_stmt(&mut self, left: &Stmt, right: &Stmt) -> bool {
46 match (&left.kind, &right.kind) {
47 (&StmtKind::Local(ref l), &StmtKind::Local(ref r)) => {
48 self.eq_pat(&l.pat, &r.pat)
49 && both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r))
50 && both(&l.init, &r.init, |l, r| self.eq_expr(l, r))
52 (&StmtKind::Expr(ref l), &StmtKind::Expr(ref r)) | (&StmtKind::Semi(ref l), &StmtKind::Semi(ref r)) => {
59 /// Checks whether two blocks are the same.
60 pub fn eq_block(&mut self, left: &Block, right: &Block) -> bool {
61 over(&left.stmts, &right.stmts, |l, r| self.eq_stmt(l, r))
62 && both(&left.expr, &right.expr, |l, r| self.eq_expr(l, r))
65 #[allow(clippy::similar_names)]
66 pub fn eq_expr(&mut self, left: &Expr, right: &Expr) -> bool {
67 if self.ignore_fn && differing_macro_contexts(left.span, right.span) {
71 if let (Some(l), Some(r)) = (
72 constant_simple(self.cx, self.tables, left),
73 constant_simple(self.cx, self.tables, right),
80 match (&left.kind, &right.kind) {
81 (&ExprKind::AddrOf(l_mut, ref le), &ExprKind::AddrOf(r_mut, ref re)) => {
82 l_mut == r_mut && self.eq_expr(le, re)
84 (&ExprKind::Continue(li), &ExprKind::Continue(ri)) => {
85 both(&li.label, &ri.label, |l, r| l.ident.as_str() == r.ident.as_str())
87 (&ExprKind::Assign(ref ll, ref lr), &ExprKind::Assign(ref rl, ref rr)) => {
88 self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
90 (&ExprKind::AssignOp(ref lo, ref ll, ref lr), &ExprKind::AssignOp(ref ro, ref rl, ref rr)) => {
91 lo.node == ro.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
93 (&ExprKind::Block(ref l, _), &ExprKind::Block(ref r, _)) => self.eq_block(l, r),
94 (&ExprKind::Binary(l_op, ref ll, ref lr), &ExprKind::Binary(r_op, ref rl, ref rr)) => {
95 l_op.node == r_op.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
96 || swap_binop(l_op.node, ll, lr).map_or(false, |(l_op, ll, lr)| {
97 l_op == r_op.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
100 (&ExprKind::Break(li, ref le), &ExprKind::Break(ri, ref re)) => {
101 both(&li.label, &ri.label, |l, r| l.ident.as_str() == r.ident.as_str())
102 && both(le, re, |l, r| self.eq_expr(l, r))
104 (&ExprKind::Box(ref l), &ExprKind::Box(ref r)) => self.eq_expr(l, r),
105 (&ExprKind::Call(ref l_fun, ref l_args), &ExprKind::Call(ref r_fun, ref r_args)) => {
106 !self.ignore_fn && self.eq_expr(l_fun, r_fun) && self.eq_exprs(l_args, r_args)
108 (&ExprKind::Cast(ref lx, ref lt), &ExprKind::Cast(ref rx, ref rt))
109 | (&ExprKind::Type(ref lx, ref lt), &ExprKind::Type(ref rx, ref rt)) => {
110 self.eq_expr(lx, rx) && self.eq_ty(lt, rt)
112 (&ExprKind::Field(ref l_f_exp, ref l_f_ident), &ExprKind::Field(ref r_f_exp, ref r_f_ident)) => {
113 l_f_ident.name == r_f_ident.name && self.eq_expr(l_f_exp, r_f_exp)
115 (&ExprKind::Index(ref la, ref li), &ExprKind::Index(ref ra, ref ri)) => {
116 self.eq_expr(la, ra) && self.eq_expr(li, ri)
118 (&ExprKind::Lit(ref l), &ExprKind::Lit(ref r)) => l.node == r.node,
119 (&ExprKind::Loop(ref lb, ref ll, ref lls), &ExprKind::Loop(ref rb, ref rl, ref rls)) => {
120 lls == rls && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.ident.as_str() == r.ident.as_str())
122 (&ExprKind::Match(ref le, ref la, ref ls), &ExprKind::Match(ref re, ref ra, ref rs)) => {
124 && self.eq_expr(le, re)
125 && over(la, ra, |l, r| {
126 self.eq_expr(&l.body, &r.body)
127 && both(&l.guard, &r.guard, |l, r| self.eq_guard(l, r))
128 && self.eq_pat(&l.pat, &r.pat)
131 (&ExprKind::MethodCall(ref l_path, _, ref l_args), &ExprKind::MethodCall(ref r_path, _, ref r_args)) => {
132 !self.ignore_fn && self.eq_path_segment(l_path, r_path) && self.eq_exprs(l_args, r_args)
134 (&ExprKind::Repeat(ref le, ref ll_id), &ExprKind::Repeat(ref re, ref rl_id)) => {
135 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body));
136 let ll = celcx.expr(&self.cx.tcx.hir().body(ll_id.body).value);
137 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body));
138 let rl = celcx.expr(&self.cx.tcx.hir().body(rl_id.body).value);
140 self.eq_expr(le, re) && ll == rl
142 (&ExprKind::Ret(ref l), &ExprKind::Ret(ref r)) => both(l, r, |l, r| self.eq_expr(l, r)),
143 (&ExprKind::Path(ref l), &ExprKind::Path(ref r)) => self.eq_qpath(l, r),
144 (&ExprKind::Struct(ref l_path, ref lf, ref lo), &ExprKind::Struct(ref r_path, ref rf, ref ro)) => {
145 self.eq_qpath(l_path, r_path)
146 && both(lo, ro, |l, r| self.eq_expr(l, r))
147 && over(lf, rf, |l, r| self.eq_field(l, r))
149 (&ExprKind::Tup(ref l_tup), &ExprKind::Tup(ref r_tup)) => self.eq_exprs(l_tup, r_tup),
150 (&ExprKind::Unary(l_op, ref le), &ExprKind::Unary(r_op, ref re)) => l_op == r_op && self.eq_expr(le, re),
151 (&ExprKind::Array(ref l), &ExprKind::Array(ref r)) => self.eq_exprs(l, r),
152 (&ExprKind::DropTemps(ref le), &ExprKind::DropTemps(ref re)) => self.eq_expr(le, re),
157 fn eq_exprs(&mut self, left: &P<[Expr]>, right: &P<[Expr]>) -> bool {
158 over(left, right, |l, r| self.eq_expr(l, r))
161 fn eq_field(&mut self, left: &Field, right: &Field) -> bool {
162 left.ident.name == right.ident.name && self.eq_expr(&left.expr, &right.expr)
165 fn eq_guard(&mut self, left: &Guard, right: &Guard) -> bool {
166 match (left, right) {
167 (Guard::If(l), Guard::If(r)) => self.eq_expr(l, r),
171 fn eq_generic_arg(&mut self, left: &GenericArg, right: &GenericArg) -> bool {
172 match (left, right) {
173 (GenericArg::Lifetime(l_lt), GenericArg::Lifetime(r_lt)) => Self::eq_lifetime(l_lt, r_lt),
174 (GenericArg::Type(l_ty), GenericArg::Type(r_ty)) => self.eq_ty(l_ty, r_ty),
179 fn eq_lifetime(left: &Lifetime, right: &Lifetime) -> bool {
180 left.name == right.name
183 /// Checks whether two patterns are the same.
184 pub fn eq_pat(&mut self, left: &Pat, right: &Pat) -> bool {
185 match (&left.kind, &right.kind) {
186 (&PatKind::Box(ref l), &PatKind::Box(ref r)) => self.eq_pat(l, r),
187 (&PatKind::TupleStruct(ref lp, ref la, ls), &PatKind::TupleStruct(ref rp, ref ra, rs)) => {
188 self.eq_qpath(lp, rp) && over(la, ra, |l, r| self.eq_pat(l, r)) && ls == rs
190 (&PatKind::Binding(ref lb, .., ref li, ref lp), &PatKind::Binding(ref rb, .., ref ri, ref rp)) => {
191 lb == rb && li.name.as_str() == ri.name.as_str() && both(lp, rp, |l, r| self.eq_pat(l, r))
193 (&PatKind::Path(ref l), &PatKind::Path(ref r)) => self.eq_qpath(l, r),
194 (&PatKind::Lit(ref l), &PatKind::Lit(ref r)) => self.eq_expr(l, r),
195 (&PatKind::Tuple(ref l, ls), &PatKind::Tuple(ref r, rs)) => {
196 ls == rs && over(l, r, |l, r| self.eq_pat(l, r))
198 (&PatKind::Range(ref ls, ref le, ref li), &PatKind::Range(ref rs, ref re, ref ri)) => {
199 self.eq_expr(ls, rs) && self.eq_expr(le, re) && (*li == *ri)
201 (&PatKind::Ref(ref le, ref lm), &PatKind::Ref(ref re, ref rm)) => lm == rm && self.eq_pat(le, re),
202 (&PatKind::Slice(ref ls, ref li, ref le), &PatKind::Slice(ref rs, ref ri, ref re)) => {
203 over(ls, rs, |l, r| self.eq_pat(l, r))
204 && over(le, re, |l, r| self.eq_pat(l, r))
205 && both(li, ri, |l, r| self.eq_pat(l, r))
207 (&PatKind::Wild, &PatKind::Wild) => true,
212 #[allow(clippy::similar_names)]
213 fn eq_qpath(&mut self, left: &QPath, right: &QPath) -> bool {
214 match (left, right) {
215 (&QPath::Resolved(ref lty, ref lpath), &QPath::Resolved(ref rty, ref rpath)) => {
216 both(lty, rty, |l, r| self.eq_ty(l, r)) && self.eq_path(lpath, rpath)
218 (&QPath::TypeRelative(ref lty, ref lseg), &QPath::TypeRelative(ref rty, ref rseg)) => {
219 self.eq_ty(lty, rty) && self.eq_path_segment(lseg, rseg)
225 fn eq_path(&mut self, left: &Path, right: &Path) -> bool {
226 left.is_global() == right.is_global()
227 && over(&left.segments, &right.segments, |l, r| self.eq_path_segment(l, r))
230 fn eq_path_parameters(&mut self, left: &GenericArgs, right: &GenericArgs) -> bool {
231 if !(left.parenthesized || right.parenthesized) {
232 over(&left.args, &right.args, |l, r| self.eq_generic_arg(l, r)) // FIXME(flip1995): may not work
233 && over(&left.bindings, &right.bindings, |l, r| self.eq_type_binding(l, r))
234 } else if left.parenthesized && right.parenthesized {
235 over(left.inputs(), right.inputs(), |l, r| self.eq_ty(l, r))
236 && both(&Some(&left.bindings[0].ty()), &Some(&right.bindings[0].ty()), |l, r| {
244 pub fn eq_path_segments(&mut self, left: &[PathSegment], right: &[PathSegment]) -> bool {
245 left.len() == right.len() && left.iter().zip(right).all(|(l, r)| self.eq_path_segment(l, r))
248 pub fn eq_path_segment(&mut self, left: &PathSegment, right: &PathSegment) -> bool {
249 // The == of idents doesn't work with different contexts,
250 // we have to be explicit about hygiene
251 if left.ident.as_str() != right.ident.as_str() {
254 match (&left.args, &right.args) {
255 (&None, &None) => true,
256 (&Some(ref l), &Some(ref r)) => self.eq_path_parameters(l, r),
261 pub fn eq_ty(&mut self, left: &Ty, right: &Ty) -> bool {
262 self.eq_ty_kind(&left.kind, &right.kind)
265 #[allow(clippy::similar_names)]
266 pub fn eq_ty_kind(&mut self, left: &TyKind, right: &TyKind) -> bool {
267 match (left, right) {
268 (&TyKind::Slice(ref l_vec), &TyKind::Slice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
269 (&TyKind::Array(ref lt, ref ll_id), &TyKind::Array(ref rt, ref rl_id)) => {
270 let full_table = self.tables;
272 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body));
273 self.tables = self.cx.tcx.body_tables(ll_id.body);
274 let ll = celcx.expr(&self.cx.tcx.hir().body(ll_id.body).value);
276 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body));
277 self.tables = self.cx.tcx.body_tables(rl_id.body);
278 let rl = celcx.expr(&self.cx.tcx.hir().body(rl_id.body).value);
280 let eq_ty = self.eq_ty(lt, rt);
281 self.tables = full_table;
284 (&TyKind::Ptr(ref l_mut), &TyKind::Ptr(ref r_mut)) => {
285 l_mut.mutbl == r_mut.mutbl && self.eq_ty(&*l_mut.ty, &*r_mut.ty)
287 (&TyKind::Rptr(_, ref l_rmut), &TyKind::Rptr(_, ref r_rmut)) => {
288 l_rmut.mutbl == r_rmut.mutbl && self.eq_ty(&*l_rmut.ty, &*r_rmut.ty)
290 (&TyKind::Path(ref l), &TyKind::Path(ref r)) => self.eq_qpath(l, r),
291 (&TyKind::Tup(ref l), &TyKind::Tup(ref r)) => over(l, r, |l, r| self.eq_ty(l, r)),
292 (&TyKind::Infer, &TyKind::Infer) => true,
297 fn eq_type_binding(&mut self, left: &TypeBinding, right: &TypeBinding) -> bool {
298 left.ident.name == right.ident.name && self.eq_ty(&left.ty(), &right.ty())
302 fn swap_binop<'a>(binop: BinOpKind, lhs: &'a Expr, rhs: &'a Expr) -> Option<(BinOpKind, &'a Expr, &'a Expr)> {
310 | BinOpKind::BitOr => Some((binop, rhs, lhs)),
311 BinOpKind::Lt => Some((BinOpKind::Gt, rhs, lhs)),
312 BinOpKind::Le => Some((BinOpKind::Ge, rhs, lhs)),
313 BinOpKind::Ge => Some((BinOpKind::Le, rhs, lhs)),
314 BinOpKind::Gt => Some((BinOpKind::Lt, rhs, lhs)),
321 | BinOpKind::Or => None,
325 /// Checks if the two `Option`s are both `None` or some equal values as per
327 fn both<X, F>(l: &Option<X>, r: &Option<X>, mut eq_fn: F) -> bool
329 F: FnMut(&X, &X) -> bool,
332 .map_or_else(|| r.is_none(), |x| r.as_ref().map_or(false, |y| eq_fn(x, y)))
335 /// Checks if two slices are equal as per `eq_fn`.
336 fn over<X, F>(left: &[X], right: &[X], mut eq_fn: F) -> bool
338 F: FnMut(&X, &X) -> bool,
340 left.len() == right.len() && left.iter().zip(right).all(|(x, y)| eq_fn(x, y))
343 /// Type used to hash an ast element. This is different from the `Hash` trait
344 /// on ast types as this
345 /// trait would consider IDs and spans.
347 /// All expressions kind are hashed, but some might have a weaker hash.
348 pub struct SpanlessHash<'a, 'tcx> {
349 /// Context used to evaluate constant expressions.
350 cx: &'a LateContext<'a, 'tcx>,
351 tables: &'a TypeckTables<'tcx>,
355 impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
356 pub fn new(cx: &'a LateContext<'a, 'tcx>, tables: &'a TypeckTables<'tcx>) -> Self {
360 s: StableHasher::new(),
364 pub fn finish(self) -> u64 {
368 pub fn hash_block(&mut self, b: &Block) {
373 if let Some(ref e) = b.expr {
378 BlockCheckMode::DefaultBlock => 0,
379 BlockCheckMode::UnsafeBlock(_) => 1,
380 BlockCheckMode::PushUnsafeBlock(_) => 2,
381 BlockCheckMode::PopUnsafeBlock(_) => 3,
386 #[allow(clippy::many_single_char_names, clippy::too_many_lines)]
387 pub fn hash_expr(&mut self, e: &Expr) {
388 let simple_const = constant_simple(self.cx, self.tables, e);
390 // const hashing may result in the same hash as some unrelated node, so add a sort of
391 // discriminant depending on which path we're choosing next
392 simple_const.is_some().hash(&mut self.s);
394 if let Some(e) = simple_const {
395 return e.hash(&mut self.s);
398 std::mem::discriminant(&e.kind).hash(&mut self.s);
401 ExprKind::AddrOf(m, ref e) => {
405 ExprKind::Continue(i) => {
406 if let Some(i) = i.label {
407 self.hash_name(i.ident.name);
410 ExprKind::Assign(ref l, ref r) => {
414 ExprKind::AssignOp(ref o, ref l, ref r) => {
416 .hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
420 ExprKind::Block(ref b, _) => {
423 ExprKind::Binary(op, ref l, ref r) => {
425 .hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
429 ExprKind::Break(i, ref j) => {
430 if let Some(i) = i.label {
431 self.hash_name(i.ident.name);
433 if let Some(ref j) = *j {
437 ExprKind::Box(ref e) | ExprKind::DropTemps(ref e) | ExprKind::Yield(ref e, _) => {
440 ExprKind::Call(ref fun, ref args) => {
442 self.hash_exprs(args);
444 ExprKind::Cast(ref e, ref ty) | ExprKind::Type(ref e, ref ty) => {
448 ExprKind::Closure(cap, _, eid, _, _) => {
450 CaptureClause::CaptureByValue => 0,
451 CaptureClause::CaptureByRef => 1,
454 // closures inherit TypeckTables
455 self.hash_expr(&self.cx.tcx.hir().body(eid).value);
457 ExprKind::Field(ref e, ref f) => {
459 self.hash_name(f.name);
461 ExprKind::Index(ref a, ref i) => {
465 ExprKind::InlineAsm(..) | ExprKind::Err => {},
466 ExprKind::Lit(ref l) => {
467 l.node.hash(&mut self.s);
469 ExprKind::Loop(ref b, ref i, _) => {
471 if let Some(i) = *i {
472 self.hash_name(i.ident.name);
475 ExprKind::Match(ref e, ref arms, ref s) => {
480 if let Some(ref e) = arm.guard {
483 self.hash_expr(&arm.body);
488 ExprKind::MethodCall(ref path, ref _tys, ref args) => {
489 self.hash_name(path.ident.name);
490 self.hash_exprs(args);
492 ExprKind::Repeat(ref e, ref l_id) => {
494 self.hash_body(l_id.body);
496 ExprKind::Ret(ref e) => {
497 if let Some(ref e) = *e {
501 ExprKind::Path(ref qpath) => {
502 self.hash_qpath(qpath);
504 ExprKind::Struct(ref path, ref fields, ref expr) => {
505 self.hash_qpath(path);
508 self.hash_name(f.ident.name);
509 self.hash_expr(&f.expr);
512 if let Some(ref e) = *expr {
516 ExprKind::Tup(ref tup) => {
517 self.hash_exprs(tup);
519 ExprKind::Array(ref v) => {
522 ExprKind::Unary(lop, ref le) => {
523 lop.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
529 pub fn hash_exprs(&mut self, e: &P<[Expr]>) {
535 pub fn hash_name(&mut self, n: Name) {
536 n.as_str().hash(&mut self.s);
539 pub fn hash_qpath(&mut self, p: &QPath) {
541 QPath::Resolved(_, ref path) => {
542 self.hash_path(path);
544 QPath::TypeRelative(_, ref path) => {
545 self.hash_name(path.ident.name);
548 // self.cx.tables.qpath_res(p, id).hash(&mut self.s);
551 pub fn hash_path(&mut self, p: &Path) {
552 p.is_global().hash(&mut self.s);
553 for p in &p.segments {
554 self.hash_name(p.ident.name);
558 pub fn hash_stmt(&mut self, b: &Stmt) {
559 std::mem::discriminant(&b.kind).hash(&mut self.s);
562 StmtKind::Local(local) => {
563 if let Some(ref init) = local.init {
564 self.hash_expr(init);
567 StmtKind::Item(..) => {},
568 StmtKind::Expr(expr) | StmtKind::Semi(expr) => {
569 self.hash_expr(expr);
574 pub fn hash_guard(&mut self, g: &Guard) {
576 Guard::If(ref expr) => {
577 self.hash_expr(expr);
582 pub fn hash_lifetime(&mut self, lifetime: &Lifetime) {
583 std::mem::discriminant(&lifetime.name).hash(&mut self.s);
584 if let LifetimeName::Param(ref name) = lifetime.name {
585 std::mem::discriminant(name).hash(&mut self.s);
587 ParamName::Plain(ref ident) => {
588 ident.name.hash(&mut self.s);
590 ParamName::Fresh(ref size) => {
591 size.hash(&mut self.s);
593 ParamName::Error => {},
598 pub fn hash_ty(&mut self, ty: &Ty) {
599 self.hash_tykind(&ty.kind);
602 pub fn hash_tykind(&mut self, ty: &TyKind) {
603 std::mem::discriminant(ty).hash(&mut self.s);
605 TyKind::Slice(ty) => {
608 TyKind::Array(ty, anon_const) => {
610 self.hash_body(anon_const.body);
612 TyKind::Ptr(mut_ty) => {
613 self.hash_ty(&mut_ty.ty);
614 mut_ty.mutbl.hash(&mut self.s);
616 TyKind::Rptr(lifetime, mut_ty) => {
617 self.hash_lifetime(lifetime);
618 self.hash_ty(&mut_ty.ty);
619 mut_ty.mutbl.hash(&mut self.s);
621 TyKind::BareFn(bfn) => {
622 bfn.unsafety.hash(&mut self.s);
623 bfn.abi.hash(&mut self.s);
624 for arg in &bfn.decl.inputs {
627 match bfn.decl.output {
628 FunctionRetTy::DefaultReturn(_) => {
629 ().hash(&mut self.s);
631 FunctionRetTy::Return(ref ty) => {
635 bfn.decl.c_variadic.hash(&mut self.s);
637 TyKind::Tup(ty_list) => {
642 TyKind::Path(qpath) => match qpath {
643 QPath::Resolved(ref maybe_ty, ref path) => {
644 if let Some(ref ty) = maybe_ty {
647 for segment in &path.segments {
648 segment.ident.name.hash(&mut self.s);
651 QPath::TypeRelative(ref ty, ref segment) => {
653 segment.ident.name.hash(&mut self.s);
656 TyKind::Def(_, arg_list) => {
657 for arg in arg_list {
659 GenericArg::Lifetime(ref l) => self.hash_lifetime(l),
660 GenericArg::Type(ref ty) => self.hash_ty(&ty),
661 GenericArg::Const(ref ca) => self.hash_body(ca.value.body),
665 TyKind::TraitObject(_, lifetime) => {
666 self.hash_lifetime(lifetime);
668 TyKind::Typeof(anon_const) => {
669 self.hash_body(anon_const.body);
671 TyKind::Err | TyKind::Infer | TyKind::Never => {},
675 pub fn hash_body(&mut self, body_id: BodyId) {
676 // swap out TypeckTables when hashing a body
677 let old_tables = self.tables;
678 self.tables = self.cx.tcx.body_tables(body_id);
679 self.hash_expr(&self.cx.tcx.hir().body(body_id).value);
680 self.tables = old_tables;