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

Support Box<T>/Option<T> inside of non-JS value roots. #522

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jdm
Copy link
Member

@jdm jdm commented Nov 9, 2024

The auto_root! macro creates a CustomAutoRoot value for the provided initializer. When this initializer contains a Box, the code fails to compile because we don't have custom tracing code for boxes.

@jdm jdm changed the title Support Box<T> inside of custom auto roots. Support Box<T>/Option<T> inside of non-JS value roots. Nov 9, 2024
Comment on lines +172 to +179
impl<T> GCMethods for Option<T> {
unsafe fn initial() -> Self {
None
}

unsafe fn post_barrier(_v: *mut Self, _prev: Self, _next: Self) {}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use bounds here (T: GCMethods) and call underlying methods (T::post_barrier)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you're probably right. I'll take a look at how the C++ code handles similar situations.

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

Successfully merging this pull request may close these issues.

2 participants