@@ -81,13 +81,19 @@ crate struct ExternalCrate {
8181/// directly to the AST's concept of an item; it's a strict superset.
8282#[ derive( Clone ) ]
8383crate 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.
8788 crate name : Option < Symbol > ,
89+ /// Attributes on this item, e.g. `#[derive(...)]` or `#[inline]`.
8890 crate attrs : Box < Attributes > ,
91+ /// The visibility of this item (private, `pub`, `pub(crate)`, etc.).
8992 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.
9095 crate kind : Box < ItemKind > ,
96+ /// The [`DefId`] of this item.
9197 crate def_id : DefId ,
9298}
9399
@@ -100,7 +106,7 @@ impl fmt::Debug for Item {
100106 let def_id: & dyn fmt:: Debug = if self . is_fake ( ) { & "**FAKE**" } else { & self . def_id } ;
101107
102108 fmt. debug_struct ( "Item" )
103- . field ( "source" , & self . source )
109+ . field ( "source" , & self . span )
104110 . field ( "name" , & self . name )
105111 . field ( "attrs" , & self . attrs )
106112 . field ( "kind" , & self . kind )
@@ -165,7 +171,7 @@ impl Item {
165171 debug ! ( "name={:?}, def_id={:?}" , name, def_id) ;
166172
167173 // `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 (
169175 || cx. tcx . def_span ( def_id) ,
170176 |local| {
171177 let hir = cx. tcx . hir ( ) ;
@@ -177,7 +183,7 @@ impl Item {
177183 def_id,
178184 kind : box kind,
179185 name,
180- source : source . clean ( cx) ,
186+ span : span . clean ( cx) ,
181187 attrs,
182188 visibility : cx. tcx . visibility ( def_id) . clean ( cx) ,
183189 }
0 commit comments