@@ -97,13 +97,25 @@ impl Definition {
97
97
}
98
98
}
99
99
100
+ /// On a first blush, a single `ast::Name` defines a single definition at some
101
+ /// scope. That is, that, by just looking at the syntactical category, we can
102
+ /// unambiguously define the semantic category.
103
+ ///
104
+ /// Sadly, that's not 100% true, there are special cases. To make sure that call
105
+ /// the code handles all the special cases correctly via exhaustive matching, we
106
+ /// add a [`NameClass`] enum which lists all of them!
107
+ ///
108
+ /// A model special case is `None` constant in pattern.
100
109
#[ derive( Debug ) ]
101
110
pub enum NameClass {
102
111
ExternCrate ( Crate ) ,
103
112
Definition ( Definition ) ,
104
113
/// `None` in `if let None = Some(82) {}`.
114
+ /// Syntactically, it is a name, but semantically it is a reference.
105
115
ConstReference ( Definition ) ,
106
- /// `field` in `if let Foo { field } = foo`.
116
+ /// `field` in `if let Foo { field } = foo`. Here, `ast::Name` both Here the
117
+ /// name both introduces a definition into a local scope, and refers to an
118
+ /// existing definition.
107
119
PatFieldShorthand {
108
120
local_def : Local ,
109
121
field_ref : Definition ,
@@ -283,6 +295,12 @@ impl NameClass {
283
295
}
284
296
}
285
297
298
+ /// This is similar to [`NameClass`], but works for [`ast::NameRef`] rather than
299
+ /// for [`ast::Name`]. Similarly, what looks like a reference in syntax is a
300
+ /// reference most of the time, but there are a couple of annoying exceptions.
301
+ ///
302
+ /// A model special case is field shorthand syntax, which uses a single
303
+ /// reference to point to two different defs.
286
304
#[ derive( Debug ) ]
287
305
pub enum NameRefClass {
288
306
ExternCrate ( Crate ) ,
0 commit comments