-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support name alias on type directly for methods #2124
base: main
Are you sure you want to change the base?
Conversation
Seems it breaks both web-sys and js-sys and path segments are not handled correctly during parsing. Would re-open when it is solved. |
Sorry for the delay in getting to this, but I'm personally sort of hesitant to merge this. This feels like it's a bit of a complicated interpretation of the attributes and requiring a preprocessing pass doesn't really feel great to me. Does this work if you put |
@alexcrichton Thank you very much for your comment. Well yeah, it does rely too much on current attributes' behaviour and probably not scalable if we wanna add some other features one day. Also, it isn't very efficient to do a heavy preprocessing just for this one purpose. My bad not thinking it very thoroughly and after a few weeks calming down, I also don't feel it is good enough to be merged. It feels like in |
I'm fine with adding more analysis as necessary in the CLI, the speed isn't really what I'm worried about. I'm mostly worried about the maintenance burden about how there's all these weird interactions between all these attributes. No one ever really designed the whole system here, it was just added piecemeal over time and we have what we have. I'm hesitant to continuously do that because it ends up being an unmaintainable mess. |
This PR tries to fix #2040.
It could also help to address the following case:
Currently, for snippet above,
wasm-bindgen
imports bothJKModule
andMModule
, which I don't think is perfect -- in rust code, both methods actually belong to the same type. Probably just importingJKModule
would be clearer (or is it by design?).Now a global name-alias map will be built before determining imports so that for each import we can check if any name-alias exists and if we should import aliased name instead.
Not sure if this modification follows the initial design of
js_class
-- forglobalThis
injs-sys
, multiplejs_class
for typeglobal
is actually used.