Skip to content

Commit d2a00eb

Browse files
authored
Rollup merge of #142494 - jdonszelmann:missing-attr-parsing-docs, r=oli-obk
Fix missing docs in `rustc_attr_parsing`
2 parents f0374dc + 7f49de2 commit d2a00eb

File tree

1 file changed

+19
-0
lines changed
  • compiler/rustc_attr_parsing/src/attributes

1 file changed

+19
-0
lines changed

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
8989
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
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`].
101114
pub(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`].
245264
pub(crate) struct Combine<T: CombineAttributeParser<S>, S: Stage>(
246265
PhantomData<(S, T)>,
247266
ThinVec<<T as CombineAttributeParser<S>>::Item>,

0 commit comments

Comments
 (0)