Skip to content

Cargo SemVer compatibility hazard: atlas feature #614

Description

@rdrpenguin04

The atlas feature is a compatibility hazard. The easiest way to see this is to enable the feature on bevy_ecs_tilemap and also use bevy_ecs_tiled, without setting its corresponding atlas flag. This causes a compilation error, which is understandably not how features are supposed to work.

A hypothetical other example would be a different 3rd-party library built for bevy_ecs_tilemap that attempts to be compatible with all options in the most Rust-y way possible: not enabling any features. It is designed around not using atlas, so it uses the alternative array texture types instead. Then, a game that uses this new library decides to enable atlas on the bevy_ecs_tilemap crate, as it has a special case not covered by the other library for which it wants direct tilemap access. Lo and behold, a cryptic compile error, as the library assumed the features it used wouldn't be taken away!

Link to the relevant Cargo guidelines: https://doc.rust-lang.org/cargo/reference/features.html#semver-compatibility

Proposed fix: do not disable enum variants, structures, or re-exports when atlas is enabled. Features should be additive. An alternative that would warn the user about performance concerns but not break libraries could be something like this:

#[cfg_attr(feature = "atlas", deprecated = "These enum variants should not be used with the `atlas` feature, as they create a compatibility and performance hazard with certain render backends.")]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions