Skip to content

Commit a2d1254

Browse files
Add documentation for name_value_literal_span methods
1 parent 63816da commit a2d1254

File tree

1 file changed

+14
-0
lines changed
  • compiler/rustc_ast/src/attr

1 file changed

+14
-0
lines changed

compiler/rustc_ast/src/attr/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ impl Attribute {
180180
self.value_str().is_some()
181181
}
182182

183+
/// This is used in case you want the value span instead of the whole attribute. Example:
184+
///
185+
/// ```text
186+
/// #[doc(alias = "foo")]
187+
/// ```
188+
///
189+
/// In here, it'll return a span for `"foo"`.
183190
pub fn name_value_literal_span(&self) -> Option<Span> {
184191
match self.kind {
185192
AttrKind::Normal(ref item, _) => {
@@ -241,6 +248,13 @@ impl MetaItem {
241248
self.value_str().is_some()
242249
}
243250

251+
/// This is used in case you want the value span instead of the whole attribute. Example:
252+
///
253+
/// ```text
254+
/// #[doc(alias = "foo")]
255+
/// ```
256+
///
257+
/// In here, it'll return a span for `"foo"`.
244258
pub fn name_value_literal_span(&self) -> Option<Span> {
245259
Some(self.name_value_literal()?.span)
246260
}

0 commit comments

Comments
 (0)