rust-lang / rust-lang/rust-analyzer
Editing and saving data dependency (like `include_bytes!`) doesn't trigger `cargo check`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
To reproduce
cargo init --bin- Open this project in VSCode.
- Create the file
datain the root of the project, with the following contents:
(no trailing newline)hello Ctrl-S- Put the following in
src/main.rs:trait MyTrait {} impl MyTrait for [u8; 5] {} fn main() { let _t: &dyn MyTrait = include_bytes!("../data"); } Ctrl-S, observe that rust-analyzer shows no errors.- Go back to the file
dataand edit it, changing its length. Ctrl-S, observe that rust-analyzer shows no errors.- Go back to file
src/main.rs. Ctrl-S, observe that rust-analyzer shows an error belatedly ("the trait bound[u8; 6]: MyTraitis not satisfied").
In the perfect world, the error would be displayed on step 8, immediately after editing and saving the data file.
This is an artificial minimal example.
For a motivating real-world example, consider a compile-time templating system like Askama. Askama uses derive proc macro to process template files, and emits include_bytes!() as a way to let the build system know about the data dependency. Mistakes in the template can result in compile errors. It would be nice if such errors were reported immediately on save, without having to manually trigger cargo check.
Version info
rust-analyzer version: 0.4.1296-standalone (26562973b 2022-11-20)
VSCode version: 1.71.1
cargo 1.66.0-nightly (73ba3f35e 2022-09-18)
rustc 1.66.0-nightly (3f83906b3 2022-09-24)
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
Reproduce the behavior with src/main.rs and the root data file using the listed VSCode and rust-analyzer steps, then compare diagnostics after saving data with running cargo check. Trace how the include_bytes!("../data") dependency is observed and determine what behavior would make the error appear immediately after the data file changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100