mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Add a doc comment on the difference between Name and NameRef ast nodes
This commit is contained in:
parent
2a5ab9f5dd
commit
24b27abf9f
2 changed files with 32 additions and 2 deletions
|
@ -1790,7 +1790,20 @@ impl Visibility {
|
|||
pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
|
||||
}
|
||||
/// Single identifier.
|
||||
/// // TODO: clarify the difference between Name and NameRef
|
||||
/// Note(@matklad): `Name` is for things that install a new name into the scope,
|
||||
/// `NameRef` is a usage of a name. Most of the time, this definition/reference
|
||||
/// distinction can be determined purely syntactically, ie in
|
||||
/// ```
|
||||
/// fn foo() { foo() }
|
||||
/// ```
|
||||
/// the first foo is `Name`, the second one is `NameRef`.
|
||||
/// The notable exception are patterns, where in
|
||||
/// ``
|
||||
/// let x = 92
|
||||
/// ```
|
||||
/// `x` can be semantically either a name or a name ref, depeding on
|
||||
/// wether there's an `x` constant in scope.
|
||||
/// We use `Name` for patterns, and disambiguate semantically (see `NameClass` in ide_db).
|
||||
///
|
||||
/// ```
|
||||
/// let ❰ foo ❱ = bar;
|
||||
|
@ -1807,6 +1820,8 @@ impl Name {
|
|||
pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
|
||||
}
|
||||
/// Reference to a name.
|
||||
/// See the explanation on the difference between `Name` and `NameRef`
|
||||
/// in `Name` ast node docs.
|
||||
///
|
||||
/// ```
|
||||
/// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue