rust-lang / rust-lang/rust-analyzer
Feature Request: Completion for class function that is not inherent method
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
According to Rust API guidelines,
Smart pointers do not add inherent methods (C-SMART-PTR)
Therefore, smart pointer structs, such as Box, Arc
have many class function that is not method,
and the first parameter is the type itself
such as Box::into_raw, Arc::into_inner
pub fn into_raw(b: Box<T, A>) -> *mut T
pub fn into_inner(this: Arc<T, A>) -> Option<T>
Is it possible to add these functions to completion, when I press the period character after the object variable?
The functions can be limited to the function whose first parameter is Self, &Self, &mut Self
For example
let foo = Arc::new(1);
let bar = foo.
Is it possible to show Arc::into_inner in the completion list?
When the completion is accepted, the code is automatically rewritten to
let foo = Arc::new(1);
let bar = Arc::into_inner(foo);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Start by locating the completion entry point for a period after an expression, then trace how associated functions and their first parameter types are represented. Done means eligible functions using Self, &Self, or &mut Self appear for smart pointers and acceptance rewrites the call to the associated-function form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100