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

Destructured tuple types not inferred correctly #12819

Closed
yngwi opened this issue Jul 19, 2022 · 12 comments
Closed

Destructured tuple types not inferred correctly #12819

yngwi opened this issue Jul 19, 2022 · 12 comments
Labels
A-ty type system / type inference / traits / method resolution

Comments

@yngwi
Copy link

yngwi commented Jul 19, 2022

When using a query in a Bevy system, destructured tuple values are not correctly infered but shown as {unknown}.

fn test_system(query: Query<(&Position, &Archetype)>) {
    for(pos, arch) in query.iter() {
        println!("{:?} {:?}", pos, arch);
    } 
}

Screenshot where {unknown} is shown:
image

rust-analyzer version:rust-analyzer version: 0.3.1131-standalone (897a7ec 2022-07-17)

rustc version: rustc 1.64.0-nightly (46b8c23f3 2022-07-01)

@Veykril
Copy link
Member

Veykril commented Jul 19, 2022

From the looks of it the problem is the Archetype, using it causes us to not longer infer the appropriate methods for WorldQuery. I am a bit confused though, Archetype is clearly not a WorldQuery as it doesn't implement Component, so how does this even compile...?

@Veykril
Copy link
Member

Veykril commented Jul 19, 2022

Actually your snippet doesn't compile for me at all as Archetype is not a Component, so there is no bug here it seems.

@yngwi
Copy link
Author

yngwi commented Jul 19, 2022

Sorry I have included a more extensive code example. Position and archetype are both custom component strictly that I defined elsewhere. The code compiles and runs just fine on my system, it's just the type inference that is off. Inference also works if the query includes just a single component instead of a tuple.

@ostwilkens
Copy link

I had this issue on w10 after updating vscode, rust-analyzer and rustc.

image

Reverting to an older nightly toolchain fixed it for me.

rust-toolchain.toml

[toolchain]
channel = "nightly-2022-04-25"

@Veykril
Copy link
Member

Veykril commented Jul 21, 2022

A reproducible snippet would be welcome, @yngwi is your problem also dependent on the toolchain, that is does the toolchain that was posted here fix the problem for you?

@yngwi
Copy link
Author

yngwi commented Jul 21, 2022

Hi, I have set the rust toolchain in my project folder as suggested and now see the correct types in VSCode. So this indeed seems to be the cause of the problem.

@Veykril
Copy link
Member

Veykril commented Jul 21, 2022

Alright, will investigate then, I assume some lang items/unstable traits changed in nightly that are relevant here

@Veykril Veykril added the A-ty type system / type inference / traits / method resolution label Jul 21, 2022
@flodiebold
Copy link
Member

It might just be proc macro expansion? @yngwi does it still work with the older toolchain if you set rust-analyzer.procMacro.enable to false?

@Veykril
Copy link
Member

Veykril commented Jul 21, 2022

Oh right, that is most likely it 🤦

@yngwi
Copy link
Author

yngwi commented Jul 21, 2022

It might just be proc macro expansion? @yngwi does it still work with the older toolchain if you set rust-analyzer.procMacro.enable to false?

After changing this setting it doesn't work any more

@flodiebold
Copy link
Member

flodiebold commented Jul 22, 2022

Yeah, that means this is just caused by proc macro support currently being broken on nightly, i.e. #12600. This should be fixed with the next stable release of rust-analyzer, or you could try the pre-release version.

@flodiebold flodiebold closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2022
@yngwi
Copy link
Author

yngwi commented Jul 22, 2022

Ok, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution
Projects
None yet
Development

No branches or pull requests

4 participants