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

lunatic_sqlite_api breaks rust-analyzer (vscode) in a cargo workspace #122

Open
you-win opened this issue May 8, 2023 · 1 comment
Open

Comments

@you-win
Copy link

you-win commented May 8, 2023

OS: Windows 10
rustc: 1.69.0
rust-analyzer: v0.3.1506
vscode: 1.77.3

I am developing a project using Lunatic,

I have a cargo workspace containing:

  • a submillisecond + lunatic-rs server
  • a client that connects to the server and does not compile to wasm
  • a project that contains shared code (only relevant since all projects in the workspace use this project)

When I have the entire workspace open, rust-analyzer emits the following errors and rust-analyzer stops highlighting errors:
Capture

This is due to this line in lunatic-rs and the lib.rs in lunatic not matching up.

This can be solved by adding a .vscode/settings.json file like so:

{
    "rust-analyzer.cargo.target": "wasm32-wasi"
}

but then that breaks my client project, since that project is currently only configured to run on desktop targets.

Attempting to add compilation gates like this to lunatic-rs/src/sqlite/query.rs:

#[cfg(not(target_arch = "wasm32"))]
use lunatic_sqlite_api as bindings;

and exposing the relevant functions in lunatic/crates/lunatic-sqlite-api/src/sqlite_bindings.rs does not work, as the function arities are different.

@bkolobara
Copy link
Contributor

Thanks @you-win for investigating this!

At one point I updated lunatic to be able to compile (but not link, I believe) on non-wasm32 targets. This significantly improved the situation with the tooling like rust-analyzer. With the introduction of the lunatic-sqlite-api crate we are sharing code between the native and wasm implementations again. This means that we have conditions based on targets and with some setups this can be an issue. Especially if you are sharing code between native and wasm implementations.

I think it should be possible to move the shared code into a separate crate imported by both and eliminate the conditional compilation issues.

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