rust-lang / rust-lang/rust-clippy
`include_str` or `include_bytes` not in `Cargo.toml/include`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
Checks paths in include_str and include_bytes and make sure those paths are found in the include field in Cargo.toml.
Advantage
When using a workspace it is easy to make the mistake of include_bytes!("../../other_crate/data/file.png"). The code will run, but cargo publish will fail, as the referenced file is not part of the crate.
This is true for any file not found in the include field of the crate's Cargo.toml.
Drawbacks
This is only relevant for crates that are intended to be published, i.e. has publish = true in their Cargo.toml.
Example
include_bytes!("../../other_crate/data/file.png")
Clippy warning: The file "../../other_crate/data/file.png" is outside the this crate, so cargo publish will fail.
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
Start by examining how Rust Clippy implements lints that inspect macros and crate metadata, then review the issue's include_str!/include_bytes! example and Cargo.toml include behavior. Done means identifying publishable crates, checking referenced paths against the crate's include field, and reporting the proposed warning without affecting unpublished crates.
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
- 35/100