@@ -2266,6 +2266,7 @@ impl Expr<'_> {
22662266 | ExprKind :: Match ( ..)
22672267 | ExprKind :: MethodCall ( ..)
22682268 | ExprKind :: OffsetOf ( ..)
2269+ | ExprKind :: RawHandle ( ..)
22692270 | ExprKind :: Path ( ..)
22702271 | ExprKind :: Repeat ( ..)
22712272 | ExprKind :: Struct ( ..)
@@ -2338,6 +2339,7 @@ impl Expr<'_> {
23382339 | ExprKind :: Assign ( ..)
23392340 | ExprKind :: InlineAsm ( ..)
23402341 | ExprKind :: OffsetOf ( ..)
2342+ | ExprKind :: RawHandle ( ..)
23412343 | ExprKind :: AssignOp ( ..)
23422344 | ExprKind :: Lit ( _)
23432345 | ExprKind :: ConstBlock ( ..)
@@ -2429,6 +2431,7 @@ impl Expr<'_> {
24292431 | ExprKind :: Become ( _)
24302432 | ExprKind :: InlineAsm ( _)
24312433 | ExprKind :: OffsetOf ( ..)
2434+ | ExprKind :: RawHandle ( ..)
24322435 | ExprKind :: Struct ( ..)
24332436 | ExprKind :: Repeat ( ..)
24342437 | ExprKind :: Yield ( ..)
@@ -2486,9 +2489,11 @@ impl Expr<'_> {
24862489
24872490 pub fn can_have_side_effects ( & self ) -> bool {
24882491 match self . peel_drop_temps ( ) . kind {
2489- ExprKind :: Path ( _) | ExprKind :: Lit ( _) | ExprKind :: OffsetOf ( ..) | ExprKind :: Use ( ..) => {
2490- false
2491- }
2492+ ExprKind :: Path ( _)
2493+ | ExprKind :: Lit ( _)
2494+ | ExprKind :: OffsetOf ( ..)
2495+ | ExprKind :: RawHandle ( ..)
2496+ | ExprKind :: Use ( ..) => false ,
24922497 ExprKind :: Type ( base, _)
24932498 | ExprKind :: Unary ( _, base)
24942499 | ExprKind :: Field ( base, _)
@@ -2654,6 +2659,21 @@ pub fn expr_needs_parens(expr: &Expr<'_>) -> bool {
26542659 }
26552660}
26562661
2662+ #[ derive( Debug , Clone , Copy , StableHash ) ]
2663+ pub struct FieldProject < ' hir > {
2664+ #[ stable_hash( ignore) ]
2665+ pub hir_id : HirId ,
2666+ pub kind : FieldProjectKind < ' hir > ,
2667+ pub span : Span ,
2668+ }
2669+
2670+ #[ derive( Debug , Clone , Copy , StableHash ) ]
2671+ pub enum FieldProjectKind < ' hir > {
2672+ Path ( QPath < ' hir > ) ,
2673+ Field ( & ' hir FieldProject < ' hir > , Ident ) ,
2674+ Deref ( & ' hir FieldProject < ' hir > ) ,
2675+ }
2676+
26572677#[ derive( Debug , Clone , Copy , StableHash ) ]
26582678pub enum ExprKind < ' hir > {
26592679 /// Allow anonymous constants from an inline `const` block
@@ -2770,6 +2790,9 @@ pub enum ExprKind<'hir> {
27702790 /// Field offset (`offset_of!`)
27712791 OffsetOf ( & ' hir Ty < ' hir > , & ' hir [ Ident ] ) ,
27722792
2793+ /// Raw place handle (`raw_handle!`)
2794+ RawHandle ( & ' hir FieldProject < ' hir > ) ,
2795+
27732796 /// A struct or struct-like variant literal expression.
27742797 ///
27752798 /// E.g., `Foo {x: 1, y: 2}`, or `Foo {x: 1, .. base}`,
@@ -5050,6 +5073,7 @@ pub enum Node<'hir> {
50505073 ConstBlock ( & ' hir ConstBlock ) ,
50515074 ConstArg ( & ' hir ConstArg < ' hir > ) ,
50525075 Expr ( & ' hir Expr < ' hir > ) ,
5076+ FieldProject ( & ' hir FieldProject < ' hir > ) ,
50535077 ExprField ( & ' hir ExprField < ' hir > ) ,
50545078 ConstArgExprField ( & ' hir ConstArgExprField < ' hir > ) ,
50555079 Stmt ( & ' hir Stmt < ' hir > ) ,
@@ -5122,6 +5146,7 @@ impl<'hir> Node<'hir> {
51225146 | Node :: ConstBlock ( ..)
51235147 | Node :: ConstArg ( ..)
51245148 | Node :: Expr ( ..)
5149+ | Node :: FieldProject ( ..)
51255150 | Node :: Stmt ( ..)
51265151 | Node :: Block ( ..)
51275152 | Node :: Ctor ( ..)
@@ -5322,6 +5347,7 @@ impl<'hir> Node<'hir> {
53225347 match self {
53235348 Node :: Ty ( Ty { kind : TyKind :: Path ( path) , .. } )
53245349 | Node :: Expr ( Expr { kind : ExprKind :: Path ( path) , .. } )
5350+ | Node :: FieldProject ( FieldProject { kind : FieldProjectKind :: Path ( path) , .. } )
53255351 | Node :: PatExpr ( PatExpr { kind : PatExprKind :: Path ( path) , .. } ) => Some ( path) ,
53265352 _ => None ,
53275353 }
@@ -5338,6 +5364,7 @@ impl<'hir> Node<'hir> {
53385364 expect_anon_const, & ' hir AnonConst , Node :: AnonConst ( n) , n;
53395365 expect_inline_const, & ' hir ConstBlock , Node :: ConstBlock ( n) , n;
53405366 expect_expr, & ' hir Expr <' hir>, Node :: Expr ( n) , n;
5367+ expect_field_project, & ' hir FieldProject <' hir>, Node :: FieldProject ( n) , n;
53415368 expect_expr_field, & ' hir ExprField <' hir>, Node :: ExprField ( n) , n;
53425369 expect_stmt, & ' hir Stmt <' hir>, Node :: Stmt ( n) , n;
53435370 expect_path_segment, & ' hir PathSegment <' hir>, Node :: PathSegment ( n) , n;
@@ -5370,6 +5397,8 @@ mod size_asserts {
53705397 static_assert_size ! ( Body <' _>, 24 ) ;
53715398 static_assert_size ! ( Expr <' _>, 64 ) ;
53725399 static_assert_size ! ( ExprKind <' _>, 48 ) ;
5400+ static_assert_size ! ( FieldProject <' _>, 48 ) ;
5401+ static_assert_size ! ( FieldProjectKind <' _>, 32 ) ;
53735402 static_assert_size ! ( FnDecl <' _>, 40 ) ;
53745403 static_assert_size ! ( ForeignItem <' _>, 88 ) ;
53755404 static_assert_size ! ( ForeignItemKind <' _>, 56 ) ;
0 commit comments