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

"unresolved import" #6278

Closed
tigregalis opened this issue Oct 19, 2020 · 9 comments
Closed

"unresolved import" #6278

tigregalis opened this issue Oct 19, 2020 · 9 comments

Comments

@tigregalis
Copy link

I'm using Windows 10 Home version 1903, and Visual Studio Code 1.50.0, and rust-analyzer VS code extension version 0.2.344. I wasn't able to work out how to find the version of ra_lsp_server that's running.

I've seen this problem in a clone of the bevy repo at https://github.com/bevyengine/bevy . I'm seeing the below error in my "Problems" pane, but the project compiles fine (and using cargo check in the terminal doesn't warn us about anything).

image

bevy_math::Vec4 is ultimately a re-export of glam::f32::Vec4, but it sits alongside bevy_math::Vec3 which is ultimately a re-export of glam::f32::Vec3 which it doesn't have a problem resolving.

I've tried:

Having opened my local copy of the glam source in my .cargo, I'm now seeing the behaviour there.

Other issues that may or may not be related: #6258, #6063, #6038

I was able to trivially reproduce this - see repo https://github.com/tigregalis/glam-breaks-ra:
image
image
image
image

@Veykril
Copy link
Member

Veykril commented Oct 19, 2020

Looks like glam's Vec4 uses cfg attributes to determine the definition of the struct: https://github.com/bitshifter/glam-rs/blob/121cfaaa56494993d1666468039b2da663fd9a06/src/f32/vec4.rs#L21-L42
But it doesn't do that for Vec3: https://github.com/bitshifter/glam-rs/blob/121cfaaa56494993d1666468039b2da663fd9a06/src/f32/vec3.rs#L10-L13
So I imagine that is the problem.

@bjorn3
Copy link
Member

bjorn3 commented Oct 19, 2020

https://github.com/bitshifter/glam-rs/blob/d1b83da533c5ddb161f2da4d76faa33607d59c67/build.rs#L16

That cfg is set by the build script. I don't think rust-analyzer has support for this.

@lnicola
Copy link
Member

lnicola commented Oct 19, 2020

Shouldn't they work by https://github.com/rust-analyzer/rust-analyzer/blob/1b3b8c7/crates/project_model/src/cargo_workspace.rs#L314-L326 (if rust-analyzer.cargo.loadOutDirsFromCheck is set)?

@lnicola
Copy link
Member

lnicola commented Oct 19, 2020

@tigregalis can you try enabling rust-analyzer.cargo.loadOutDirsFromCheck? This seems to work for me.

@tigregalis
Copy link
Author

tigregalis commented Oct 19, 2020

@lnicola That's solved it, thanks. What is this rust-analyzer.cargo.loadOutDirsFromCheck option doing?

@Veykril If I had to guess, the types that have those cfg attributes are the ones that (can) have SIMD support.

@lnicola
Copy link
Member

lnicola commented Oct 19, 2020

It enables build script support, which makes those #[cfg]s work -- and also code generated at build-time, like other projects have.

@tigregalis
Copy link
Author

Ok, thanks. I'll close the issue. It could be worth documenting though.

@a74731248
Copy link

@tigregalis can you try enabling rust-analyzer.cargo.loadOutDirsFromCheck? This seems to work for me.

Could you please tell me how to enable this?

@flodiebold
Copy link
Member

It's called rust-analyzer.cargo.buildScripts.enable nowadays and enabled by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants