-
Notifications
You must be signed in to change notification settings - Fork 121
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
Remove Copy/Clone from MutableHandle #559
base: main
Are you sure you want to change the base?
Conversation
afd7b3c
to
19c77e8
Compare
A previous version of this change is here, with an accompying servo branch here. It took the approach of passing around That branch also includes a commit removing |
Signed-off-by: Greg Morenz <greg-morenz@droid.cafe>
Signed-off-by: Greg Morenz <greg-morenz@droid.cafe>
Marking this as ready for review with my preferred fix to #520. The design question asked in #520 is still valid, and if we'd rather go another way... this shouldn't be merged as is (though it wouldn't be hard to revert). I'm also going to open a draft servo PR simultaneously. I'm not sure what the preferred procedure for updating mozjs and servo in lockstep is? If that's a process we'd really rather avoid, this could be split into two. First add |
Typically what we do for stylo is to post the stylo PR, and then post the corresponding Servo PR (with a temporary change to |
Fixes #520
Replaces
Copy
andClone
with areborrow
method that handles lifetimes correctly. Also mergeswrappers
andjsapi_wrapped
since they now have the same API.As discussed in #520 there are multiple options here, with no clear "best option". I currently favor this since
RootedGuard
that safe-interior-mutability apis are likely to be unwieldy (these would let us keepCopy/Clone
.Accompanying servo branch here.
This doesn't fix
JS::MutableHandle
beingCopy
andClone
.JS::MutableHandle
doesn't carry a lifetime annotation, so there's no reasonable way to definereborrow
on it. The fix here is probably to remove theDeref
andDerefMut
impls on it (since without lifetime annotations there's no way those are safe functions) and move servo to always using the lifetime annotated versions.It also doesn't fix other aliasing issues surrounding this type, those can/should be fixed separately, and apart from an approach that leans entirely into interior mutability, those fixes should be compatible with this change.