1 use crate::consts::{constant_context, constant_simple};
2 use crate::utils::differing_macro_contexts;
3 use rustc::hir::ptr::P;
5 use rustc::lint::LateContext;
6 use rustc::ty::TypeckTables;
7 use std::collections::hash_map::DefaultHasher;
8 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> {
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> 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.kind, &right.kind) {
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.kind, &right.kind) {
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::Lit(ref l), &ExprKind::Lit(ref r)) => l.node == r.node,
118 (&ExprKind::Loop(ref lb, ref ll, ref lls), &ExprKind::Loop(ref rb, ref rl, ref rls)) => {
119 lls == rls && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.ident.as_str() == r.ident.as_str())
121 (&ExprKind::Match(ref le, ref la, ref ls), &ExprKind::Match(ref re, ref ra, ref rs)) => {
123 && self.eq_expr(le, re)
124 && over(la, ra, |l, r| {
125 self.eq_expr(&l.body, &r.body)
126 && both(&l.guard, &r.guard, |l, r| self.eq_guard(l, r))
127 && self.eq_pat(&l.pat, &r.pat)
130 (&ExprKind::MethodCall(ref l_path, _, ref l_args), &ExprKind::MethodCall(ref r_path, _, ref r_args)) => {
131 !self.ignore_fn && self.eq_path_segment(l_path, r_path) && self.eq_exprs(l_args, r_args)
133 (&ExprKind::Repeat(ref le, ref ll_id), &ExprKind::Repeat(ref re, ref rl_id)) => {
134 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body));
135 let ll = celcx.expr(&self.cx.tcx.hir().body(ll_id.body).value);
136 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body));
137 let rl = celcx.expr(&self.cx.tcx.hir().body(rl_id.body).value);
139 self.eq_expr(le, re) && ll == rl
141 (&ExprKind::Ret(ref l), &ExprKind::Ret(ref r)) => both(l, r, |l, r| self.eq_expr(l, r)),
142 (&ExprKind::Path(ref l), &ExprKind::Path(ref r)) => self.eq_qpath(l, r),
143 (&ExprKind::Struct(ref l_path, ref lf, ref lo), &ExprKind::Struct(ref r_path, ref rf, ref ro)) => {
144 self.eq_qpath(l_path, r_path)
145 && both(lo, ro, |l, r| self.eq_expr(l, r))
146 && over(lf, rf, |l, r| self.eq_field(l, r))
148 (&ExprKind::Tup(ref l_tup), &ExprKind::Tup(ref r_tup)) => self.eq_exprs(l_tup, r_tup),
149 (&ExprKind::Unary(l_op, ref le), &ExprKind::Unary(r_op, ref re)) => l_op == r_op && self.eq_expr(le, re),
150 (&ExprKind::Array(ref l), &ExprKind::Array(ref r)) => self.eq_exprs(l, r),
151 (&ExprKind::DropTemps(ref le), &ExprKind::DropTemps(ref re)) => self.eq_expr(le, re),
156 fn eq_exprs(&mut self, left: &P<[Expr]>, right: &P<[Expr]>) -> bool {
157 over(left, right, |l, r| self.eq_expr(l, r))
160 fn eq_field(&mut self, left: &Field, right: &Field) -> bool {
161 left.ident.name == right.ident.name && self.eq_expr(&left.expr, &right.expr)
164 fn eq_guard(&mut self, left: &Guard, right: &Guard) -> bool {
165 match (left, right) {
166 (Guard::If(l), Guard::If(r)) => self.eq_expr(l, r),
170 fn eq_generic_arg(&mut self, left: &GenericArg, right: &GenericArg) -> bool {
171 match (left, right) {
172 (GenericArg::Lifetime(l_lt), GenericArg::Lifetime(r_lt)) => Self::eq_lifetime(l_lt, r_lt),
173 (GenericArg::Type(l_ty), GenericArg::Type(r_ty)) => self.eq_ty(l_ty, r_ty),
178 fn eq_lifetime(left: &Lifetime, right: &Lifetime) -> bool {
179 left.name == right.name
182 /// Checks whether two patterns are the same.
183 pub fn eq_pat(&mut self, left: &Pat, right: &Pat) -> bool {
184 match (&left.kind, &right.kind) {
185 (&PatKind::Box(ref l), &PatKind::Box(ref r)) => self.eq_pat(l, r),
186 (&PatKind::TupleStruct(ref lp, ref la, ls), &PatKind::TupleStruct(ref rp, ref ra, rs)) => {
187 self.eq_qpath(lp, rp) && over(la, ra, |l, r| self.eq_pat(l, r)) && ls == rs
189 (&PatKind::Binding(ref lb, .., ref li, ref lp), &PatKind::Binding(ref rb, .., ref ri, ref rp)) => {
190 lb == rb && li.name.as_str() == ri.name.as_str() && both(lp, rp, |l, r| self.eq_pat(l, r))
192 (&PatKind::Path(ref l), &PatKind::Path(ref r)) => self.eq_qpath(l, r),
193 (&PatKind::Lit(ref l), &PatKind::Lit(ref r)) => self.eq_expr(l, r),
194 (&PatKind::Tuple(ref l, ls), &PatKind::Tuple(ref r, rs)) => {
195 ls == rs && over(l, r, |l, r| self.eq_pat(l, r))
197 (&PatKind::Range(ref ls, ref le, ref li), &PatKind::Range(ref rs, ref re, ref ri)) => {
198 self.eq_expr(ls, rs) && self.eq_expr(le, re) && (*li == *ri)
200 (&PatKind::Ref(ref le, ref lm), &PatKind::Ref(ref re, ref rm)) => lm == rm && self.eq_pat(le, re),
201 (&PatKind::Slice(ref ls, ref li, ref le), &PatKind::Slice(ref rs, ref ri, ref re)) => {
202 over(ls, rs, |l, r| self.eq_pat(l, r))
203 && over(le, re, |l, r| self.eq_pat(l, r))
204 && both(li, ri, |l, r| self.eq_pat(l, r))
206 (&PatKind::Wild, &PatKind::Wild) => true,
211 #[allow(clippy::similar_names)]
212 fn eq_qpath(&mut self, left: &QPath, right: &QPath) -> bool {
213 match (left, right) {
214 (&QPath::Resolved(ref lty, ref lpath), &QPath::Resolved(ref rty, ref rpath)) => {
215 both(lty, rty, |l, r| self.eq_ty(l, r)) && self.eq_path(lpath, rpath)
217 (&QPath::TypeRelative(ref lty, ref lseg), &QPath::TypeRelative(ref rty, ref rseg)) => {
218 self.eq_ty(lty, rty) && self.eq_path_segment(lseg, rseg)
224 fn eq_path(&mut self, left: &Path, right: &Path) -> bool {
225 left.is_global() == right.is_global()
226 && over(&left.segments, &right.segments, |l, r| self.eq_path_segment(l, r))
229 fn eq_path_parameters(&mut self, left: &GenericArgs, right: &GenericArgs) -> bool {
230 if !(left.parenthesized || right.parenthesized) {
231 over(&left.args, &right.args, |l, r| self.eq_generic_arg(l, r)) // FIXME(flip1995): may not work
232 && over(&left.bindings, &right.bindings, |l, r| self.eq_type_binding(l, r))
233 } else if left.parenthesized && right.parenthesized {
234 over(left.inputs(), right.inputs(), |l, r| self.eq_ty(l, r))
235 && both(&Some(&left.bindings[0].ty()), &Some(&right.bindings[0].ty()), |l, r| {
243 pub fn eq_path_segments(&mut self, left: &[PathSegment], right: &[PathSegment]) -> bool {
244 left.len() == right.len() && left.iter().zip(right).all(|(l, r)| self.eq_path_segment(l, r))
247 pub fn eq_path_segment(&mut self, left: &PathSegment, right: &PathSegment) -> bool {
248 // The == of idents doesn't work with different contexts,
249 // we have to be explicit about hygiene
250 if left.ident.as_str() != right.ident.as_str() {
253 match (&left.args, &right.args) {
254 (&None, &None) => true,
255 (&Some(ref l), &Some(ref r)) => self.eq_path_parameters(l, r),
260 pub fn eq_ty(&mut self, left: &Ty, right: &Ty) -> bool {
261 self.eq_ty_kind(&left.kind, &right.kind)
264 #[allow(clippy::similar_names)]
265 pub fn eq_ty_kind(&mut self, left: &TyKind, right: &TyKind) -> bool {
266 match (left, right) {
267 (&TyKind::Slice(ref l_vec), &TyKind::Slice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
268 (&TyKind::Array(ref lt, ref ll_id), &TyKind::Array(ref rt, ref rl_id)) => {
269 let full_table = self.tables;
271 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body));
272 self.tables = self.cx.tcx.body_tables(ll_id.body);
273 let ll = celcx.expr(&self.cx.tcx.hir().body(ll_id.body).value);
275 let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body));
276 self.tables = self.cx.tcx.body_tables(rl_id.body);
277 let rl = celcx.expr(&self.cx.tcx.hir().body(rl_id.body).value);
279 let eq_ty = self.eq_ty(lt, rt);
280 self.tables = full_table;
283 (&TyKind::Ptr(ref l_mut), &TyKind::Ptr(ref r_mut)) => {
284 l_mut.mutbl == r_mut.mutbl && self.eq_ty(&*l_mut.ty, &*r_mut.ty)
286 (&TyKind::Rptr(_, ref l_rmut), &TyKind::Rptr(_, ref r_rmut)) => {
287 l_rmut.mutbl == r_rmut.mutbl && self.eq_ty(&*l_rmut.ty, &*r_rmut.ty)
289 (&TyKind::Path(ref l), &TyKind::Path(ref r)) => self.eq_qpath(l, r),
290 (&TyKind::Tup(ref l), &TyKind::Tup(ref r)) => over(l, r, |l, r| self.eq_ty(l, r)),
291 (&TyKind::Infer, &TyKind::Infer) => true,
296 fn eq_type_binding(&mut self, left: &TypeBinding, right: &TypeBinding) -> bool {
297 left.ident.name == right.ident.name && self.eq_ty(&left.ty(), &right.ty())
301 fn swap_binop<'a>(binop: BinOpKind, lhs: &'a Expr, rhs: &'a Expr) -> Option<(BinOpKind, &'a Expr, &'a Expr)> {
309 | BinOpKind::BitOr => Some((binop, rhs, lhs)),
310 BinOpKind::Lt => Some((BinOpKind::Gt, rhs, lhs)),
311 BinOpKind::Le => Some((BinOpKind::Ge, rhs, lhs)),
312 BinOpKind::Ge => Some((BinOpKind::Le, rhs, lhs)),
313 BinOpKind::Gt => Some((BinOpKind::Lt, rhs, lhs)),
320 | BinOpKind::Or => None,
324 /// Checks if the two `Option`s are both `None` or some equal values as per
326 fn both<X, F>(l: &Option<X>, r: &Option<X>, mut eq_fn: F) -> bool
328 F: FnMut(&X, &X) -> bool,
331 .map_or_else(|| r.is_none(), |x| r.as_ref().map_or(false, |y| eq_fn(x, y)))
334 /// Checks if two slices are equal as per `eq_fn`.
335 fn over<X, F>(left: &[X], right: &[X], mut eq_fn: F) -> bool
337 F: FnMut(&X, &X) -> bool,
339 left.len() == right.len() && left.iter().zip(right).all(|(x, y)| eq_fn(x, y))
342 /// Type used to hash an ast element. This is different from the `Hash` trait
343 /// on ast types as this
344 /// trait would consider IDs and spans.
346 /// All expressions kind are hashed, but some might have a weaker hash.
347 pub struct SpanlessHash<'a, 'tcx> {
348 /// Context used to evaluate constant expressions.
349 cx: &'a LateContext<'a, 'tcx>,
350 tables: &'a TypeckTables<'tcx>,
354 impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
355 pub fn new(cx: &'a LateContext<'a, 'tcx>, tables: &'a TypeckTables<'tcx>) -> Self {
359 s: DefaultHasher::new(),
363 pub fn finish(&self) -> u64 {
367 pub fn hash_block(&mut self, b: &Block) {
372 if let Some(ref e) = b.expr {
377 BlockCheckMode::DefaultBlock => 0,
378 BlockCheckMode::UnsafeBlock(_) => 1,
379 BlockCheckMode::PushUnsafeBlock(_) => 2,
380 BlockCheckMode::PopUnsafeBlock(_) => 3,
385 #[allow(clippy::many_single_char_names, clippy::too_many_lines)]
386 pub fn hash_expr(&mut self, e: &Expr) {
387 let simple_const = constant_simple(self.cx, self.tables, e);
389 // const hashing may result in the same hash as some unrelated node, so add a sort of
390 // discriminant depending on which path we're choosing next
391 simple_const.is_some().hash(&mut self.s);
393 if let Some(e) = simple_const {
394 return e.hash(&mut self.s);
397 std::mem::discriminant(&e.kind).hash(&mut self.s);
400 ExprKind::AddrOf(m, ref e) => {
404 ExprKind::Continue(i) => {
405 if let Some(i) = i.label {
406 self.hash_name(i.ident.name);
409 ExprKind::Assign(ref l, ref r) => {
413 ExprKind::AssignOp(ref o, ref l, ref r) => {
414 o.node.hash(&mut self.s);
418 ExprKind::Block(ref b, _) => {
421 ExprKind::Binary(op, ref l, ref r) => {
422 op.node.hash(&mut self.s);
426 ExprKind::Break(i, ref j) => {
427 if let Some(i) = i.label {
428 self.hash_name(i.ident.name);
430 if let Some(ref j) = *j {
434 ExprKind::Box(ref e) | ExprKind::DropTemps(ref e) | ExprKind::Yield(ref e, _) => {
437 ExprKind::Call(ref fun, ref args) => {
439 self.hash_exprs(args);
441 ExprKind::Cast(ref e, ref ty) | ExprKind::Type(ref e, ref ty) => {
445 ExprKind::Closure(cap, _, eid, _, _) => {
447 CaptureClause::CaptureByValue => 0,
448 CaptureClause::CaptureByRef => 1,
451 self.hash_expr(&self.cx.tcx.hir().body(eid).value);
453 ExprKind::Field(ref e, ref f) => {
455 self.hash_name(f.name);
457 ExprKind::Index(ref a, ref i) => {
461 ExprKind::InlineAsm(..) | ExprKind::Err => {},
462 ExprKind::Lit(ref l) => {
463 l.node.hash(&mut self.s);
465 ExprKind::Loop(ref b, ref i, _) => {
467 if let Some(i) = *i {
468 self.hash_name(i.ident.name);
471 ExprKind::Match(ref e, ref arms, ref s) => {
476 if let Some(ref e) = arm.guard {
479 self.hash_expr(&arm.body);
484 ExprKind::MethodCall(ref path, ref _tys, ref args) => {
485 self.hash_name(path.ident.name);
486 self.hash_exprs(args);
488 ExprKind::Repeat(ref e, ref l_id) => {
490 let full_table = self.tables;
491 self.tables = self.cx.tcx.body_tables(l_id.body);
492 self.hash_expr(&self.cx.tcx.hir().body(l_id.body).value);
493 self.tables = full_table;
495 ExprKind::Ret(ref e) => {
496 if let Some(ref e) = *e {
500 ExprKind::Path(ref qpath) => {
501 self.hash_qpath(qpath);
503 ExprKind::Struct(ref path, ref fields, ref expr) => {
504 self.hash_qpath(path);
507 self.hash_name(f.ident.name);
508 self.hash_expr(&f.expr);
511 if let Some(ref e) = *expr {
515 ExprKind::Tup(ref tup) => {
516 self.hash_exprs(tup);
518 ExprKind::Array(ref v) => {
521 ExprKind::Unary(lop, ref le) => {
522 lop.hash(&mut self.s);
528 pub fn hash_exprs(&mut self, e: &P<[Expr]>) {
534 pub fn hash_name(&mut self, n: Name) {
535 n.as_str().hash(&mut self.s);
538 pub fn hash_qpath(&mut self, p: &QPath) {
540 QPath::Resolved(_, ref path) => {
541 self.hash_path(path);
543 QPath::TypeRelative(_, ref path) => {
544 self.hash_name(path.ident.name);
547 // self.cx.tables.qpath_res(p, id).hash(&mut self.s);
550 pub fn hash_path(&mut self, p: &Path) {
551 p.is_global().hash(&mut self.s);
552 for p in &p.segments {
553 self.hash_name(p.ident.name);
557 pub fn hash_stmt(&mut self, b: &Stmt) {
558 std::mem::discriminant(&b.kind).hash(&mut self.s);
561 StmtKind::Local(local) => {
562 if let Some(ref init) = local.init {
563 self.hash_expr(init);
566 StmtKind::Item(..) => {},
567 StmtKind::Expr(expr) | StmtKind::Semi(expr) => {
568 self.hash_expr(expr);
573 pub fn hash_guard(&mut self, g: &Guard) {
575 Guard::If(ref expr) => {
576 self.hash_expr(expr);
581 pub fn hash_lifetime(&mut self, lifetime: &Lifetime) {
582 std::mem::discriminant(&lifetime.name).hash(&mut self.s);
583 if let LifetimeName::Param(ref name) = lifetime.name {
584 std::mem::discriminant(name).hash(&mut self.s);
586 ParamName::Plain(ref ident) => {
587 ident.name.hash(&mut self.s);
589 ParamName::Fresh(ref size) => {
590 size.hash(&mut self.s);
592 ParamName::Error => {},
597 pub fn hash_ty(&mut self, ty: &Ty) {
598 self.hash_tykind(&ty.kind);
601 pub fn hash_tykind(&mut self, ty: &TyKind) {
602 std::mem::discriminant(ty).hash(&mut self.s);
604 TyKind::Slice(ty) => {
607 TyKind::Array(ty, anon_const) => {
609 self.hash_expr(&self.cx.tcx.hir().body(anon_const.body).value);
611 TyKind::Ptr(mut_ty) => {
612 self.hash_ty(&mut_ty.ty);
613 mut_ty.mutbl.hash(&mut self.s);
615 TyKind::Rptr(lifetime, mut_ty) => {
616 self.hash_lifetime(lifetime);
617 self.hash_ty(&mut_ty.ty);
618 mut_ty.mutbl.hash(&mut self.s);
620 TyKind::BareFn(bfn) => {
621 bfn.unsafety.hash(&mut self.s);
622 bfn.abi.hash(&mut self.s);
623 for arg in &bfn.decl.inputs {
626 match bfn.decl.output {
627 FunctionRetTy::DefaultReturn(_) => {
628 ().hash(&mut self.s);
630 FunctionRetTy::Return(ref ty) => {
634 bfn.decl.c_variadic.hash(&mut self.s);
636 TyKind::Tup(ty_list) => {
641 TyKind::Path(qpath) => match qpath {
642 QPath::Resolved(ref maybe_ty, ref path) => {
643 if let Some(ref ty) = maybe_ty {
646 for segment in &path.segments {
647 segment.ident.name.hash(&mut self.s);
650 QPath::TypeRelative(ref ty, ref segment) => {
652 segment.ident.name.hash(&mut self.s);
655 TyKind::Def(_, arg_list) => {
656 for arg in arg_list {
658 GenericArg::Lifetime(ref l) => self.hash_lifetime(l),
659 GenericArg::Type(ref ty) => self.hash_ty(&ty),
660 GenericArg::Const(ref ca) => {
661 self.hash_expr(&self.cx.tcx.hir().body(ca.value.body).value);
666 TyKind::TraitObject(_, lifetime) => {
667 self.hash_lifetime(lifetime);
669 TyKind::Typeof(anon_const) => {
670 self.hash_expr(&self.cx.tcx.hir().body(anon_const.body).value);
672 TyKind::Err | TyKind::Infer | TyKind::Never => {},