rustc_attr_parsing/attributes/
path.rs1use rustc_feature::AttributeStability;
2
3use super::prelude::*;
4
5pub(crate) struct PathParser;
6
7impl SingleAttributeParser for PathParser {
8 const PATH: &[Symbol] = &[sym::path];
9 const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError;
10 const ALLOWED_TARGETS: AllowedTargets =
11 AllowedTargets::AllowListWarnRest(&[Allow(Target::Mod), Error(Target::Crate)]);
12 const TEMPLATE: AttributeTemplate = ::rustc_feature::AttributeTemplate {
word: false,
list: None,
one_of: &[],
name_value_str: Some(&["file"]),
docs: Some("https://doc.rust-lang.org/reference/items/modules.html#the-path-attribute"),
}template!(
13 NameValueStr: "file",
14 "https://doc.rust-lang.org/reference/items/modules.html#the-path-attribute"
15 );
16 const STABILITY: AttributeStability = AttributeStability::Stable;
17
18 fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
19 let nv = cx.expect_name_value(args, cx.attr_span, None)?;
20 let path = cx.expect_string_literal(nv)?;
21
22 Some(AttributeKind::Path(path))
23 }
24}