-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Harden proc macro path resolution and add integration tests. #17330
Harden proc macro path resolution and add integration tests. #17330
Conversation
28422af
to
8f4a421
Compare
BevyManifest
name resolution smarter.@@ -4,6 +4,7 @@ crates/**/target | |||
benches/**/target | |||
tools/**/target | |||
**/*.rs.bk | |||
rustc-ice-*.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It happens from time to time when tickling rust nightly or deleting the target
folder while rust is building.
I like to keep them around while I consider if they should be reported. In any case they should not be committed to bevy I think.
Great idea, just need to fix the errors |
I will make the ci pass coming Thursday or Friday. |
When I try this branch, rust-analyzer logs this:
Is it expected to work with stable Rust / edition 2021? |
The command
|
I know. Please try it with nightly for now. Clean your project first and restart rust analyzer. I need to modify |
The ci passes now. I am now investigating why RA still fails. #[derive(Resource)]
struct MyResource {
value: f32,
} Expands to the following according to RA: // Recursive expansion of Resource macro
// ======================================
impl ::bevy::ecs::system::Resource for MyResource where Self: Send + Sync + 'static {} The following function: fn hello_world(query: Query<&MyComponent>, resource: Res<MyResource>) {
let value_deref = resource.value; // suggestions don't work but ctrl+click works once it's written, inlay hints also work
let value_direct = resource.into_inner().value; // suggestions work
println!(
"hello world! Value: {} {} {}",
query.iter().next().unwrap().value,
value_deref,
value_direct
);
} RA only seems to fail to complete the deref for me. |
cfbd221
to
96fbf0e
Compare
For me this PR is working correctly even with RA. The deref autocompletion doesn't really interact with the macro as far as I can tell. If I replace the derive macro with the expanded code manually, RA still fails the deref suggestion. This might possibly maybe be a RA issue? Or I am missing something. |
Current version (raldone01/bevy-rs@96fbf0e) works for me as well. |
96fbf0e
to
0b82b2e
Compare
0b82b2e
to
b3a2078
Compare
@BenjaminBrienen Should be ready from my side now. |
b3a2078
to
a6ba23e
Compare
0ed2ea8
to
c0538b9
Compare
I cleaned up the git history. It should be easier to review now. |
* Use the `extern crate self as` trick to make proc macros work inside and outside bevy behave the same way.
e90db6d
to
1041912
Compare
1041912
to
22802c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little noisy to do this all at once, but I really like the extern crate trick, and the introduction of dedicated integration tests is long-overdue.
This particular design feels a bit complicated to me relative to just slapping stuff in the root level tests
folder, but on reflection I think it's required to properly test the derive macros as if we were an external user.
I've fixed up the merge conflicts for you; merging now. |
I could have split it up easily as requested. Feel free to change it how you see fit. I just needed a way to test that everything is working as intended. Thank you for your work on bevy! |
This broke all my usages of bevy derive with messages like this:
and
For reference, I'm using Cargo overrides to redirect Bevy 0.16.0 to the local repo. |
I think I know what went wrong! I will add an integration test for it and fix it soon. It should be a minimal fix. The path to bevy reflect should start with |
@pcwalton can you open an issue with a minimal reproducer? I just tried a few bevy reflect derives and they all worked for me. Tag me in the issue. |
Hitting this in |
@villor I will use your pr to track down the issue and fix it. |
Much thanks @raldone01. I'm going to spin up an issue so we don't forget to fix this for 0.16. |
… 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.
…ine#17330) This pr uses the `extern crate self as` trick to make proc macros behave the same way inside and outside bevy. - Removes noise introduced by `crate as` in the whole bevy repo. - Fixes bevyengine#17004. - Hardens proc macro path resolution. - [x] `BevyManifest` needs cleanup. - [x] Cleanup remaining `crate as`. - [x] Add proper integration tests to the ci. - `cargo-manifest-proc-macros` is written by me and based/inspired by the old `BevyManifest` implementation and [`bkchr/proc-macro-crate`](https://github.com/bkchr/proc-macro-crate). - What do you think about the new integration test machinery I added to the `ci`? More and better integration tests can be added at a later stage. The goal of these integration tests is to simulate an actual separate crate that uses bevy. Ideally they would lightly touch all bevy crates. - Needs RA test - Needs testing from other users - Others need to run at least `cargo run -p ci integration-test` and verify that they work. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This pr uses the
extern crate self as
trick to make proc macros behave the same way inside and outside bevy.Objective
crate as
in the whole bevy repo.TODO
BevyManifest
needs cleanup.crate as
.Notes
cargo-manifest-proc-macros
is written by me and based/inspired by the oldBevyManifest
implementation andbkchr/proc-macro-crate
.ci
?More and better integration tests can be added at a later stage.
The goal of these integration tests is to simulate an actual separate crate that uses bevy. Ideally they would lightly touch all bevy crates.
Testing
cargo run -p ci integration-test
and verify that they work.