@@ -36,6 +36,7 @@ impl<'tcx> Const<'tcx> {
3636 Self :: from_opt_const_arg_anon_const ( tcx, ty:: WithOptConstParam :: unknown ( def_id) )
3737 }
3838
39+ #[ instrument( skip( tcx) , level = "debug" ) ]
3940 pub fn from_opt_const_arg_anon_const (
4041 tcx : TyCtxt < ' tcx > ,
4142 def : ty:: WithOptConstParam < LocalDefId > ,
@@ -53,6 +54,7 @@ impl<'tcx> Const<'tcx> {
5354 } ;
5455
5556 let expr = & tcx. hir ( ) . body ( body_id) . value ;
57+ debug ! ( ?expr) ;
5658
5759 let ty = tcx. type_of ( def. def_id_for_type_of ( ) ) ;
5860
@@ -69,11 +71,21 @@ impl<'tcx> Const<'tcx> {
6971 }
7072 }
7173
74+ #[ instrument( skip( tcx) , level = "debug" ) ]
7275 fn try_eval_lit_or_param (
7376 tcx : TyCtxt < ' tcx > ,
7477 ty : Ty < ' tcx > ,
7578 expr : & ' tcx hir:: Expr < ' tcx > ,
7679 ) -> 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+
7789 let lit_input = match expr. kind {
7890 hir:: ExprKind :: Lit ( ref lit) => Some ( LitToConstInput { lit : & lit. node , ty, neg : false } ) ,
7991 hir:: ExprKind :: Unary ( hir:: UnOp :: Neg , ref expr) => match expr. kind {
@@ -95,15 +107,6 @@ impl<'tcx> Const<'tcx> {
95107 }
96108 }
97109
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-
107110 use hir:: { def:: DefKind :: ConstParam , def:: Res , ExprKind , Path , QPath } ;
108111 match expr. kind {
109112 ExprKind :: Path ( QPath :: Resolved ( _, & Path { res : Res :: Def ( ConstParam , def_id) , .. } ) ) => {
0 commit comments