From a2d1254e22c37b359a8b89e13a5dd288cc69a268 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 1 Dec 2020 17:32:14 +0100 Subject: [PATCH] Add documentation for name_value_literal_span methods --- compiler/rustc_ast/src/attr/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 22539bb1d9d..19c7c479f04 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -180,6 +180,13 @@ impl Attribute { self.value_str().is_some() } + /// This is used in case you want the value span instead of the whole attribute. Example: + /// + /// ```text + /// #[doc(alias = "foo")] + /// ``` + /// + /// In here, it'll return a span for `"foo"`. pub fn name_value_literal_span(&self) -> Option { match self.kind { AttrKind::Normal(ref item, _) => { @@ -241,6 +248,13 @@ impl MetaItem { self.value_str().is_some() } + /// This is used in case you want the value span instead of the whole attribute. Example: + /// + /// ```text + /// #[doc(alias = "foo")] + /// ``` + /// + /// In here, it'll return a span for `"foo"`. pub fn name_value_literal_span(&self) -> Option { Some(self.name_value_literal()?.span) }