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 for SIMD types (CARGO_CFG_TARGET_FEATURE not evaluated?) #6556

Closed
Tracked by #86
hrydgard opened this issue Nov 15, 2020 · 2 comments
Closed
Tracked by #86

Comments

@hrydgard
Copy link

This builds and runs, but rust-analyzer is unhappy with the vec4 type:

ra-repro

Here's the (rather trivial) repro:

https://github.com/hrydgard/ra-vec4-repro

glam::Vec4 is a SIMD type:

/// A 4-dimensional vector.
///
/// This type is 16 byte aligned.
#[cfg(vec4_sse2)]
#[derive(Clone, Copy)]
#[repr(C)]
pub struct Vec4(pub(crate) __m128);

So my suspicion is that the vec4_sse2 option is not set, hiding the type.

The build.rs is what sets this option based on CARGO_CFG_TARGET_FEATURE.

What's the best way to deal with this as a user of glam-rs (or as the library author, to make rust-analyzer do the most sensible thing?)

I guess this is somewhat similar to #6038 ?

@bjorn3
Copy link
Member

bjorn3 commented Nov 15, 2020

It should work if you enable loadOutDirsFromCheck.

{
    "rust-analyzer.cargo.loadOutDirsFromCheck": true,
}

I guess this is somewhat similar to #6038 ?

No, that is the cfg_if dependency of libstd being ignored.

@hrydgard
Copy link
Author

Ah thanks, that does indeed take care of it. Though #6448 discusses the insecurity of the option (although when developing something with a build.rs, you'll end up running it whether you use rust-analyzer or not.. so not that big a difference)...

Wonder if glam-rs could somehow do this check without relying on a build.rs, but I'll take that issue over there.

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

2 participants