rust-lang / rust-lang/rust-analyzer

Feature request: “Create file” assist for `include` macro family

Open
#11,019 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I propose that if the file that a user tries to include with the built-in macro include or include_str (maybe also include_bytes) does not exist, RA should offer an assist to create it (and any folders leading to it if necessary) similar to the “Create module” assist.

It's left to decide when exactly this assist can trigger: Does the cursor need to be inside of the string literal or can it also rest on the macro path? If the latter is valid, too, it probably makes sense to accept include/include_strs with non string literal arguments (e.g. in$0clude!(concat!("prefix/", include_str!("extra"))) with the cursor $0).

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 reading the existing “Create module” assist and the handling of Rust’s built-in include, include_str, and possibly include_bytes macros. Clarify whether the assist triggers inside the string literal, on the macro path, or both, including non-literal arguments. Done means offering creation of the missing file and any required parent folders.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.