@@ -1623,6 +1623,14 @@ pub struct AnonConst {
1623
1623
pub span : Span ,
1624
1624
}
1625
1625
1626
+ /// An inline constant expression `const { something }`.
1627
+ #[ derive( Copy , Clone , Debug , HashStable_Generic ) ]
1628
+ pub struct ConstBlock {
1629
+ pub hir_id : HirId ,
1630
+ pub def_id : LocalDefId ,
1631
+ pub body : BodyId ,
1632
+ }
1633
+
1626
1634
/// An expression.
1627
1635
#[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
1628
1636
pub struct Expr < ' hir > {
@@ -1909,7 +1917,7 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool {
1909
1917
#[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
1910
1918
pub enum ExprKind < ' hir > {
1911
1919
/// Allow anonymous constants from an inline `const` block
1912
- ConstBlock ( & ' hir Expr < ' hir > ) ,
1920
+ ConstBlock ( ConstBlock ) ,
1913
1921
/// An array (e.g., `[a, b, c, d]`).
1914
1922
Array ( & ' hir [ Expr < ' hir > ] ) ,
1915
1923
/// A function call.
@@ -3641,6 +3649,7 @@ pub enum Node<'hir> {
3641
3649
Variant ( & ' hir Variant < ' hir > ) ,
3642
3650
Field ( & ' hir FieldDef < ' hir > ) ,
3643
3651
AnonConst ( & ' hir AnonConst ) ,
3652
+ ConstBlock ( & ' hir ConstBlock ) ,
3644
3653
Expr ( & ' hir Expr < ' hir > ) ,
3645
3654
ExprField ( & ' hir ExprField < ' hir > ) ,
3646
3655
Stmt ( & ' hir Stmt < ' hir > ) ,
@@ -3701,6 +3710,7 @@ impl<'hir> Node<'hir> {
3701
3710
Node :: PreciseCapturingNonLifetimeArg ( a) => Some ( a. ident ) ,
3702
3711
Node :: Param ( ..)
3703
3712
| Node :: AnonConst ( ..)
3713
+ | Node :: ConstBlock ( ..)
3704
3714
| Node :: Expr ( ..)
3705
3715
| Node :: Stmt ( ..)
3706
3716
| Node :: Block ( ..)
@@ -3798,6 +3808,7 @@ impl<'hir> Node<'hir> {
3798
3808
}
3799
3809
3800
3810
Node :: AnonConst ( constant) => Some ( ( constant. def_id , constant. body ) ) ,
3811
+ Node :: ConstBlock ( constant) => Some ( ( constant. def_id , constant. body ) ) ,
3801
3812
3802
3813
_ => None ,
3803
3814
}
@@ -3866,6 +3877,7 @@ impl<'hir> Node<'hir> {
3866
3877
expect_variant, & ' hir Variant <' hir>, Node :: Variant ( n) , n;
3867
3878
expect_field, & ' hir FieldDef <' hir>, Node :: Field ( n) , n;
3868
3879
expect_anon_const, & ' hir AnonConst , Node :: AnonConst ( n) , n;
3880
+ expect_inline_const, & ' hir ConstBlock , Node :: ConstBlock ( n) , n;
3869
3881
expect_expr, & ' hir Expr <' hir>, Node :: Expr ( n) , n;
3870
3882
expect_expr_field, & ' hir ExprField <' hir>, Node :: ExprField ( n) , n;
3871
3883
expect_stmt, & ' hir Stmt <' hir>, Node :: Stmt ( n) , n;
0 commit comments