Skip to content

Renaming import, cause it to rename in the cached source file as well #17318

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

Closed
ariaandika opened this issue May 31, 2024 · 2 comments · Fixed by #17360
Closed

Renaming import, cause it to rename in the cached source file as well #17318

ariaandika opened this issue May 31, 2024 · 2 comments · Fixed by #17360
Assignees
Labels
Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug

Comments

@ariaandika
Copy link

rust-analyzer version: from rust-analyzer -V: rust-analyzer 0.3.1975-standalone, from nvim mason installed version 2024-05-27

rustc version: rustc 1.78.0 (9b00956e5 2024-04-29)

editor or extension: nvim --version: NVIM v0.10.0

relevant settings: RUSTC_WRAPPER=sccache

step to reproduce:
cargo init

cargo add axum

use axum::response::Html;

fn main() {
    let app = Html("awd");
}

then use "rename" (F2), in use axum::response::Html

use axum::response::Html as HtmlRespone;

fn main() {
    let app = HtmlRespone("awd");
}

rm -rf ./target/, because its not affect this project that use source in ./target/, instead its affect other new project that uses cache in ~/.cargo/registry/src

cargo build

error[E0412]: cannot find type `HtmlResponse` in this scope
   --> /home/deuzo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.7.5/src/response/mod.rs:41:26
    |
41  | impl<T> IntoResponse for HtmlResponse<T>
    |                          ^^^^^^^^^^^^ help: a trait with a similar name exists: `IntoResponse`
    |
   ::: /home/deuzo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-core-0.4.3/src/response/into_response.rs:112:1
    |
112 | pub trait IntoResponse {
    | ---------------------- similarly named trait `IntoResponse` defined here

error[E0412]: cannot find type `HtmlResponse` in this scope
   --> /home/deuzo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.7.5/src/response/mod.rs:57:21
    |
57  | impl<T> From<T> for HtmlResponse<T> {
    |                     ^^^^^^^^^^^^ help: a trait with a similar name exists: `IntoResponse`
    |
   ::: /home/deuzo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-core-0.4.3/src/response/into_response.rs:112:1
    |
112 | pub trait IntoResponse {
    | ---------------------- similarly named trait `IntoResponse` defined here

For more information about this error, try `rustc --explain E0412`.
error: could not compile `axum` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

the source file in cache renamed

also when i 'write all' in neovim, it shows that it writen file inside ~/.cargo directory

@ariaandika ariaandika added the C-bug Category: bug label May 31, 2024
@julianh-y
Copy link

julianh-y commented Jun 6, 2024

I hit the same issue with Emacs + eglot + rust-analyzer (71a816a90 2024-05-26)

use axum::{
    //...
    Router,
};

renaming Router to AxumRouter resulted in

use axum::{
    //...
    Router as AxumRouter,
};

with the unexpected side effect of also renaming everything in ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.7.5

@Veykril Veykril added the Broken Window Bugs / technical debt to be addressed immediately label Jun 7, 2024
@Veykril
Copy link
Member

Veykril commented Jun 7, 2024

Broke in #16489

@Veykril Veykril self-assigned this Jun 7, 2024
@bors bors closed this as completed in 4735576 Jun 7, 2024
lnicola pushed a commit to lnicola/rust that referenced this issue Jun 23, 2024
fix: Fix renaming imports of foreign items touching foreign sources

Fixes rust-lang/rust-analyzer#17318
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants