Expand description
Defines the basics of attributes lowering.
The heart and soul of this module is expand_cfg_attr(), alongside its sibling
expand_cfg_attr_with_doc_comments(). It is used to implement all attribute lowering
in r-a. Its basic job is to list attributes; however, attributes do not necessarily map
into [ast::Attr], because cfg_attr can map to zero, one, or more attributes
(#[cfg_attr(predicate, attr1, attr2, ...)]). expand_cfg_attr() expands cfg_attrs
as it goes (as its name implies), to list all attributes.
Another thing to note is that we need to be able to map an attribute back to a range
(for diagnostic purposes etc.). This is only ever needed for attributes that participate
in name resolution. An attribute is mapped back by its AttrId, which is just an
index into the item tree attributes list. To minimize the risk of bugs, we have one
place (here) and one function (is_item_tree_filtered_attr()) that decides whether
an attribute participate in name resolution.
Structsยง
Enumsยง
Traitsยง
Functionsยง
- collect_
item_ tree_ attrs - This collects attributes exactly as the item tree needs them. This is used for the item tree,
as well as for resolving
AttrIds. - expand_
cfg_ attr - The callback is passed the attribute and the outermost
ast::Attr. Note that one node may map to multiple [ast::Meta]s due tocfg_attr. - expand_
cfg_ attr_ with_ doc_ comments - is_
item_ ๐tree_ filtered_ attr - parse_
path_ ๐comma_ token_ tree - unescape ๐