Skip to content

BevyManifest incorrectly assumes that all crates starting with bevy_ are exposed through ::bevy:: #17816

Open
@raldone01

Description

@raldone01

fn get_re_exported_crate_path(&self, crate_name: &str) -> Option<PathPiece> {
crate_name.strip_prefix("bevy_").map(|s| {
let mut path = PathPiece::new();
path.push(syn::parse_str::<syn::PathSegment>(s).unwrap());
path

When I modified BevyManifest, I thought that it was bevy internal. However it is also used by https://github.com/bevyengine/bevy_editor_prototypes/blob/f41e2240174e29f1c9206bb6b080431463466ea5/crates/bevy_bsn/src/macros/src/derive_construct.rs#L14-L16 and possibly in other crates too. As long as only official bevy crates are resolved though it, there are no issues.

However, should a user crate that extends bevy and is named bevy_... use the BevyManifest in their proc macros, it will incorrectly assume their crate is available through ::bevy::.

A fix would be to only strip the prefix from the bevy_ crates that are actually available through ::bevy::.

I can create a pr for this and see two options:

  1. List dir in crates/ to get all the bevy internal crates. More complex but should automatically keep up with bevy but possibly yield wrong results if crates are added that are not rexported through bevy.
  2. Just using a manual string list. Simpler but needs to be kept in sync manually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-Cross-CuttingImpacts the entire engineC-BugAn unexpected or incorrect behaviorD-MacrosCode that generates Rust codeS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions