@@ -87,8 +87,19 @@ pub(crate) trait AttributeParser<S: Stage>: Default + 'static {
87
87
/// [`SingleAttributeParser`] can only convert attributes one-to-one, and cannot combine multiple
88
88
/// attributes together like is necessary for `#[stable()]` and `#[unstable()]` for example.
89
89
pub ( crate ) trait SingleAttributeParser < S : Stage > : ' static {
90
+ /// The single path of the attribute this parser accepts.
91
+ ///
92
+ /// If you need the parser to accept more than one path, use [`AttributeParser`] instead
90
93
const PATH : & [ Symbol ] ;
94
+
95
+ /// Configures the precedence of attributes with the same `PATH` on a syntax node.
91
96
const ATTRIBUTE_ORDER : AttributeOrder ;
97
+
98
+ /// Configures what to do when when the same attribute is
99
+ /// applied more than once on the same syntax node.
100
+ ///
101
+ /// [`ATTRIBUTE_ORDER`](Self::ATTRIBUTE_ORDER) specified which one is assumed to be correct,
102
+ /// and this specified whether to, for example, warn or error on the other one.
92
103
const ON_DUPLICATE : OnDuplicate < S > ;
93
104
94
105
/// The template this attribute parser should implement. Used for diagnostics.
@@ -98,6 +109,8 @@ pub(crate) trait SingleAttributeParser<S: Stage>: 'static {
98
109
fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser < ' _ > ) -> Option < AttributeKind > ;
99
110
}
100
111
112
+ /// Use in combination with [`SingleAttributeParser`].
113
+ /// `Single<T: SingleAttributeParser>` implements [`AttributeParser`].
101
114
pub ( crate ) struct Single < T : SingleAttributeParser < S > , S : Stage > (
102
115
PhantomData < ( S , T ) > ,
103
116
Option < ( AttributeKind , Span ) > ,
@@ -230,6 +243,10 @@ pub(crate) trait CombineAttributeParser<S: Stage>: 'static {
230
243
const PATH : & [ rustc_span:: Symbol ] ;
231
244
232
245
type Item ;
246
+ /// A function that converts individual items (of type [`Item`](Self::Item)) into the final attribute.
247
+ ///
248
+ /// For example, individual representations fomr `#[repr(...)]` attributes into an `AttributeKind::Repr(x)`,
249
+ /// where `x` is a vec of these individual reprs.
233
250
const CONVERT : ConvertFn < Self :: Item > ;
234
251
235
252
/// The template this attribute parser should implement. Used for diagnostics.
@@ -242,6 +259,8 @@ pub(crate) trait CombineAttributeParser<S: Stage>: 'static {
242
259
) -> impl IntoIterator < Item = Self :: Item > + ' c ;
243
260
}
244
261
262
+ /// Use in combination with [`CombineAttributeParser`].
263
+ /// `Combine<T: CombineAttributeParser>` implements [`AttributeParser`].
245
264
pub ( crate ) struct Combine < T : CombineAttributeParser < S > , S : Stage > (
246
265
PhantomData < ( S , T ) > ,
247
266
ThinVec < <T as CombineAttributeParser < S > >:: Item > ,
0 commit comments