rust-analyzer: Unknown types in web-sys dependency
(I suspect this is a duplicate, but i’m not sure what the root cause is).
I’m trying to use the web-sys crate, which is highly generated.
I’ve enabled both loadOutDirsFromCheck and procMacro.enable:
.vscode/settings.jon
{
"rust-analyzer.cargo.loadOutDirsFromCheck": true,
"rust-analyzer.procMacro.enable": true,
"editor.tokenColorCustomizationsExperimental": {
"unresolvedReference": "#FF0000"
}
}
Cargo.toml
[package]
name = "foo"
version = "0.1.0"
authors = ["Andrew Chin <achin@eminence32.net>"]
edition = "2018"
[dependencies.web-sys]
version = "0.3"
features = ["Document", "Window"]
Code:
use web_sys::{Document, Window};
pub fn foo() {
let win: Window = web_sys::window().unwrap();
let doc: Document = win.document().unwrap();
}

Using RA nightly (fe99a29)
Thanks!
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 31 (29 by maintainers)
That PR has landed. But that didn’t help
web-sysmuch. Ifweb-syswas using genuine extern opaque type syntax as input to macros (e.g. impl blocks etc) the issue would have been solved. It seems we need to improve proc macro support next. I’ll look into what i can do to help.I gave adding support for extern opaque types a try in https://github.com/rust-analyzer/rust-analyzer/pull/5993 .
I’m not sure we can do this in a useful way? For example, it seems
wasm_bindgen(start)on a function doesn’t change the function, butwasm_bindgenon other items has noticeable effects. We could maybe notice that the macro didn’t actually change the function though?