rustc_attr_parsing/attributes/
confusables.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//! Parsing and validation of builtin attributes

use rustc_ast::MetaItemInner;
use rustc_ast::attr::AttributeExt;
use rustc_span::Symbol;

/// Read the content of a `rustc_confusables` attribute, and return the list of candidate names.
pub fn parse_confusables(attr: &impl AttributeExt) -> Option<Vec<Symbol>> {
    let metas = attr.meta_item_list()?;

    let mut candidates = Vec::new();

    for meta in metas {
        let MetaItemInner::Lit(meta_lit) = meta else {
            return None;
        };
        candidates.push(meta_lit.symbol);
    }

    Some(candidates)
}