@@ -572,6 +572,20 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
572572 Some ( single)
573573 }
574574
575+ /// Asserts that an [`ArgParser`] is a list and returns it, or emits an error and returns
576+ /// `None`.
577+ ///
578+ /// Some examples:
579+ ///
580+ /// - `#[allow(clippy::complexity)]`: `(clippy::complexity)` is a list
581+ /// - `#[rustfmt::skip::macros(target_macro_name)]`: `(target_macro_name)` is a list
582+ ///
583+ /// This is a higher-level (and harder to misuse) wrapper over [`ArgParser::list`]. That allows
584+ /// using `?` when the attribute parsing function allows it. You may still want to use
585+ /// [`ArgParser::list`] for the following reasons:
586+ ///
587+ /// - You want to emit your own diagnostics (for instance, with [`AcceptContext::emit_err`]).
588+ /// - The attribute can be parsed in multiple ways and it does not make sense to emit an error.
575589 pub ( crate ) fn list < ' arg > (
576590 & mut self ,
577591 args : & ' arg ArgParser ,
@@ -584,6 +598,15 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
584598 list
585599 }
586600
601+ /// Asserts that a [`MetaItemListParser`] contains a single element and returns it, or emits an
602+ /// error and returns `None`.
603+ ///
604+ /// This is a higher-level (and harder to misuse) wrapper over [`MetaItemListParser::single`].
605+ /// That allows using `?` to early return. You may still want to use
606+ /// [`MetaItemListParser::single`] for the following reasons:
607+ ///
608+ /// - You want to emit your own diagnostics (for instance, with [`AcceptContext::emit_err`]).
609+ /// - The attribute can be parsed in multiple ways and it does not make sense to emit an error.
587610 pub ( crate ) fn single < ' arg > (
588611 & mut self ,
589612 list : & ' arg MetaItemListParser ,
0 commit comments