Skip to content

docs: add documentation for find_all_refs constructor search #19861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

vremyavnikuda
Copy link
Contributor

@vremyavnikuda vremyavnikuda commented May 25, 2025

docs(find_all_refs): document constructor search behavior

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 25, 2025
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 25, 2025
@vremyavnikuda vremyavnikuda force-pushed the docs/find-all-refs-constructor-search branch from abc321e to 0902094 Compare May 26, 2025 08:56
@rustbot
Copy link
Collaborator

rustbot commented May 26, 2025

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please remove them as they will spam the issue with references to the commit.

@rustbot rustbot removed has-merge-commits S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 26, 2025
@vremyavnikuda vremyavnikuda changed the title docs: add documentation for find_all_refs constructor search (#10725) docs: add documentation for find_all_refs constructor search May 26, 2025
@vremyavnikuda vremyavnikuda force-pushed the docs/find-all-refs-constructor-search branch from 1a68f66 to a2b58e2 Compare May 26, 2025 09:41
Comment on lines 517 to 586
/// Find all references to the item at the cursor position.
///
/// # Examples
///
/// Basic struct reference search:
/// ```rust
/// struct S {
/// pub x: usize,
/// }
///
/// fn print_s(s: S) {
/// println!("{}", s.x)
/// }
///
/// fn main() {
/// let s = S { x: 42 }; // This is a constructor usage
/// print_s(s); // This is a type reference
/// }
/// ```
///
/// To find only constructor/initialization usages:
/// 1. Position cursor on special tokens in struct/enum definition:
/// ```rust
/// // On '{' - finds record struct initializations
/// struct Point { // <- cursor here on '{'
/// x: i32,
/// y: i32,
/// }
///
/// // On '(' - finds tuple struct initializations
/// struct Tuple(i32, i32); // <- cursor here on '('
///
/// // On ';' - finds unit struct initializations
/// struct Unit; // <- cursor here on ';'
/// ```
///
/// 2. Examples of what will be found:
/// ```rust
/// struct Point{x: i32, y: i32};
/// struct Tuple(i32, i32);
/// struct Unit;
///
///
/// let p1 = Point { x: 0, y: 0 }; // Found when cursor on '{'
/// let p2 = Tuple(1, 2); // Found when cursor on '('
/// let u = Unit; // Found when cursor on ';'
/// ```
///
/// 3. For enum variants:
/// ```rust
/// enum E {
/// Struct { // <- cursor here on '{'
/// x: i32
/// },
/// Tuple(i32), // <- cursor here on '('
/// Unit // <- cursor here on identifier
/// }
///
/// let e1 = E::Struct { x: 0 }; // Found for Struct variant
/// let e2 = E::Tuple(1); // Found for Tuple variant
/// let e3 = E::Unit; // Found for Unit variant
/// ```
///
/// # Parameters
/// * `position` - The position in the file to find references for
/// * `search_scope` - Optional scope to limit the search
///
/// # Returns
/// Returns a vector of reference search results if references are found,
/// or None if no valid item is found at the position.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems duplicated-ish. We already have the relevant docs on the implementation now, so I don't think retelling this here is beneficial (aspecially as we now have multiple places to update the docs of the features change)

Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril Veykril added this pull request to the merge queue May 30, 2025
Merged via the queue into rust-lang:master with commit e65ddda May 30, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants