@@ -36,6 +36,7 @@ impl<'tcx> Const<'tcx> {
36
36
Self :: from_opt_const_arg_anon_const ( tcx, ty:: WithOptConstParam :: unknown ( def_id) )
37
37
}
38
38
39
+ #[ instrument( skip( tcx) , level = "debug" ) ]
39
40
pub fn from_opt_const_arg_anon_const (
40
41
tcx : TyCtxt < ' tcx > ,
41
42
def : ty:: WithOptConstParam < LocalDefId > ,
@@ -53,6 +54,7 @@ impl<'tcx> Const<'tcx> {
53
54
} ;
54
55
55
56
let expr = & tcx. hir ( ) . body ( body_id) . value ;
57
+ debug ! ( ?expr) ;
56
58
57
59
let ty = tcx. type_of ( def. def_id_for_type_of ( ) ) ;
58
60
@@ -69,11 +71,21 @@ impl<'tcx> Const<'tcx> {
69
71
}
70
72
}
71
73
74
+ #[ instrument( skip( tcx) , level = "debug" ) ]
72
75
fn try_eval_lit_or_param (
73
76
tcx : TyCtxt < ' tcx > ,
74
77
ty : Ty < ' tcx > ,
75
78
expr : & ' tcx hir:: Expr < ' tcx > ,
76
79
) -> Option < & ' tcx Self > {
80
+ // Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments
81
+ // currently have to be wrapped in curly brackets, so it's necessary to special-case.
82
+ let expr = match & expr. kind {
83
+ hir:: ExprKind :: Block ( block, _) if block. stmts . is_empty ( ) && block. expr . is_some ( ) => {
84
+ block. expr . as_ref ( ) . unwrap ( )
85
+ }
86
+ _ => expr,
87
+ } ;
88
+
77
89
let lit_input = match expr. kind {
78
90
hir:: ExprKind :: Lit ( ref lit) => Some ( LitToConstInput { lit : & lit. node , ty, neg : false } ) ,
79
91
hir:: ExprKind :: Unary ( hir:: UnOp :: Neg , ref expr) => match expr. kind {
@@ -95,15 +107,6 @@ impl<'tcx> Const<'tcx> {
95
107
}
96
108
}
97
109
98
- // Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments
99
- // currently have to be wrapped in curly brackets, so it's necessary to special-case.
100
- let expr = match & expr. kind {
101
- hir:: ExprKind :: Block ( block, _) if block. stmts . is_empty ( ) && block. expr . is_some ( ) => {
102
- block. expr . as_ref ( ) . unwrap ( )
103
- }
104
- _ => expr,
105
- } ;
106
-
107
110
use hir:: { def:: DefKind :: ConstParam , def:: Res , ExprKind , Path , QPath } ;
108
111
match expr. kind {
109
112
ExprKind :: Path ( QPath :: Resolved ( _, & Path { res : Res :: Def ( ConstParam , def_id) , .. } ) ) => {
0 commit comments