File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
crates/ra_syntax/src/ast/generated Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -1790,7 +1790,20 @@ impl Visibility {
1790
1790
pub fn crate_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ crate ] ) }
1791
1791
}
1792
1792
/// Single identifier.
1793
- /// // TODO: clarify the difference between Name and NameRef
1793
+ /// Note(@matklad): `Name` is for things that install a new name into the scope,
1794
+ /// `NameRef` is a usage of a name. Most of the time, this definition/reference
1795
+ /// distinction can be determined purely syntactically, ie in
1796
+ /// ```
1797
+ /// fn foo() { foo() }
1798
+ /// ```
1799
+ /// the first foo is `Name`, the second one is `NameRef`.
1800
+ /// The notable exception are patterns, where in
1801
+ /// ``
1802
+ /// let x = 92
1803
+ /// ```
1804
+ /// `x` can be semantically either a name or a name ref, depeding on
1805
+ /// wether there's an `x` constant in scope.
1806
+ /// We use `Name` for patterns, and disambiguate semantically (see `NameClass` in ide_db).
1794
1807
///
1795
1808
/// ```
1796
1809
/// let ❰ foo ❱ = bar;
@@ -1807,6 +1820,8 @@ impl Name {
1807
1820
pub fn ident_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ident] ) }
1808
1821
}
1809
1822
/// Reference to a name.
1823
+ /// See the explanation on the difference between `Name` and `NameRef`
1824
+ /// in `Name` ast node docs.
1810
1825
///
1811
1826
/// ```
1812
1827
/// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱;
Original file line number Diff line number Diff line change @@ -1522,7 +1522,20 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
1522
1522
struct Visibility { T ![ pub ] , T ![ super ] , T ![ self ] , T ![ crate ] }
1523
1523
1524
1524
/// Single identifier.
1525
- /// // TODO: clarify the difference between Name and NameRef
1525
+ /// Note(@matklad): `Name` is for things that install a new name into the scope,
1526
+ /// `NameRef` is a usage of a name. Most of the time, this definition/reference
1527
+ /// distinction can be determined purely syntactically, ie in
1528
+ /// ```
1529
+ /// fn foo() { foo() }
1530
+ /// ```
1531
+ /// the first foo is `Name`, the second one is `NameRef`.
1532
+ /// The notable exception are patterns, where in
1533
+ /// ``
1534
+ /// let x = 92
1535
+ /// ```
1536
+ /// `x` can be semantically either a name or a name ref, depeding on
1537
+ /// wether there's an `x` constant in scope.
1538
+ /// We use `Name` for patterns, and disambiguate semantically (see `NameClass` in ide_db).
1526
1539
///
1527
1540
/// ```
1528
1541
/// let ❰ foo ❱ = bar;
@@ -1534,6 +1547,8 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
1534
1547
struct Name { T ![ ident] }
1535
1548
1536
1549
/// Reference to a name.
1550
+ /// See the explanation on the difference between `Name` and `NameRef`
1551
+ /// in `Name` ast node docs.
1537
1552
///
1538
1553
/// ```
1539
1554
/// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱;
You can’t perform that action at this time.
0 commit comments