@@ -229,9 +229,8 @@ impl<'hir> PathSegment<'hir> {
229
229
}
230
230
231
231
#[ derive( Clone , Copy , Debug , HashStable_Generic ) ]
232
- pub struct ConstArg {
233
- pub value : AnonConst ,
234
- pub span : Span ,
232
+ pub struct ConstArg < ' hir > {
233
+ pub value : & ' hir AnonConst ,
235
234
/// Indicates whether this comes from a `~const` desugaring.
236
235
pub is_desugared_from_effects : bool ,
237
236
}
@@ -252,7 +251,7 @@ impl InferArg {
252
251
pub enum GenericArg < ' hir > {
253
252
Lifetime ( & ' hir Lifetime ) ,
254
253
Type ( & ' hir Ty < ' hir > ) ,
255
- Const ( ConstArg ) ,
254
+ Const ( ConstArg < ' hir > ) ,
256
255
Infer ( InferArg ) ,
257
256
}
258
257
@@ -261,7 +260,7 @@ impl GenericArg<'_> {
261
260
match self {
262
261
GenericArg :: Lifetime ( l) => l. ident . span ,
263
262
GenericArg :: Type ( t) => t. span ,
264
- GenericArg :: Const ( c) => c. span ,
263
+ GenericArg :: Const ( c) => c. value . span ,
265
264
GenericArg :: Infer ( i) => i. span ,
266
265
}
267
266
}
@@ -490,7 +489,7 @@ pub enum GenericParamKind<'hir> {
490
489
Const {
491
490
ty : & ' hir Ty < ' hir > ,
492
491
/// Optional default value for the const generic param
493
- default : Option < AnonConst > ,
492
+ default : Option < & ' hir AnonConst > ,
494
493
is_host_effect : bool ,
495
494
} ,
496
495
}
@@ -1562,12 +1561,12 @@ impl fmt::Display for ConstContext {
1562
1561
pub type Lit = Spanned < LitKind > ;
1563
1562
1564
1563
#[ derive( Copy , Clone , Debug , HashStable_Generic ) ]
1565
- pub enum ArrayLen {
1564
+ pub enum ArrayLen < ' hir > {
1566
1565
Infer ( InferArg ) ,
1567
- Body ( AnonConst ) ,
1566
+ Body ( & ' hir AnonConst ) ,
1568
1567
}
1569
1568
1570
- impl ArrayLen {
1569
+ impl ArrayLen < ' _ > {
1571
1570
pub fn hir_id ( & self ) -> HirId {
1572
1571
match self {
1573
1572
ArrayLen :: Infer ( InferArg { hir_id, .. } ) | ArrayLen :: Body ( AnonConst { hir_id, .. } ) => {
@@ -1590,6 +1589,7 @@ pub struct AnonConst {
1590
1589
pub hir_id : HirId ,
1591
1590
pub def_id : LocalDefId ,
1592
1591
pub body : BodyId ,
1592
+ pub span : Span ,
1593
1593
}
1594
1594
1595
1595
/// An inline constant expression `const { something }`.
@@ -2002,7 +2002,7 @@ pub enum ExprKind<'hir> {
2002
2002
///
2003
2003
/// E.g., `[1; 5]`. The first expression is the element
2004
2004
/// to be repeated; the second is the number of times to repeat it.
2005
- Repeat ( & ' hir Expr < ' hir > , ArrayLen ) ,
2005
+ Repeat ( & ' hir Expr < ' hir > , ArrayLen < ' hir > ) ,
2006
2006
2007
2007
/// A suspension point for coroutines (i.e., `yield <expr>`).
2008
2008
Yield ( & ' hir Expr < ' hir > , YieldSource ) ,
@@ -2382,7 +2382,7 @@ pub struct TypeBinding<'hir> {
2382
2382
#[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
2383
2383
pub enum Term < ' hir > {
2384
2384
Ty ( & ' hir Ty < ' hir > ) ,
2385
- Const ( AnonConst ) ,
2385
+ Const ( & ' hir AnonConst ) ,
2386
2386
}
2387
2387
2388
2388
impl < ' hir > From < & ' hir Ty < ' hir > > for Term < ' hir > {
@@ -2391,8 +2391,8 @@ impl<'hir> From<&'hir Ty<'hir>> for Term<'hir> {
2391
2391
}
2392
2392
}
2393
2393
2394
- impl < ' hir > From < AnonConst > for Term < ' hir > {
2395
- fn from ( c : AnonConst ) -> Self {
2394
+ impl < ' hir > From < & ' hir AnonConst > for Term < ' hir > {
2395
+ fn from ( c : & ' hir AnonConst ) -> Self {
2396
2396
Term :: Const ( c)
2397
2397
}
2398
2398
}
@@ -2683,7 +2683,7 @@ pub enum TyKind<'hir> {
2683
2683
/// A variable length slice (i.e., `[T]`).
2684
2684
Slice ( & ' hir Ty < ' hir > ) ,
2685
2685
/// A fixed length array (i.e., `[T; n]`).
2686
- Array ( & ' hir Ty < ' hir > , ArrayLen ) ,
2686
+ Array ( & ' hir Ty < ' hir > , ArrayLen < ' hir > ) ,
2687
2687
/// A raw pointer (i.e., `*const T` or `*mut T`).
2688
2688
Ptr ( MutTy < ' hir > ) ,
2689
2689
/// A reference (i.e., `&'a T` or `&'a mut T`).
@@ -2712,7 +2712,7 @@ pub enum TyKind<'hir> {
2712
2712
/// where `Bound` is a trait or a lifetime.
2713
2713
TraitObject ( & ' hir [ PolyTraitRef < ' hir > ] , & ' hir Lifetime , TraitObjectSyntax ) ,
2714
2714
/// Unused for now.
2715
- Typeof ( AnonConst ) ,
2715
+ Typeof ( & ' hir AnonConst ) ,
2716
2716
/// `TyKind::Infer` means the type should be inferred instead of it having been
2717
2717
/// specified. This can appear anywhere in a type.
2718
2718
Infer ,
@@ -2745,10 +2745,10 @@ pub enum InlineAsmOperand<'hir> {
2745
2745
out_expr : Option < & ' hir Expr < ' hir > > ,
2746
2746
} ,
2747
2747
Const {
2748
- anon_const : AnonConst ,
2748
+ anon_const : & ' hir AnonConst ,
2749
2749
} ,
2750
2750
SymFn {
2751
- anon_const : AnonConst ,
2751
+ anon_const : & ' hir AnonConst ,
2752
2752
} ,
2753
2753
SymStatic {
2754
2754
path : QPath < ' hir > ,
@@ -2950,7 +2950,7 @@ pub struct Variant<'hir> {
2950
2950
/// Fields and constructor id of the variant.
2951
2951
pub data : VariantData < ' hir > ,
2952
2952
/// Explicit discriminant (e.g., `Foo = 1`).
2953
- pub disr_expr : Option < AnonConst > ,
2953
+ pub disr_expr : Option < & ' hir AnonConst > ,
2954
2954
/// Span
2955
2955
pub span : Span ,
2956
2956
}
@@ -3479,15 +3479,13 @@ impl<'hir> OwnerNode<'hir> {
3479
3479
}
3480
3480
}
3481
3481
3482
- // Span by reference to pass to `Node::Err`.
3483
- #[ allow( rustc:: pass_by_value) ]
3484
- pub fn span ( & self ) -> & ' hir Span {
3482
+ pub fn span ( & self ) -> Span {
3485
3483
match self {
3486
3484
OwnerNode :: Item ( Item { span, .. } )
3487
3485
| OwnerNode :: ForeignItem ( ForeignItem { span, .. } )
3488
3486
| OwnerNode :: ImplItem ( ImplItem { span, .. } )
3489
- | OwnerNode :: TraitItem ( TraitItem { span, .. } ) => span,
3490
- OwnerNode :: Crate ( Mod { spans : ModSpans { inner_span, .. } , .. } ) => inner_span,
3487
+ | OwnerNode :: TraitItem ( TraitItem { span, .. } ) => * span,
3488
+ OwnerNode :: Crate ( Mod { spans : ModSpans { inner_span, .. } , .. } ) => * inner_span,
3491
3489
OwnerNode :: Synthetic => unreachable ! ( ) ,
3492
3490
}
3493
3491
}
@@ -3632,9 +3630,7 @@ pub enum Node<'hir> {
3632
3630
PreciseCapturingNonLifetimeArg ( & ' hir PreciseCapturingNonLifetimeArg ) ,
3633
3631
// Created by query feeding
3634
3632
Synthetic ,
3635
- // Span by reference to minimize `Node`'s size
3636
- #[ allow( rustc:: pass_by_value) ]
3637
- Err ( & ' hir Span ) ,
3633
+ Err ( Span ) ,
3638
3634
}
3639
3635
3640
3636
impl < ' hir > Node < ' hir > {
@@ -3871,7 +3867,7 @@ mod size_asserts {
3871
3867
static_assert_size ! ( FnDecl <' _>, 40 ) ;
3872
3868
static_assert_size ! ( ForeignItem <' _>, 72 ) ;
3873
3869
static_assert_size ! ( ForeignItemKind <' _>, 40 ) ;
3874
- static_assert_size ! ( GenericArg <' _>, 32 ) ;
3870
+ static_assert_size ! ( GenericArg <' _>, 24 ) ;
3875
3871
static_assert_size ! ( GenericBound <' _>, 48 ) ;
3876
3872
static_assert_size ! ( Generics <' _>, 56 ) ;
3877
3873
static_assert_size ! ( Impl <' _>, 80 ) ;
0 commit comments