@@ -87,8 +87,19 @@ pub(crate) trait AttributeParser<S: Stage>: Default + 'static {
8787/// [`SingleAttributeParser`] can only convert attributes one-to-one, and cannot combine multiple
8888/// attributes together like is necessary for `#[stable()]` and `#[unstable()]` for example.
8989pub ( 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
9093 const PATH : & [ Symbol ] ;
94+
95+ /// Configures the precedence of attributes with the same `PATH` on a syntax node.
9196 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.
92103 const ON_DUPLICATE : OnDuplicate < S > ;
93104
94105 /// The template this attribute parser should implement. Used for diagnostics.
@@ -98,6 +109,8 @@ pub(crate) trait SingleAttributeParser<S: Stage>: 'static {
98109 fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser < ' _ > ) -> Option < AttributeKind > ;
99110}
100111
112+ /// Use in combination with [`SingleAttributeParser`].
113+ /// `Single<T: SingleAttributeParser>` implements [`AttributeParser`].
101114pub ( crate ) struct Single < T : SingleAttributeParser < S > , S : Stage > (
102115 PhantomData < ( S , T ) > ,
103116 Option < ( AttributeKind , Span ) > ,
@@ -230,6 +243,10 @@ pub(crate) trait CombineAttributeParser<S: Stage>: 'static {
230243 const PATH : & [ rustc_span:: Symbol ] ;
231244
232245 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.
233250 const CONVERT : ConvertFn < Self :: Item > ;
234251
235252 /// The template this attribute parser should implement. Used for diagnostics.
@@ -242,6 +259,8 @@ pub(crate) trait CombineAttributeParser<S: Stage>: 'static {
242259 ) -> impl IntoIterator < Item = Self :: Item > + ' c ;
243260}
244261
262+ /// Use in combination with [`CombineAttributeParser`].
263+ /// `Combine<T: CombineAttributeParser>` implements [`AttributeParser`].
245264pub ( crate ) struct Combine < T : CombineAttributeParser < S > , S : Stage > (
246265 PhantomData < ( S , T ) > ,
247266 ThinVec < <T as CombineAttributeParser < S > >:: Item > ,
0 commit comments