@@ -81,13 +81,19 @@ crate struct ExternalCrate {
81
81
/// directly to the AST's concept of an item; it's a strict superset.
82
82
#[ derive( Clone ) ]
83
83
crate struct Item {
84
- /// Stringified span
85
- crate source : Span ,
86
- /// Not everything has a name. E.g., impls
84
+ /// The [`Span`] of this item in the source code.
85
+ crate span : Span ,
86
+ /// The name of this item.
87
+ /// Optional because not every item has a name, e.g. impls.
87
88
crate name : Option < Symbol > ,
89
+ /// Attributes on this item, e.g. `#[derive(...)]` or `#[inline]`.
88
90
crate attrs : Box < Attributes > ,
91
+ /// The visibility of this item (private, `pub`, `pub(crate)`, etc.).
89
92
crate visibility : Visibility ,
93
+ /// Information about this item that is specific to what kind of item it is.
94
+ /// E.g., struct vs enum vs function.
90
95
crate kind : Box < ItemKind > ,
96
+ /// The [`DefId`] of this item.
91
97
crate def_id : DefId ,
92
98
}
93
99
@@ -100,7 +106,7 @@ impl fmt::Debug for Item {
100
106
let def_id: & dyn fmt:: Debug = if self . is_fake ( ) { & "**FAKE**" } else { & self . def_id } ;
101
107
102
108
fmt. debug_struct ( "Item" )
103
- . field ( "source" , & self . source )
109
+ . field ( "source" , & self . span )
104
110
. field ( "name" , & self . name )
105
111
. field ( "attrs" , & self . attrs )
106
112
. field ( "kind" , & self . kind )
@@ -165,7 +171,7 @@ impl Item {
165
171
debug ! ( "name={:?}, def_id={:?}" , name, def_id) ;
166
172
167
173
// `span_if_local()` lies about functions and only gives the span of the function signature
168
- let source = def_id. as_local ( ) . map_or_else (
174
+ let span = def_id. as_local ( ) . map_or_else (
169
175
|| cx. tcx . def_span ( def_id) ,
170
176
|local| {
171
177
let hir = cx. tcx . hir ( ) ;
@@ -177,7 +183,7 @@ impl Item {
177
183
def_id,
178
184
kind : box kind,
179
185
name,
180
- source : source . clean ( cx) ,
186
+ span : span . clean ( cx) ,
181
187
attrs,
182
188
visibility : cx. tcx . visibility ( def_id) . clean ( cx) ,
183
189
}
0 commit comments