Skip to content

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

Open
@emilk

Description

@emilk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsT-cargoType: cargo related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions