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

Extracting method ignores existing impl block #4520

Closed
Tracked by #2183
krojew opened this issue Oct 10, 2019 · 0 comments · Fixed by #7637
Closed
Tracked by #2183

Extracting method ignores existing impl block #4520

krojew opened this issue Oct 10, 2019 · 0 comments · Fixed by #7637
Labels
improvement subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc. subsystem::refactoring Issues related to refactorings

Comments

@krojew
Copy link

krojew commented Oct 10, 2019

Environment

  • IntelliJ Rust plugin version: 0.2.107.2137-192
  • Rust toolchain version: 1.40 nightly
  • IDE name and version: CLion 2019.2.4
  • Operating system: Windows 10

Problem description

When trying to extract a block of code from a method to a new method, a new impl block for given struct is created even when there's an existing one already.

Steps to reproduce

struct Foo;

trait Bar {
    fn foo();
}

impl Bar for Foo {
   fn foo() {
       // extract some code from here
   }
}

impl Foo {
}

mod tests {
}

// new impl Foo {} block gets created here
@Undin Undin mentioned this issue Feb 6, 2020
20 tasks
@artemmukhin artemmukhin added improvement subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc. subsystem::refactoring Issues related to refactorings labels Feb 6, 2020
bors bot added a commit that referenced this issue Sep 6, 2021
7506: RUN: Fix macros and generated items support for WSL toolchains r=vlad20012 a=mchernyavsky

changelog: Fix macros and generated items support for WSL toolchains

Fixes
```
2021-07-11 21:11:39,418 [71319350]   WARN - st.cargo.toolchain.tools.Cargo - Execution failed (exit code 101).
C:\WINDOWS\system32\wsl.exe --distribution Ubuntu --exec /bin/sh -c "export PATH=\"/home/misha/.cargo/bin:$PATH\" && export RUST_BACKTRACE=short && export RUSTC_WRAPPER=/mnt/c/Users/Mikhail/IdeaProjects/intellij-rust/plugin/build/clion-sandbox-212/plugins/intellij-rust/bin/windows/x86-64/intellij-rust-native-helper.exe && export TERM=ansi && cd /mnt/c/Users/Mikhail/CLionProjects/untitled8 && /home/misha/.cargo/bin/cargo check --message-format json"
stdout : error: failed to join search paths together
Does $LD_LIBRARY_PATH have an unterminated quote character?

Caused by:
  failed to join path array: ["/mnt/c/Users/Mikhail/CLionProjects/untitled8/target/debug/deps", "C:\\Users\\Mikhail\\.rustup\\toolchains\\nightly-2020-10-04-x86_64-pc-windows-msvc/lib", "/home/misha/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib"]

Caused by:
  path segment contains separator `:`

stderr :  
com.intellij.execution.ExecutionException: Execution failed (exit code 101).
C:\WINDOWS\system32\wsl.exe --distribution Ubuntu --exec /bin/sh -c "export PATH=\"/home/misha/.cargo/bin:$PATH\" && export RUST_BACKTRACE=short && export RUSTC_WRAPPER=/mnt/c/Users/Mikhail/IdeaProjects/intellij-rust/plugin/build/clion-sandbox-212/plugins/intellij-rust/bin/windows/x86-64/intellij-rust-native-helper.exe && export TERM=ansi && cd /mnt/c/Users/Mikhail/CLionProjects/untitled8 && /home/misha/.cargo/bin/cargo check --message-format json"
stdout : error: failed to join search paths together
Does $LD_LIBRARY_PATH have an unterminated quote character?

Caused by:
  failed to join path array: ["/mnt/c/Users/Mikhail/CLionProjects/untitled8/target/debug/deps", "C:\\Users\\Mikhail\\.rustup\\toolchains\\nightly-2020-10-04-x86_64-pc-windows-msvc/lib", "/home/misha/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib"]

Caused by:
  path segment contains separator `:`

stderr : 
	at org.rust.openapiext.CommandLineExtKt.execute(CommandLineExt.kt:108)
	at org.rust.cargo.toolchain.tools.Cargo.execute(Cargo.kt:412)
	at org.rust.cargo.toolchain.tools.Cargo.execute$default(Cargo.kt:406)
	at org.rust.cargo.toolchain.tools.Cargo.fetchBuildScriptsInfo(Cargo.kt:204)
	at org.rust.cargo.toolchain.tools.Cargo.fullProjectDescription(Cargo.kt:134)
	at org.rust.cargo.project.model.impl.CargoSyncTaskKt$fetchCargoWorkspace$1.invoke(CargoSyncTask.kt:316)
	at org.rust.cargo.project.model.impl.CargoSyncTaskKt$fetchCargoWorkspace$1.invoke(CargoSyncTask.kt:306)
	at org.rust.cargo.project.model.impl.CargoSyncTaskKt.runWithChildProgress(CargoSyncTask.kt:409)
	at org.rust.cargo.project.model.impl.CargoSyncTaskKt.access$runWithChildProgress(CargoSyncTask.kt:1)
	at org.rust.cargo.project.model.impl.CargoSyncTask$SyncContext.runWithChildProgress(CargoSyncTask.kt:178)
	at org.rust.cargo.project.model.impl.CargoSyncTaskKt.fetchCargoWorkspace(CargoSyncTask.kt:306)
	at org.rust.cargo.project.model.impl.CargoSyncTaskKt.access$fetchCargoWorkspace(CargoSyncTask.kt:1)
	at org.rust.cargo.project.model.impl.CargoSyncTask$doRun$refreshedProjects$1$2.invoke(CargoSyncTask.kt:118)
	at org.rust.cargo.project.model.impl.CargoSyncTask$doRun$refreshedProjects$1$2.invoke(CargoSyncTask.kt:109)
	at org.rust.cargo.project.model.impl.CargoSyncTaskKt.runWithChildProgress(CargoSyncTask.kt:409)
	at org.rust.cargo.project.model.impl.CargoSyncTaskKt.runWithChildProgress$default(CargoSyncTask.kt:400)
	at org.rust.cargo.project.model.impl.CargoSyncTask.doRun(CargoSyncTask.kt:106)
	at org.rust.cargo.project.model.impl.CargoSyncTask.run(CargoSyncTask.kt:74)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:450)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:117)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:510)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:243)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:183)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:705)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:647)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:170)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:243)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:829)
```

7637: REF: Use existing impl block in "Extract function" refactoring r=ortem a=dima74

Fixes #4520

changelog: Use existing impl block if possible in "Extract function" refactoring

Co-authored-by: mchernyavsky <mikhail.chernyavsky@jebrains.com>
Co-authored-by: Dmitry Murzin <diralik@yandex.ru>
@bors bors bot closed this as completed in 6191e97 Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc. subsystem::refactoring Issues related to refactorings
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants