File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
compiler/rustc_attr_parsing/src/attributes Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ type AcceptMapping<T> = &'static [(&'static [Symbol], AcceptFn<T>)];
5151/// whether it has seen the attribute it has been looking for.
5252///
5353/// The state machine is automatically reset to parse attributes on the next item.
54+ ///
55+ /// For a simpler attribute parsing interface, consider using [`SingleAttributeParser`]
56+ /// or [`CombineAttributeParser`] instead.
5457pub ( crate ) trait AttributeParser : Default + ' static {
5558 /// The symbols for the attributes that this parser is interested in.
5659 ///
@@ -59,6 +62,12 @@ pub(crate) trait AttributeParser: Default + 'static {
5962
6063 /// The parser has gotten a chance to accept the attributes on an item,
6164 /// here it can produce an attribute.
65+ ///
66+ /// All finalize methods of all parsers are unconditionally called.
67+ /// This means you can't unconditionally return `Some` here,
68+ /// that'd be equivalent to unconditionally applying an attribute to
69+ /// every single syntax item that could have attributes applied to it.
70+ /// Your accept mappings should determine whether this returns something.
6271 fn finalize ( self , cx : & FinalizeContext < ' _ > ) -> Option < AttributeKind > ;
6372}
6473
You can’t perform that action at this time.
0 commit comments