Refactor Suggestion: Convert module to subdir

Hi. Been using the rust-analyzer extensions for VS Code (with OSS build) it's amazing how far the dev experience has improved over the years.

I have an idea for a Refactor. I have a module and I want to covert it to a folder: ie allocator/
However I'm not sure how the whole code<->lsp<->Analyzer thing all ties together so where would I want to try and contribute this in a way that's usable by the most people. I would like to get Rust's refactoring tools to be at least as good as VS+C# at some point. So every little bit helps.

The best explanation for this is:

This specific refactoring shouldn't be hard to implement, but is non-trivial in terms of user-experience we can provide.

Generally, in rust 2018 most of the folks don't use at all. So they'd have file with mod submodulue; in it, and allocator/ This layout is supported in rust-analyzer today: if you type mod submodule;, the red squiggly contains a quick fix for creating a corresponding file.

That being said, is not deprecated and some people use this old style instead. (I also happen to prefer the old style, but I use new style for consistency). I think a good change to the above quick fix would be to check if all modules in the current crate happen to use pattern, and, if that's the case, rename to allocator/ as well. Here's the relevant source code:

It would also help to have a code action / fixit on the file itself, so that one can ctrl+. in the explorer. I think that is not supported by either VS Code or LSP. Opened Feature Request: allow Code Actions on files/directories · Issue #1239 · microsoft/language-server-protocol · GitHub for that.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.