@@ -85,8 +85,19 @@ pub(crate) trait AttributeParser<S: Stage>: Default + 'static {
8585/// [`SingleAttributeParser`] can only convert attributes one-to-one, and cannot combine multiple
8686/// attributes together like is necessary for `#[stable()]` and `#[unstable()]` for example.
8787pub ( crate ) trait SingleAttributeParser < S : Stage > : ' static {
88+ /// The single path of the attribute this parser accepts.
89+ ///
90+ /// If you need the parser to accept more than one path, use [`AttributeParser`] instead
8891 const PATH : & [ Symbol ] ;
92+
93+ /// Configures the precedence of attributes with the same `PATH` on a syntax node.
8994 const ATTRIBUTE_ORDER : AttributeOrder ;
95+
96+ /// Configures what to do when when the same attribute is
97+ /// applied more than once on the same syntax node.
98+ ///
99+ /// [`ATTRIBUTE_ORDER`] specified which one is assumed to be correct,
100+ /// and this specified whether to, for example, warn or error on the other one.
90101 const ON_DUPLICATE : OnDuplicate < S > ;
91102
92103 /// The template this attribute parser should implement. Used for diagnostics.
@@ -96,6 +107,8 @@ pub(crate) trait SingleAttributeParser<S: Stage>: 'static {
96107 fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser < ' _ > ) -> Option < AttributeKind > ;
97108}
98109
110+ /// Use in combination with [`SingleAttributeParser`].
111+ /// `Single<T: SingleAttributeParser>` implements [`AttributeParser`].
99112pub ( crate ) struct Single < T : SingleAttributeParser < S > , S : Stage > (
100113 PhantomData < ( S , T ) > ,
101114 Option < ( AttributeKind , Span ) > ,
@@ -228,6 +241,10 @@ pub(crate) trait CombineAttributeParser<S: Stage>: 'static {
228241 const PATH : & [ rustc_span:: Symbol ] ;
229242
230243 type Item ;
244+ /// A function that converts individual items (of type [`Item`](Self::Item)) into the final attribute.
245+ ///
246+ /// For example, individual representations fomr `#[repr(...)]` attributes into an `AttributeKind::Repr(x)`,
247+ /// where `x` is a vec of these individual reprs.
231248 const CONVERT : ConvertFn < Self :: Item > ;
232249
233250 /// The template this attribute parser should implement. Used for diagnostics.
@@ -240,6 +257,8 @@ pub(crate) trait CombineAttributeParser<S: Stage>: 'static {
240257 ) -> impl IntoIterator < Item = Self :: Item > + ' c ;
241258}
242259
260+ /// Use in combination with [`CombineAttributeParser`].
261+ /// `Combine<T: CombineAttributeParser>` implements [`AttributeParser`].
243262pub ( crate ) struct Combine < T : CombineAttributeParser < S > , S : Stage > (
244263 PhantomData < ( S , T ) > ,
245264 ThinVec < <T as CombineAttributeParser < S > >:: Item > ,
0 commit comments