Skip to content

Conversation

@jiangheng90
Copy link
Contributor

Objective

the rust-analyzer error in example bounding 2d

fn render_shapes(mut gizmos: Gizmos, query: Query<(&Shape, &Transform)>) {
    let color = GRAY;
    for (shape, transform) in query.iter() {
        let translation = transform.translation.xy();
        let rotation = transform.rotation.to_euler(EulerRot::YXZ).2;
        let isometry = Isometry2d::new(translation, Rot2::radians(rotation));
        match shape {
            Shape::Rectangle(r) => {
                gizmos.primitive_2d(r, isometry, color);
            }

the r will cause expected &{unknown}, found Rectangle

Solution

this error will occure in many place in this example
for match adding ref will solve this and pass lint

@alice-i-cecile alice-i-cecile added C-Examples An addition or correction to our examples A-Math Fundamental domain-agnostic mathematical operations S-Needs-Testing Testing must be done before this is safe to merge D-Trivial Nice and easy! A great choice to get started with Bevy labels Jan 19, 2025
@alice-i-cecile
Copy link
Member

I'd like a second verification of the error before we merge this. This is quite odd: this flavor of error should 100% be caught in CI.

@raldone01
Copy link
Contributor

raldone01 commented Jan 19, 2025

#17330 is not yet merged. Maybe RA bugs should be investigated after this has landed. Currently bevy is not interacting with rust-analyzer properly. I am not 100% sure if it is related though.

@mockersf
Copy link
Member

mockersf commented Jan 19, 2025

I can reproduce the issue with Rust Analyzer, but I don't think this PR should be merged. It introduces unneeded syntax, and hides the problem

@alice-i-cecile alice-i-cecile added S-Blocked This cannot move forward until something else changes and removed S-Needs-Testing Testing must be done before this is safe to merge labels Jan 19, 2025
@jiangheng90
Copy link
Contributor Author

I can reproduce the issue with Rust Analyzer, but I don't think this PR should be merged. It introduces unneeded syntax, and hides the problem

@mockersf That's true, after I switched the tag to 0.15.1 and rustc to 1.82.0, then rust analyze error prompt disappeared
also I found 0.15.1 with 1.84.0 is right. but only 0.16-dev with 1.84.0 will occure this problem.

After I diving deep into this issue(main branch with rustc 1.84.0), I found RA know the query type is Query<'_, '_, (&Shape, &Transform)>but can not found iter on query that finnally cause can not recognize &shape and &transform

 for (shape, transform) in query.iter() {

@BenjaminBrienen
Copy link
Contributor

I found 0.15.1 with 1.84.0 is right. but only 0.16-dev with 1.84.0 will occure this problem

Can you please bisect it?

@jiangheng90
Copy link
Contributor Author

@BenjaminBrienen I'm not understand what's your meaning of bisect. So I just make a simple test to see in which case this error will occure
My test environment is win11 24h2 vscode ra plugin
use the following step:

  • each time use cmd to switch version
rustup default x.xx.x 
  • reopen the vscode
  • check on save
0.15.1 0.16-dev
1.82.0 ✔️ ❌ failure with min require 1.83.0
1.83.0 ✔️ ❌ ra error occure
1.84.0 ✔️ ❌ ra error occure

not only this error. other example like anisotropy and clearcoat has no such field error. and this error is not same as error in bounding 2d.

@BenjaminBrienen
Copy link
Contributor

git bisect

@jiangheng90
Copy link
Contributor Author

jiangheng90 commented Jan 21, 2025

@BenjaminBrienen
git bisect result below, I think is the #16766 cause this ra error.

PS D:\Projects\Github Repostries\bevy> rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.84.0 (9fc6b4312 2025-01-07)`
PS D:\Projects\Github Repostries\bevy> git bisect start
HEAD is now at 1030a99b8 Release 0.15.1
status: waiting for both good and bad commits
PS D:\Projects\Github Repostries\bevy> git bisect good 1030a99b8e2680a7e696d6433b79f5671768231c
status: waiting for bad commit, 1 good commit known
PS D:\Projects\Github Repostries\bevy> git bisect bad b66c3ceb0ee39374ff1759ffb1b5bee2e4b93e99
Bisecting: a merge base must be tested
[fac0b34b20d18dd3d539c28f98ebe92829abe394] remove reference to missing file in bevy_remote cargo.toml (#16057)
PS D:\Projects\Github Repostries\bevy> git bisect good
Bisecting: 312 revisions left to test after this (roughly 8 steps)
[56688b387c04a06697a94307fe077af3da8132d6] Fix registering all reflection types that are components as reflection components (#16800)
PS D:\Projects\Github Repostries\bevy> git bisect bad
Bisecting: 155 revisions left to test after this (roughly 7 steps)
[d9282486e3d96af0c3067d55cf9f4fef0b977b5b] Dont enable bevy_remote by default (#16464)
PS D:\Projects\Github Repostries\bevy> git bisect good
Bisecting: 77 revisions left to test after this (roughly 6 steps)
[e763b7159106a57c3de645665c3acf0c8c2b5b5a] picking: disable raycast backface culling for Mesh2d (#16657)
PS D:\Projects\Github Repostries\bevy> git bisect good
Bisecting: 38 revisions left to test after this (roughly 5 steps)
[3188e5af619577a2b5d8192d9cc4154ebe9e2527] Batch skinned meshes on platforms where storage buffers are available. (#16599)
PS D:\Projects\Github Repostries\bevy> git bisect good
Bisecting: 19 revisions left to test after this (roughly 4 steps)
[b2d3371814497b02d3b95ab8fff2ea4a60739579] Event source location tracking (#16778)
PS D:\Projects\Github Repostries\bevy> git bisect good
Bisecting: 9 revisions left to test after this (roughly 3 steps)
[c14135d1500850fe7d37d59f2e2736069f3dfd46] Support `SystemInput` tuples up to 8 elements (#16814)
PS D:\Projects\Github Repostries\bevy> git bisect good
Bisecting: 4 revisions left to test after this (roughly 2 steps)
[622ca0d17be2c777557461f6ff287a54d208fe66] Fix stale comment on `LoadContext::finish`. (#16821)
PS D:\Projects\Github Repostries\bevy> git bisect bad 
Bisecting: 2 revisions left to test after this (roughly 1 step)
[760d0a31003c70ed6017b2a70059a76d9b268425] Use one `BevyManifest` instance in proc macros (#16766)
PS D:\Projects\Github Repostries\bevy> git bisect bad
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[73a66d6bd8e3d21b928f2a31f1aff5c9fb95a564] doc: fix camera link (#16827)

@BenjaminBrienen
Copy link
Contributor

Awesome, thanks!

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

Labels

A-Math Fundamental domain-agnostic mathematical operations C-Examples An addition or correction to our examples D-Trivial Nice and easy! A great choice to get started with Bevy S-Blocked This cannot move forward until something else changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants