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