rust-lang / rust-lang/rust-analyzer
Rename operation does not rename examples in docstrings
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Given cargo new --lib rename with contents:
/// Prints "Hello, world!".
///
/// # Example
/// ```rust
/// use rename::hello;
/// hello();
/// ```
pub fn hello() {
println!("Hello, world!");
}
and using the rename operation (F2 in VSCode) on the hello() function, you end up with
/// Prints "Hello, world!".
///
/// # Example
/// ```rust
/// use rename::hello;
/// hello();
/// ```
pub fn hello_world() {
println!("Hello, world!");
}
which results in cargo test breaking:
---- src/lib.rs - hello_world (line 4) stdout ----
error[E0432]: unresolved import `rename::hello`
--> src/lib.rs:5:5
|
4 | use rename::hello;
| ^^^^^^^^^^^^^ no `hello` in the root
error: aborting due to previous error
Considering rust-analyzer manages to provide syntax highlighting within the docstring example blocks, it would be nice if the rename operation affected the docstrings as well.
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
Reproduce the issue with the shown cargo new --lib rename example and the VSCode F2 rename operation, then run cargo test to confirm the doctest failure. Trace how rename handles symbols in Rust docstring example blocks; done means the renamed function and its references in the example stay consistent and cargo test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100