rust-lang / rust-lang/rust-analyzer
When building with `no_std`, `alloc` imports don't also add `extern crate alloc`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
When working on a #![no_std] crate and doing a code complete on Vec, selecting alloc::vec::Vec, the import is added to the top of the file, but an appropriate extern crate alloc; is not added anywhere, causing the project to immediately complain and fail to build.
It would be better if RA could detect this and add the extern crate at the crate root.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue concerns completion and import insertion for alloc::vec::Vec in a #![no_std] crate; start by tracing that completion path and its handling of crate-root imports. Done means selecting the item adds both the import and extern crate alloc without regressing normal std cases; add focused coverage in the relevant test area.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100