@@ -229,9 +229,8 @@ impl<'hir> PathSegment<'hir> {
229229}
230230
231231#[ 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 ,
235234 /// Indicates whether this comes from a `~const` desugaring.
236235 pub is_desugared_from_effects : bool ,
237236}
@@ -252,7 +251,7 @@ impl InferArg {
252251pub enum GenericArg < ' hir > {
253252 Lifetime ( & ' hir Lifetime ) ,
254253 Type ( & ' hir Ty < ' hir > ) ,
255- Const ( ConstArg ) ,
254+ Const ( ConstArg < ' hir > ) ,
256255 Infer ( InferArg ) ,
257256}
258257
@@ -261,7 +260,7 @@ impl GenericArg<'_> {
261260 match self {
262261 GenericArg :: Lifetime ( l) => l. ident . span ,
263262 GenericArg :: Type ( t) => t. span ,
264- GenericArg :: Const ( c) => c. span ,
263+ GenericArg :: Const ( c) => c. value . span ,
265264 GenericArg :: Infer ( i) => i. span ,
266265 }
267266 }
@@ -490,7 +489,7 @@ pub enum GenericParamKind<'hir> {
490489 Const {
491490 ty : & ' hir Ty < ' hir > ,
492491 /// Optional default value for the const generic param
493- default : Option < AnonConst > ,
492+ default : Option < & ' hir AnonConst > ,
494493 is_host_effect : bool ,
495494 } ,
496495}
@@ -1562,12 +1561,12 @@ impl fmt::Display for ConstContext {
15621561pub type Lit = Spanned < LitKind > ;
15631562
15641563#[ derive( Copy , Clone , Debug , HashStable_Generic ) ]
1565- pub enum ArrayLen {
1564+ pub enum ArrayLen < ' hir > {
15661565 Infer ( InferArg ) ,
1567- Body ( AnonConst ) ,
1566+ Body ( & ' hir AnonConst ) ,
15681567}
15691568
1570- impl ArrayLen {
1569+ impl ArrayLen < ' _ > {
15711570 pub fn hir_id ( & self ) -> HirId {
15721571 match self {
15731572 ArrayLen :: Infer ( InferArg { hir_id, .. } ) | ArrayLen :: Body ( AnonConst { hir_id, .. } ) => {
@@ -1590,6 +1589,7 @@ pub struct AnonConst {
15901589 pub hir_id : HirId ,
15911590 pub def_id : LocalDefId ,
15921591 pub body : BodyId ,
1592+ pub span : Span ,
15931593}
15941594
15951595/// An inline constant expression `const { something }`.
@@ -2002,7 +2002,7 @@ pub enum ExprKind<'hir> {
20022002 ///
20032003 /// E.g., `[1; 5]`. The first expression is the element
20042004 /// 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 > ) ,
20062006
20072007 /// A suspension point for coroutines (i.e., `yield <expr>`).
20082008 Yield ( & ' hir Expr < ' hir > , YieldSource ) ,
@@ -2382,7 +2382,7 @@ pub struct TypeBinding<'hir> {
23822382#[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
23832383pub enum Term < ' hir > {
23842384 Ty ( & ' hir Ty < ' hir > ) ,
2385- Const ( AnonConst ) ,
2385+ Const ( & ' hir AnonConst ) ,
23862386}
23872387
23882388impl < ' hir > From < & ' hir Ty < ' hir > > for Term < ' hir > {
@@ -2391,8 +2391,8 @@ impl<'hir> From<&'hir Ty<'hir>> for Term<'hir> {
23912391 }
23922392}
23932393
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 {
23962396 Term :: Const ( c)
23972397 }
23982398}
@@ -2683,7 +2683,7 @@ pub enum TyKind<'hir> {
26832683 /// A variable length slice (i.e., `[T]`).
26842684 Slice ( & ' hir Ty < ' hir > ) ,
26852685 /// A fixed length array (i.e., `[T; n]`).
2686- Array ( & ' hir Ty < ' hir > , ArrayLen ) ,
2686+ Array ( & ' hir Ty < ' hir > , ArrayLen < ' hir > ) ,
26872687 /// A raw pointer (i.e., `*const T` or `*mut T`).
26882688 Ptr ( MutTy < ' hir > ) ,
26892689 /// A reference (i.e., `&'a T` or `&'a mut T`).
@@ -2712,7 +2712,7 @@ pub enum TyKind<'hir> {
27122712 /// where `Bound` is a trait or a lifetime.
27132713 TraitObject ( & ' hir [ PolyTraitRef < ' hir > ] , & ' hir Lifetime , TraitObjectSyntax ) ,
27142714 /// Unused for now.
2715- Typeof ( AnonConst ) ,
2715+ Typeof ( & ' hir AnonConst ) ,
27162716 /// `TyKind::Infer` means the type should be inferred instead of it having been
27172717 /// specified. This can appear anywhere in a type.
27182718 Infer ,
@@ -2745,10 +2745,10 @@ pub enum InlineAsmOperand<'hir> {
27452745 out_expr : Option < & ' hir Expr < ' hir > > ,
27462746 } ,
27472747 Const {
2748- anon_const : AnonConst ,
2748+ anon_const : & ' hir AnonConst ,
27492749 } ,
27502750 SymFn {
2751- anon_const : AnonConst ,
2751+ anon_const : & ' hir AnonConst ,
27522752 } ,
27532753 SymStatic {
27542754 path : QPath < ' hir > ,
@@ -2950,7 +2950,7 @@ pub struct Variant<'hir> {
29502950 /// Fields and constructor id of the variant.
29512951 pub data : VariantData < ' hir > ,
29522952 /// Explicit discriminant (e.g., `Foo = 1`).
2953- pub disr_expr : Option < AnonConst > ,
2953+ pub disr_expr : Option < & ' hir AnonConst > ,
29542954 /// Span
29552955 pub span : Span ,
29562956}
@@ -3479,15 +3479,13 @@ impl<'hir> OwnerNode<'hir> {
34793479 }
34803480 }
34813481
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 {
34853483 match self {
34863484 OwnerNode :: Item ( Item { span, .. } )
34873485 | OwnerNode :: ForeignItem ( ForeignItem { span, .. } )
34883486 | 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,
34913489 OwnerNode :: Synthetic => unreachable ! ( ) ,
34923490 }
34933491 }
@@ -3632,9 +3630,7 @@ pub enum Node<'hir> {
36323630 PreciseCapturingNonLifetimeArg ( & ' hir PreciseCapturingNonLifetimeArg ) ,
36333631 // Created by query feeding
36343632 Synthetic ,
3635- // Span by reference to minimize `Node`'s size
3636- #[ allow( rustc:: pass_by_value) ]
3637- Err ( & ' hir Span ) ,
3633+ Err ( Span ) ,
36383634}
36393635
36403636impl < ' hir > Node < ' hir > {
@@ -3871,7 +3867,7 @@ mod size_asserts {
38713867 static_assert_size ! ( FnDecl <' _>, 40 ) ;
38723868 static_assert_size ! ( ForeignItem <' _>, 72 ) ;
38733869 static_assert_size ! ( ForeignItemKind <' _>, 40 ) ;
3874- static_assert_size ! ( GenericArg <' _>, 32 ) ;
3870+ static_assert_size ! ( GenericArg <' _>, 24 ) ;
38753871 static_assert_size ! ( GenericBound <' _>, 48 ) ;
38763872 static_assert_size ! ( Generics <' _>, 56 ) ;
38773873 static_assert_size ! ( Impl <' _>, 80 ) ;
0 commit comments