Lines Matching full:path
13 use crate::path::Path;
47 /// Every attribute has a `path` that indicates the intended interpretation
48 /// of the rest of the attribute's contents. The path and the optional
52 /// - Meta::Path — attributes whose information content conveys just a
53 /// path, for example the `#[test]` attribute.
56 /// path, surrounded by a delimiter (parenthesis, bracket, or brace). For
59 /// - Meta::NameValue — attributes with an `=` sign after the path,
60 /// followed by a Rust expression. For example `#[path =
63 /// All doc comments are represented in the NameValue style with a path of
69 /// ~~~~~~Path
72 /// #[path = "sys/windows.rs"]
73 /// ~~~~Path
77 /// ^^^^Meta::Path
100 /// // #[path = "s.tmpl"]
128 /// TokenStream`. Macros are expected to check the `path` of the attribute,
184 /// Returns the path that identifies the interpretation of this attribute.
187 /// `#[derive(Copy)]`, and the `path` in `#[path = "sys/windows.rs"]`.
188 pub fn path(&self) -> &Path { in path() argument
189 self.meta.path() in path()
216 /// if attr.path().is_ident("precondition") {
249 Meta::Path(path) => Err(crate::error::new2( in parse_args_with()
250 path.segments.first().unwrap().ident.span(), in parse_args_with()
251 path.segments.last().unwrap().ident.span(), in parse_args_with()
255 parsing::DisplayPath(path), in parse_args_with()
263 parsing::DisplayPath(&meta.path), in parse_args_with()
298 /// if attr.path().is_ident("repr") {
301 /// if meta.path.is_ident("C") {
307 /// if meta.path.is_ident("transparent") {
313 /// if meta.path.is_ident("align") {
323 /// if meta.path.is_ident("packed") {
364 /// if attr.path().is_ident("repr") {
369 /// Meta::Path(path) if path.is_ident("C") => {
374 /// Meta::List(meta) if meta.path.is_ident("align") => {
456 /// ## Path
458 /// A meta path is like the `test` in `#[test]`.
466 /// A name-value meta is like the `path = "..."` in `#[path =
476 Path(Path),
490 pub path: Path,
500 pub path: Path,
507 /// Returns the path that begins this structured meta item.
510 /// `#[derive(Copy)]`, and the `path` in `#[path = "sys/windows.rs"]`.
511 pub fn path(&self) -> &Path { in path() argument
513 Meta::Path(path) => path, in path()
514 Meta::List(meta) => &meta.path, in path()
515 Meta::NameValue(meta) => &meta.path, in path()
522 pub fn require_path_only(&self) -> Result<&Path> { in require_path_only() argument
524 Meta::Path(path) => return Ok(path), in require_path_only()
531 /// Error if this is a `Meta::Path` or `Meta::NameValue`.
537 Meta::Path(path) => Err(crate::error::new2( in require_list()
538 path.segments.first().unwrap().ident.span(), in require_list()
539 path.segments.last().unwrap().ident.span(), in require_list()
542 parsing::DisplayPath(path), in require_list()
549 /// Error if this is a `Meta::Path` or `Meta::List`.
555 Meta::Path(path) => Err(crate::error::new2( in require_name_value()
556 path.segments.first().unwrap().ident.span(), in require_name_value()
557 path.segments.last().unwrap().ident.span(), in require_name_value()
560 parsing::DisplayPath(path), in require_name_value()
630 impl From<Path> for Meta {
631 fn from(meta: Path) -> Meta { in from()
632 Meta::Path(meta) in from()
656 use crate::path::Path;
691 let path = parse_outermost_meta_path(input)?; in parse() localVariable
692 parse_meta_after_path(path, input) in parse()
699 let path = parse_outermost_meta_path(input)?; in parse() localVariable
700 parse_meta_list_after_path(path, input) in parse()
707 let path = parse_outermost_meta_path(input)?; in parse() localVariable
708 parse_meta_name_value_after_path(path, input) in parse()
712 // Unlike meta::parse_meta_path which accepts arbitrary keywords in the path,
713 // only the `unsafe` keyword is accepted as an attribute's outermost path.
714 fn parse_outermost_meta_path(input: ParseStream) -> Result<Path> { in parse_outermost_meta_path() argument
717 Ok(Path::from(Ident::new("unsafe", unsafe_token.span))) in parse_outermost_meta_path()
719 Path::parse_mod_style(input) in parse_outermost_meta_path()
723 pub(crate) fn parse_meta_after_path(path: Path, input: ParseStream) -> Result<Meta> { in parse_meta_after_path() argument
725 parse_meta_list_after_path(path, input).map(Meta::List) in parse_meta_after_path()
727 parse_meta_name_value_after_path(path, input).map(Meta::NameValue) in parse_meta_after_path()
729 Ok(Meta::Path(path)) in parse_meta_after_path()
733 fn parse_meta_list_after_path(path: Path, input: ParseStream) -> Result<MetaList> { in parse_meta_list_after_path() argument
736 path, in parse_meta_list_after_path()
742 fn parse_meta_name_value_after_path(path: Path, input: ParseStream) -> Result<MetaNameValue> { in parse_meta_name_value_after_path() argument
758 path, in parse_meta_name_value_after_path()
775 pub(super) struct DisplayPath<'a>(pub &'a Path);
793 use crate::path;
794 use crate::path::printing::PathStyle;
815 Meta::Path(path) => path::printing::print_path(tokens, path, PathStyle::Mod), in to_tokens()
825 path::printing::print_path(tokens, &self.path, PathStyle::Mod); in to_tokens()
833 path::printing::print_path(tokens, &self.path, PathStyle::Mod); in to_tokens()