mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-05 17:36:20 +00:00
Add a doc comment to Attribute::span
There's a lot going on and it's not obvious.
This commit is contained in:
@@ -3413,6 +3413,29 @@ pub struct Attribute {
|
||||
/// Denotes if the attribute decorates the following construct (outer)
|
||||
/// or the construct this attribute is contained within (inner).
|
||||
pub style: AttrStyle,
|
||||
|
||||
/// The carets in the examples below show the spans for various cases.
|
||||
/// ```text
|
||||
/// #[foo] - A vanilla parsed attribute.
|
||||
/// ^^^^^^ - Its span covers it all.
|
||||
///
|
||||
/// /** abc */ /// xyz - A parsed doc comment.
|
||||
/// ^^^^^^^^^^ ^^^^^^^ - Its span covers the text and comment marker(s).
|
||||
/// - The same span is also used if the doc comment is desugared (into
|
||||
/// a new normal `#[doc = r"..."]` attribute) by
|
||||
/// `desugar_doc_comments` before being passed to a macro (which
|
||||
/// is done so that `#[$m:meta]` will match).
|
||||
///
|
||||
/// #[cfg_attr(pred, foo)] - A parsed `cfg_attr` attribute.
|
||||
/// ^^^^^^^^^^^^^^^^^^^^^^ - Its span covers it all.
|
||||
/// ^^^ - Span of the new replacement attribute (equivalent to `#[foo]`)
|
||||
/// created by `cfg_attr` expansion (if `pred` is true).
|
||||
/// ^^^^^^^^^^^^^^^^^^^^^^ - Span of the synthetic `CfgAttrTrace` attribute created by
|
||||
/// `cfg_attr` expansion. (`CfgTrace` is derived from `#[cfg(..)]` and
|
||||
/// handled similarly.)
|
||||
/// ```
|
||||
/// Finally, for compiler-generated attributes the span is whatever the construction site
|
||||
/// chooses. Usually `DUMMY_SP` or some relevant span from the source code.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user