-
Notifications
You must be signed in to change notification settings - Fork 11
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
Maybe swap lifetime location for *Kind
enums
#43
Comments
I'm thinking if we could just officially store the I think we may still guarantee safety for the users if we make the thread local a This could also remove the need for passing |
Do you propose to make the thread local accessible from lint crates as well? I think the |
My main point is that we already have quite a lot of methods that use Removing the proliferation of I'm thinking now of the API that doesn't involve users to even have For example React JS does this. It has a bunch of implicit global state and provides developers with free functions like |
Hmmm, one question would be, how we reconstruct the I guess this would be the biggest blocker 🤔 |
What do you mean by this? I don't understand what problem this is trying to solve. |
Anything, stored in a static item, can only use the My understanding is, that we're also limited, when it comes to the usage of smart pointers. For one, they don't have a stable ABI, but we could work around that. But lint crates are compiled separately from the driver. Therefore, it could happen, that they use different allocator. AFAIK, deallocating memory with a different allocator than the allocator that created the pointer, is unsound. So we're restricted to either passing |
Today the static stores a |
The problem is the |
Yep. Anyway, I think this matter requires experimentation rather than discussions |
rust-marker uses kind enums to represent different node types, like items. These currently hold references with the
'ast
lifetime inside them. This might not be ideal for drivers like RA, which may change and remove nodes after a linting pass. It might be better to remove the lifetime. One option for this could be to store the struct directly in the enum and only pass enum references to the API. This still ensures that users can only access immutable references while removing the'ast
lifetime. However, this will affect the size of*Kind
enums, as they will have the size of the largest variant and not just a reference.This is an idea worth exploring before v1.0.0
See
ItemKind
enum:marker/marker_api/src/ast/item.rs
Lines 70 to 85 in 2a11448
The text was updated successfully, but these errors were encountered: