Skip to content

"Extract module to file" extracts module to incorrect path when source module's location is specified with #[path] #17181

Closed
@selenography

Description

@selenography

rust-analyzer version: 0.3.1940-standalone (f216be4 2024-04-27)

rustc version: rustc 1.79.0-nightly (0d8b3346a 2024-04-14)

editor or extension: VSCode; rust-analyzer v0.3.1940

relevant settings: None applicable

code snippet to reproduce:
In src/main.rs:

#[path="parser/__mod.rs"]
mod parser;

fn main() {}

In src/parser/__mod.rs:

mod expr {};

Place the cursor on expr and invoke the "Extract module to file" assist.

Expected behavior:
The line in __mod.rs becomes mod expr;, and a new empty file is created at parser/expr.rs.

Actual behavior:
The line in __mod.rs becomes mod expr;, and a new empty file is created at parser/parser/expr.rs (where it will not be recognized as part of the workspace).

Metadata

Metadata

Assignees

Labels

C-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions