rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
13.97k stars 1.55k forks source link

Only get 'extract to variable' not 'extract to function' in vscode #17280

Open rbtcollins opened 2 months ago

rbtcollins commented 2 months ago

Very similar to https://github.com/rust-lang/rust-analyzer/issues/11577, but happening in VSCode, and as far as I know the files are part of the project - certainly they are in git and in a regular cargo crate in a regular cargo workspace.

rust-analyzer version: rust-analyzer version: 0.3.1958-standalone

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

editor or extension: VSCode v0.3.1958

relevant settings: nothing special

repository link (if public, optional): private sorry,

code snippet to reproduce: (copied from the troubleshooting guide into my program, then attempted the same extraction).

        let n = 1;
        let m = n + 2;
        // calculate
        let k = m + n;
        let g = 3;

image

lnicola commented 2 months ago

Can't reproduce, AFAICT:

image

image

toondehaene commented 1 month ago

I have the same issue:

rust-analyzer version: Version 0.3.2011, Server Version 0.3.2011-standalone

rustc version: rustc 1.74.0 (79e9716c9 2023-11-13)

VSCode info: Version: 1.90.2 Date: 2024-06-18T22:33:48.698Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Linux x64 6.8.0-76060800daily20240311-generic

code snippet to reproduce: I did the same snippet as @rbtcollins

rbtcollins commented 1 month ago

@lnicola are there additional debugging steps we can provide?