diff options
author | veetaha <[email protected]> | 2020-05-12 21:31:37 +0100 |
---|---|---|
committer | veetaha <[email protected]> | 2020-05-12 21:31:37 +0100 |
commit | 24b27abf9f3a57268d0fb7c9a1aa2ede2980195f (patch) | |
tree | a017fbf3780dfea221c721fbb6ce870a7aa7abfb | |
parent | 2a5ab9f5ddc2f60a9229904c412ac943e894c4b7 (diff) |
Add a doc comment on the difference between Name and NameRef ast nodes
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 17 | ||||
-rw-r--r-- | xtask/src/ast_src.rs | 17 |
2 files changed, 32 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 7ee4590ba..7b236cd52 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -1790,7 +1790,20 @@ impl Visibility { | |||
1790 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | 1790 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } |
1791 | } | 1791 | } |
1792 | /// Single identifier. | 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 | /// let ❰ foo ❱ = bar; | 1809 | /// let ❰ foo ❱ = bar; |
@@ -1807,6 +1820,8 @@ impl Name { | |||
1807 | pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } | 1820 | pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } |
1808 | } | 1821 | } |
1809 | /// Reference to a name. | 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 | /// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱; | 1827 | /// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱; |
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index d1e34e299..79e5a608d 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs | |||
@@ -1522,7 +1522,20 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
1522 | struct Visibility { T![pub], T![super], T![self], T![crate] } | 1522 | struct Visibility { T![pub], T![super], T![self], T![crate] } |
1523 | 1523 | ||
1524 | /// Single identifier. | 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 | /// let ❰ foo ❱ = bar; | 1541 | /// let ❰ foo ❱ = bar; |
@@ -1534,6 +1547,8 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
1534 | struct Name { T![ident] } | 1547 | struct Name { T![ident] } |
1535 | 1548 | ||
1536 | /// Reference to a name. | 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 | /// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱; | 1554 | /// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱; |