From 5486b70bc0fa1b6260178fa7e547a534d91c3e04 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 18 Sep 2020 16:43:50 +0200 Subject: Use hir_def to resolve proc macros --- crates/hir_def/src/attr.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/hir_def/src/attr.rs') diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index dea552a60..a841b97bf 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs @@ -171,6 +171,9 @@ pub struct AttrQuery<'a> { } impl<'a> AttrQuery<'a> { + /// For an attribute like `#[attr(value)]`, returns the `(value)` subtree. + /// + /// If the attribute does not have a token tree argument, returns `None`. pub fn tt_values(self) -> impl Iterator { self.attrs().filter_map(|attr| match attr.input.as_ref()? { AttrInput::TokenTree(it) => Some(it), @@ -178,6 +181,9 @@ impl<'a> AttrQuery<'a> { }) } + /// For an attribute like `#[key = "value"]`, returns `"value"`. + /// + /// Returns `None` if the attribute does not have `key = "value"` form. pub fn string_value(self) -> Option<&'a SmolStr> { self.attrs().find_map(|attr| match attr.input.as_ref()? { AttrInput::Literal(it) => Some(it), -- cgit v1.2.3