-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Unknown types in web-sys dependency #4150
Comments
Are you using the weekly build? All these definitions are in |
I am using the nightly build (fe99a29). (Sorry, that was an important detail I should not have omitted) |
For example, Here is how
|
|
It probably gets turned into something different by the macro? |
And we didn't expand it because no custom attr proc-macro support yet. But I doubt if |
Not to hijack but I'm having similar issues with both go-to-definition and completion for the web-sys crate. doing
|
Extern opaque types are supported by chalk now. Hopefully this will help with this issue. |
Cool, that helps a bit! Using the latest commit (60c8941), the Edit: Actually, the upgraded chalk isn't in RA head yet, so the above improvements came from elsewhere... Sorry for the noise! |
I gave adding support for extern opaque types a try in #5993 . |
That PR has landed. But that didn't help |
Is there any movement on this front, or direction contributors could look to have in trying to get this supported? For reference, this the definition of web-sys modules. #[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = UiEvent , extends = Event , extends = :: js_sys :: Object , js_name = InputEvent , typescript_type = "InputEvent")]
#[derive(Debug, Clone, PartialEq, Eq)]
pub type InputEvent;
# [wasm_bindgen (structural , method , getter , js_class = "InputEvent" , js_name = isComposing)]
pub fn is_composing(this: &InputEvent) -> bool;
#[wasm_bindgen(catch, constructor, js_class = "InputEvent")]
pub fn new(type_: &str) -> Result<InputEvent, JsValue>;
#[cfg(feature = "InputEventInit")]
#[wasm_bindgen(catch, constructor, js_class = "InputEvent")]
pub fn new_with_event_init_dict(
type_: &str,
event_init_dict: &InputEventInit,
) -> Result<InputEvent, JsValue>;
} |
Attribute proc macros are tracked in #6029, let's close this for now. |
@jonas-schievink do we expand attributes for exten blocks? #[wasm_bindgen]
extern "C" {
pub type Window;
} https://users.rust-lang.org/t/no-autocompletion-with-rust-analyzer-and-wasm-bindgen-web-sys/64301 |
We should |
If it's not working even with attribute macro support, we should reopen? |
Ah, the problem is that turning |
damned if you do, damned if you don't... I am wondering... Can we just record two functions with the same name in the def map, one expanded and one not expanded, such that |
So And the proper fix might be for the |
That seems like it would lead to all kinds of other incorrect results? |
Right. It will do completion in the non-expanded code. That's technically wrong (for example, macro can be written in such a way as to inject unhygienic
I don't think a fully proper fix is possible, as the general case is compile time reflection. I think 90% proper fix would be to allow proc macro authors to annotate their macros as "this doesn't change item semantics", so that we know that the treatment, suggested above, is fully correct. For the cases where the macro does change semantics, yeah, I think will need extra collaboration from the macro itself. |
I think a fully proper fix is possible as long as the cursor is in a range of tokens that just get mapped as one continuous range, which I think is what people expect. No-one would reasonably expect completions in |
I'm not sure we can do this in a useful way? For example, it seems |
... although I guess the problem is that Edit: Or does it? I don't know, maybe it will be fixed by just #9866... |
Yeah, proc macros generally just expand to An optimal fix for this would entail rewriting |
Maybe we can just lie to the macro by synthesizing tokens that make the input parse correctly 🤔 |
The reason I was wondering is that in this case, the proc macro doesn't need to inspect the body of the function, so it would be fine for it to just parse the header, also for build time and forward compatibility reasons. I don't know if it does that right now though.
Yeah, that's also something I was considering, though it could also lead to other problems. (It's also kind of similar to the hypothetically-expand-with-inserted-token thing we're doing, and maybe if we someday have better support for hypothetical queries in Salsa that could help as well.) |
I think the issues discussed here have been mostly fixed. |
I just did a quick test and things seem to be much better! The |
(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
andprocMacro.enable
:.vscode/settings.jon
Cargo.toml
Code:
Using RA nightly (fe99a29)
Thanks!
The text was updated successfully, but these errors were encountered: