rust-lang / rust-lang/rust-analyzer

Add shebang support for "cargo script"

Open
#15,318 5 comments 44 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-cargo A-project-model B-unstable C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Add an initial shebang support for "cargo script".

Cargo script is an experimental feature for single-file packages described in eRFC-3424.

The initial support would require to recognize and parse the shebang and handle the entire file as a single-file package.

Parsing the manifest would be out of the scope for the moment since it hasn't been stabilized yet. So there would not be support for external packages from crates.io at the moment.

As an extra this initial support could be be beneficial also for other third party alternatives.

I am willing to help with this feature.

Cargo script tracking issue here.

Relates to: #9609

cc: @epage

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 eRFC-3424 and the Cargo script tracking issue #12207, then locate rust-analyzer's handling of file parsing and package boundaries. The work should recognize and parse a shebang and treat the complete file as a single-file package, without manifest or crates.io dependency support. Done means initial cargo script support works without requiring stabilized manifest parsing.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.