Skip to content
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

Rename symbol - No file available to rename #14379

Closed
tekumara opened this issue Mar 19, 2023 · 11 comments · Fixed by #14407
Closed

Rename symbol - No file available to rename #14379

tekumara opened this issue Mar 19, 2023 · 11 comments · Fixed by #14407
Labels
A-macro macro expansion C-bug Category: bug

Comments

@tekumara
Copy link

When trying to rename a symbol (by pressing F2) I get:

[Error - 20:35:06] Request textDocument/rename failed.
  Message: No file available to rename
  Code: -32602 
CleanShot.2023-03-19.at.20.39.58-converted.mp4

rust-analyzer version: rust-analyzer version: 0.3.1435-standalone (f1e51af 2023-03-12)

rustc version: rustc 1.68.0 (2c8cc3432 2023-03-06) (built from a source tarball)

@tekumara tekumara added the C-bug Category: bug label Mar 19, 2023
@lnicola lnicola added the A-macro macro expansion label Mar 19, 2023
@lnicola
Copy link
Member

lnicola commented Mar 19, 2023

Probably a duplicate of #13388.

@lnicola lnicola added the S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work. label Mar 19, 2023
@djc
Copy link

djc commented Mar 20, 2023

I also noticed this today. Feels likely that there is a regression somehow? The code where I'm running into this is using #[tracing::instrument].

@HKalbasi
Copy link
Member

Can someone check if it happens before #14232 ? (Or more generally bisect it)

@Veykril
Copy link
Member

Veykril commented Mar 20, 2023

It is likely that PR + the one where I fixed reference search not working in attributes again.
https://github.com/veykril/rust-analyzer/blob/66636939a63237fb7a6d1198dd9f92514807621e/crates/ide-db/src/rename.rs#L466

This line should try mapping out of macro calls and only error if the definition can't be mapped to macro inputs (we should also adjust the error stating that the definition comes from a macro and hence can't be renamed)

@mikkelens
Copy link

mikkelens commented Mar 22, 2023

I have also encountered this error (also using tokio) and I can't manage to get symbol renaming working again. It worked earlier today, even for a while after reloading VSCode with the newest version of rust-analyzer. No idea what prompted it to break only after a while.

@memark
Copy link

memark commented Mar 23, 2023

Here is an MRE:

Renaming the variable does work

async fn main() {
    let a = 1;
}

Renaming the variable doesn't work

#[tokio::main]
async fn main() {
    let a = 1;
}

@Veykril Veykril removed the S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work. label Mar 23, 2023
@ruabmbua
Copy link
Contributor

Also started to experience this with #[async_std::main]

@memark
Copy link

memark commented Mar 25, 2023

Also noted it has other effects, e.g. "Extract into function" refactoring disappears from the right-click context menu in VS Code.

@ThinkerDreamer
Copy link

ThinkerDreamer commented Apr 18, 2024

I just had the same issue with a slightly different error message while using the #[axum_macros::debug_handler] macro attribute.

[Error - 2:49:13 PM] Request textDocument/rename failed.
  Message: Cannot rename a non-local definition
  Code: -32602 

rust-analyzer version: 3.1924
rustc version: 1.74.0

It's the same error message as #15656, but I can successfully rename the fn when I comment out the macro attribute

@Veykril
Copy link
Member

Veykril commented Apr 18, 2024

That will need more information than that, ideally a snippet that caused this

@ThinkerDreamer
Copy link

ThinkerDreamer commented Apr 18, 2024

#[axum_macros::debug_handler]
pub async fn login(Json(input): Json<LoginRequest>) -> impl IntoResponse {
    println!("{input:?}");
    StatusCode::OK.into_response()
}

Trying to rename the login fn (by pressing F2 in VSCode) doesn't work when I have the macro uncommented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants