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

Hardening proc macro path resolution broke cargo overrides #17780

Closed
alice-i-cecile opened this issue Feb 10, 2025 · 3 comments · Fixed by #17795
Closed

Hardening proc macro path resolution broke cargo overrides #17780

alice-i-cecile opened this issue Feb 10, 2025 · 3 comments · Fixed by #17795
Labels
C-Bug An unexpected or incorrect behavior D-Macros Code that generates Rust code P-High This is particularly urgent, and deserves immediate attention P-Regression Functionality that used to work but no longer does. Add a test for this! S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Milestone

Comments

@alice-i-cecile
Copy link
Member

This broke all my usages of bevy derive with messages like this:

error[E0433]: failed to resolve: use of undeclared crate or module `bevy_reflect`
   --> C:\Users\pcwal\Source\Rust\leafwing-input-manager\src\lib.rs:144:41
    |
144 | #[derive(Debug, Clone, Copy, PartialEq, Reflect, Serialize, Deserialize)]
    |                                         ^^^^^^^ use of undeclared crate or module `bevy_reflect`
    |
    = note: struct `crate::user_input::trait_reflection::tripleaxislike::TypeRegistration` exists but is inaccessible
    = note: this error originates in the derive macro `Reflect` (in Nightly builds, run with -Z macro-backtrace for more info)

and

error[E0277]: `user_input::gamepad::GamepadStick` can not provide dynamic type information through reflection
   --> C:\Users\pcwal\Source\Rust\leafwing-input-manager\src\user_input\gamepad.rs:548:23
    |
548 | impl DualAxislike for GamepadStick {
    |                       ^^^^^^^^^^^^ the trait `bevy::bevy_reflect::Typed` is not implemented for `user_input::gamepad::GamepadStick`

For reference, I'm using Cargo overrides to redirect Bevy 0.16.0 to the local repo.

Originally posted by @pcwalton in #17330 (comment)

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong D-Macros Code that generates Rust code labels Feb 10, 2025
@alice-i-cecile
Copy link
Member Author

A reproduction is given in #17330 (comment).

@raldone01 has offered to try fixing this, but feel free to chime in and help out.

@alice-i-cecile alice-i-cecile added the P-High This is particularly urgent, and deserves immediate attention label Feb 10, 2025
@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Feb 10, 2025
@alice-i-cecile alice-i-cecile added the P-Regression Functionality that used to work but no longer does. Add a test for this! label Feb 10, 2025
@raldone01
Copy link
Contributor

raldone01 commented Feb 11, 2025

I am trying to get the reproducer to work (It has some unrelated issues on my machine).
If anyone finds a simpler reproducer please comment here.

@raldone01
Copy link
Contributor

raldone01 commented Feb 11, 2025

Current state of my invenstigation:

The issue seems is caused by depending on bevy in dev and normal dependencies:

[dependencies]
bevy.workspace = true
[dev-dependencies]
bevy.workspace = true

The error of the cargo-manifest-proc-macros crate was being ignored in BevyManifest:

    /// Returns the path for the crate with the given name.
    pub fn get_path(&self, name: &str) -> syn::Path {
        self.maybe_get_path(name)
            .expect("Failed to get path for crate")
        // Moving the comment here shows the error
        //.unwrap_or_else(|_err| Self::parse_str(name))
    }

The ambiguity detection in cargo-manifest-proc-macros detects false positives. I am working on a fix as I am the author. I already have a failing test that covers the scenario in bevy.

raldone01 added a commit to ink-feather-org/cargo-manifest-proc-macros-rs that referenced this issue Feb 11, 2025
github-merge-queue bot pushed a commit that referenced this issue Feb 11, 2025
… dependencies. (#17795)

This is a follow up fix for #17330 and fixes #17780.
There was a logic error in the ambiguity detection of
`cargo-manifest-proc-macros`.
`cargo-manifest-proc-macros` now has a test for this case to prevent the
issue in the future.

I also opted to hard fail if the `cargo-manifest-proc-macros` crate
fails. That way the error is more obvious and easier to fix and
diagnose.

## Testing

- The reproducer:
bevyengine/bevy_editor_prototypes#178 works for
me using these fixes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior D-Macros Code that generates Rust code P-High This is particularly urgent, and deserves immediate attention P-Regression Functionality that used to work but no longer does. Add a test for this! S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
2 participants