rust-lang / rust-lang/rust-analyzer

Inverse to `move_module_to_file`; move module to inline

Open
#11,463 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-assists C-feature S-actionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

In a project which has a ton of "noise" wrt module structure, I find it nice to inline modules into their relevant files, to be able to use modules as semantic units for library API isolation.

Example of the project structure;
image

get_public_rooms_filtered.rs is then simply;

pub mod v1;

It'd be nice if I could do the reverse of move_module_to_file, and have a code action on that module identifier that would move the entire file to the inline module, and take care of removing the corresponding file (and folder, if it's then empty).

Suggested name; move_module_to_inline

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing move_module_to_file implementation and its code action entry point. Trace how it moves module contents and handles the source file, then implement the inverse for move_module_to_inline; done means the module is inlined and the corresponding file and any empty folder are removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.