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 /crates/ra_syntax/src/ast/generated | |
parent | 2a5ab9f5ddc2f60a9229904c412ac943e894c4b7 (diff) |
Add a doc comment on the difference between Name and NameRef ast nodes
Diffstat (limited to 'crates/ra_syntax/src/ast/generated')
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 17 |
1 files changed, 16 insertions, 1 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 ❱) ❱; |