@@ -230,9 +230,8 @@ impl<'hir> PathSegment<'hir> {
230230}
231231
232232#[ derive( Clone , Copy , Debug , HashStable_Generic ) ]
233- pub struct ConstArg {
234- pub value : AnonConst ,
235- pub span : Span ,
233+ pub struct ConstArg < ' hir > {
234+ pub value : & ' hir AnonConst ,
236235 /// Indicates whether this comes from a `~const` desugaring.
237236 pub is_desugared_from_effects : bool ,
238237}
@@ -253,7 +252,7 @@ impl InferArg {
253252pub enum GenericArg < ' hir > {
254253 Lifetime ( & ' hir Lifetime ) ,
255254 Type ( & ' hir Ty < ' hir > ) ,
256- Const ( ConstArg ) ,
255+ Const ( ConstArg < ' hir > ) ,
257256 Infer ( InferArg ) ,
258257}
259258
@@ -262,7 +261,7 @@ impl GenericArg<'_> {
262261 match self {
263262 GenericArg :: Lifetime ( l) => l. ident . span ,
264263 GenericArg :: Type ( t) => t. span ,
265- GenericArg :: Const ( c) => c. span ,
264+ GenericArg :: Const ( c) => c. value . span ,
266265 GenericArg :: Infer ( i) => i. span ,
267266 }
268267 }
@@ -491,7 +490,7 @@ pub enum GenericParamKind<'hir> {
491490 Const {
492491 ty : & ' hir Ty < ' hir > ,
493492 /// Optional default value for the const generic param
494- default : Option < AnonConst > ,
493+ default : Option < & ' hir AnonConst > ,
495494 is_host_effect : bool ,
496495 } ,
497496}
@@ -1563,12 +1562,12 @@ impl fmt::Display for ConstContext {
15631562pub type Lit = Spanned < LitKind > ;
15641563
15651564#[ derive( Copy , Clone , Debug , HashStable_Generic ) ]
1566- pub enum ArrayLen {
1565+ pub enum ArrayLen < ' hir > {
15671566 Infer ( InferArg ) ,
1568- Body ( AnonConst ) ,
1567+ Body ( & ' hir AnonConst ) ,
15691568}
15701569
1571- impl ArrayLen {
1570+ impl ArrayLen < ' _ > {
15721571 pub fn hir_id ( & self ) -> HirId {
15731572 match self {
15741573 ArrayLen :: Infer ( InferArg { hir_id, .. } ) | ArrayLen :: Body ( AnonConst { hir_id, .. } ) => {
@@ -1591,6 +1590,7 @@ pub struct AnonConst {
15911590 pub hir_id : HirId ,
15921591 pub def_id : LocalDefId ,
15931592 pub body : BodyId ,
1593+ pub span : Span ,
15941594}
15951595
15961596/// An inline constant expression `const { something }`.
@@ -2003,7 +2003,7 @@ pub enum ExprKind<'hir> {
20032003 ///
20042004 /// E.g., `[1; 5]`. The first expression is the element
20052005 /// to be repeated; the second is the number of times to repeat it.
2006- Repeat ( & ' hir Expr < ' hir > , ArrayLen ) ,
2006+ Repeat ( & ' hir Expr < ' hir > , ArrayLen < ' hir > ) ,
20072007
20082008 /// A suspension point for coroutines (i.e., `yield <expr>`).
20092009 Yield ( & ' hir Expr < ' hir > , YieldSource ) ,
@@ -2383,7 +2383,7 @@ pub struct TypeBinding<'hir> {
23832383#[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
23842384pub enum Term < ' hir > {
23852385 Ty ( & ' hir Ty < ' hir > ) ,
2386- Const ( AnonConst ) ,
2386+ Const ( & ' hir AnonConst ) ,
23872387}
23882388
23892389impl < ' hir > From < & ' hir Ty < ' hir > > for Term < ' hir > {
@@ -2392,8 +2392,8 @@ impl<'hir> From<&'hir Ty<'hir>> for Term<'hir> {
23922392 }
23932393}
23942394
2395- impl < ' hir > From < AnonConst > for Term < ' hir > {
2396- fn from ( c : AnonConst ) -> Self {
2395+ impl < ' hir > From < & ' hir AnonConst > for Term < ' hir > {
2396+ fn from ( c : & ' hir AnonConst ) -> Self {
23972397 Term :: Const ( c)
23982398 }
23992399}
@@ -2684,7 +2684,7 @@ pub enum TyKind<'hir> {
26842684 /// A variable length slice (i.e., `[T]`).
26852685 Slice ( & ' hir Ty < ' hir > ) ,
26862686 /// A fixed length array (i.e., `[T; n]`).
2687- Array ( & ' hir Ty < ' hir > , ArrayLen ) ,
2687+ Array ( & ' hir Ty < ' hir > , ArrayLen < ' hir > ) ,
26882688 /// A raw pointer (i.e., `*const T` or `*mut T`).
26892689 Ptr ( MutTy < ' hir > ) ,
26902690 /// A reference (i.e., `&'a T` or `&'a mut T`).
@@ -2713,7 +2713,7 @@ pub enum TyKind<'hir> {
27132713 /// where `Bound` is a trait or a lifetime.
27142714 TraitObject ( & ' hir [ PolyTraitRef < ' hir > ] , & ' hir Lifetime , TraitObjectSyntax ) ,
27152715 /// Unused for now.
2716- Typeof ( AnonConst ) ,
2716+ Typeof ( & ' hir AnonConst ) ,
27172717 /// `TyKind::Infer` means the type should be inferred instead of it having been
27182718 /// specified. This can appear anywhere in a type.
27192719 Infer ,
@@ -2746,10 +2746,10 @@ pub enum InlineAsmOperand<'hir> {
27462746 out_expr : Option < & ' hir Expr < ' hir > > ,
27472747 } ,
27482748 Const {
2749- anon_const : AnonConst ,
2749+ anon_const : & ' hir AnonConst ,
27502750 } ,
27512751 SymFn {
2752- anon_const : AnonConst ,
2752+ anon_const : & ' hir AnonConst ,
27532753 } ,
27542754 SymStatic {
27552755 path : QPath < ' hir > ,
@@ -2951,7 +2951,7 @@ pub struct Variant<'hir> {
29512951 /// Fields and constructor id of the variant.
29522952 pub data : VariantData < ' hir > ,
29532953 /// Explicit discriminant (e.g., `Foo = 1`).
2954- pub disr_expr : Option < AnonConst > ,
2954+ pub disr_expr : Option < & ' hir AnonConst > ,
29552955 /// Span
29562956 pub span : Span ,
29572957}
@@ -3480,15 +3480,13 @@ impl<'hir> OwnerNode<'hir> {
34803480 }
34813481 }
34823482
3483- // Span by reference to pass to `Node::Err`.
3484- #[ allow( rustc:: pass_by_value) ]
3485- pub fn span ( & self ) -> & ' hir Span {
3483+ pub fn span ( & self ) -> Span {
34863484 match self {
34873485 OwnerNode :: Item ( Item { span, .. } )
34883486 | OwnerNode :: ForeignItem ( ForeignItem { span, .. } )
34893487 | OwnerNode :: ImplItem ( ImplItem { span, .. } )
3490- | OwnerNode :: TraitItem ( TraitItem { span, .. } ) => span,
3491- OwnerNode :: Crate ( Mod { spans : ModSpans { inner_span, .. } , .. } ) => inner_span,
3488+ | OwnerNode :: TraitItem ( TraitItem { span, .. } ) => * span,
3489+ OwnerNode :: Crate ( Mod { spans : ModSpans { inner_span, .. } , .. } ) => * inner_span,
34923490 OwnerNode :: Synthetic => unreachable ! ( ) ,
34933491 }
34943492 }
@@ -3633,9 +3631,7 @@ pub enum Node<'hir> {
36333631 PreciseCapturingNonLifetimeArg ( & ' hir PreciseCapturingNonLifetimeArg ) ,
36343632 // Created by query feeding
36353633 Synthetic ,
3636- // Span by reference to minimize `Node`'s size
3637- #[ allow( rustc:: pass_by_value) ]
3638- Err ( & ' hir Span ) ,
3634+ Err ( Span ) ,
36393635}
36403636
36413637impl < ' 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