#[tokio::main] breaks lsp-rename

#[tokio::main] seems to break lsp-rename for me. Specifically, I noticed that changing the name of a variable using lsp-rename does not propagate the name change to instances of the variable when the variable exists within a function decorated with #[tokio::main]. However, other functions not decorated as such continue to work just fine with lsp-rename.

For clarity, renaming foo to bar on line 3 will not change the foo on line 4:

#[tokio::main]
async fn main() {
    let foo = "Hello";
    let baz = foo;
}

Is this a problem for others or just me?

The problem exists for me in VS Code with rust-analyzer v0.3.1277 and in emacs with rustic+lsp-mode using rust-analyzer compiled from source (rust-analyzer 0.0.0 (b8b1951ee 2022-11-07).

I'd check the rust-analyzer issue tracker for this. I've got a feeling this will already be reported somewhere because it'll come from the proc-macro implementation not tracking spans correctly, or not propagating that information through to assists like rename.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.