19
19
//! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators.
20
20
21
21
use std:: borrow:: Cow ;
22
- use std:: { cmp, fmt, mem } ;
22
+ use std:: { cmp, fmt} ;
23
23
24
24
pub use GenericArgs :: * ;
25
25
pub use UnsafeSource :: * ;
@@ -1688,28 +1688,16 @@ pub enum AttrArgs {
1688
1688
/// Span of the `=` token.
1689
1689
Span ,
1690
1690
/// The "value".
1691
- AttrArgsEq ,
1691
+ P < Expr > ,
1692
1692
) ,
1693
1693
}
1694
1694
1695
- // The RHS of an `AttrArgs::Eq` starts out as an expression. Once macro
1696
- // expansion is completed, all cases end up either as a meta item literal,
1697
- // which is the form used after lowering to HIR, or as an error.
1698
- #[ derive( Clone , Encodable , Decodable , Debug ) ]
1699
- pub enum AttrArgsEq {
1700
- Ast ( P < Expr > ) ,
1701
- Hir ( MetaItemLit ) ,
1702
- }
1703
-
1704
1695
impl AttrArgs {
1705
1696
pub fn span ( & self ) -> Option < Span > {
1706
1697
match self {
1707
1698
AttrArgs :: Empty => None ,
1708
1699
AttrArgs :: Delimited ( args) => Some ( args. dspan . entire ( ) ) ,
1709
- AttrArgs :: Eq ( eq_span, AttrArgsEq :: Ast ( expr) ) => Some ( eq_span. to ( expr. span ) ) ,
1710
- AttrArgs :: Eq ( _, AttrArgsEq :: Hir ( lit) ) => {
1711
- unreachable ! ( "in literal form when getting span: {:?}" , lit) ;
1712
- }
1700
+ AttrArgs :: Eq ( eq_span, expr) => Some ( eq_span. to ( expr. span ) ) ,
1713
1701
}
1714
1702
}
1715
1703
@@ -1719,30 +1707,7 @@ impl AttrArgs {
1719
1707
match self {
1720
1708
AttrArgs :: Empty => TokenStream :: default ( ) ,
1721
1709
AttrArgs :: Delimited ( args) => args. tokens . clone ( ) ,
1722
- AttrArgs :: Eq ( _, AttrArgsEq :: Ast ( expr) ) => TokenStream :: from_ast ( expr) ,
1723
- AttrArgs :: Eq ( _, AttrArgsEq :: Hir ( lit) ) => {
1724
- unreachable ! ( "in literal form when getting inner tokens: {:?}" , lit)
1725
- }
1726
- }
1727
- }
1728
- }
1729
-
1730
- impl < CTX > HashStable < CTX > for AttrArgs
1731
- where
1732
- CTX : crate :: HashStableContext ,
1733
- {
1734
- fn hash_stable ( & self , ctx : & mut CTX , hasher : & mut StableHasher ) {
1735
- mem:: discriminant ( self ) . hash_stable ( ctx, hasher) ;
1736
- match self {
1737
- AttrArgs :: Empty => { }
1738
- AttrArgs :: Delimited ( args) => args. hash_stable ( ctx, hasher) ,
1739
- AttrArgs :: Eq ( _eq_span, AttrArgsEq :: Ast ( expr) ) => {
1740
- unreachable ! ( "hash_stable {:?}" , expr) ;
1741
- }
1742
- AttrArgs :: Eq ( eq_span, AttrArgsEq :: Hir ( lit) ) => {
1743
- eq_span. hash_stable ( ctx, hasher) ;
1744
- lit. hash_stable ( ctx, hasher) ;
1745
- }
1710
+ AttrArgs :: Eq ( _, expr) => TokenStream :: from_ast ( expr) ,
1746
1711
}
1747
1712
}
1748
1713
}
@@ -2892,7 +2857,7 @@ pub enum AttrStyle {
2892
2857
}
2893
2858
2894
2859
/// A list of attributes.
2895
- pub type AttrVec = ThinVec < Attribute > ;
2860
+ pub type AttrVec < A = Attribute > = ThinVec < A > ;
2896
2861
2897
2862
/// A syntax-level representation of an attribute.
2898
2863
#[ derive( Clone , Encodable , Decodable , Debug ) ]
@@ -2937,7 +2902,7 @@ impl NormalAttr {
2937
2902
}
2938
2903
}
2939
2904
2940
- #[ derive( Clone , Encodable , Decodable , Debug , HashStable_Generic ) ]
2905
+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
2941
2906
pub struct AttrItem {
2942
2907
pub unsafety : Safety ,
2943
2908
pub path : Path ,
@@ -3078,8 +3043,8 @@ impl VariantData {
3078
3043
3079
3044
/// An item definition.
3080
3045
#[ derive( Clone , Encodable , Decodable , Debug ) ]
3081
- pub struct Item < K = ItemKind > {
3082
- pub attrs : AttrVec ,
3046
+ pub struct Item < K = ItemKind , A = Attribute > {
3047
+ pub attrs : AttrVec < A > ,
3083
3048
pub id : NodeId ,
3084
3049
pub span : Span ,
3085
3050
pub vis : Visibility ,
0 commit comments