Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include_str or include_bytes not in Cargo.toml/include #11677

Open
emilk opened this issue Oct 16, 2023 · 1 comment
Open

include_str or include_bytes not in Cargo.toml/include #11677

emilk opened this issue Oct 16, 2023 · 1 comment
Labels
A-lint Area: New lints

Comments

@emilk
Copy link

emilk commented Oct 16, 2023

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.

@GuillaumeGomez
Copy link
Member

So this one is a bit tricky as it requires changes in cargo (for the metadata output) and to cargo_metadata (to get this new information).

I have started working on it in cargo (you can see my current work here).

So once everything is merged, I'll be able to finish working on this lint. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants