Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up(Do not merge) Introduce pins #20063
Conversation
highfive
commented
Feb 16, 2018
|
Heads up! This PR modifies the following files:
|
highfive
commented
Feb 16, 2018
|
Cc @jdm @asajeffrey |
|
Note that this encoding allows |
|
Ooooh, nice! On first glance, it looks good. I was wondering why we have macro_rules! pinned {
(let ref $name:ident: $ty:ty := $expr:expr) => {
let mut $name = $crate::dom::bindings::pin::Pin::<$ty>::new();
let $name = unsafe { $name.pin($expr) };
};
}and ditto for |
Because owning a
Providing any mutable access is UB because it introduces aliasing when JS traces the pins. |
|
Ah that makes sense. The IRC conversation about this: https://mozilla.logbot.info/servo/20180216#c14315715 |
|
Note too that WebIDL unions can be trivially pinned with that encoding too: #[derive(JSTraceable)]
pub enum DocumentOrBlob {
Document(Dom<Document>),
Blob(Dom<Blob>),
}
unsafe impl<'a> Unrooted<&'a Document> for DocumentOrBlob {
unsafe fn unrooted(value: &'a Document) -> Self {
DocumentOrBlob::Document(Unrooted::unrooted(value))
}
}
unsafe impl<'a> Unrooted<&'a Blob> for DocumentOrBlob {
unsafe fn unrooted(value: &'a Blob) -> Self {
DocumentOrBlob::Blob(Unrooted::unrooted(value))
}
} |
1a22838
to
dc0ae23
|
Some mucking around on the Playground: https://play.rust-lang.org/?gist=0b254dd788285573b19bf3abd8194ac8&version=stable, the gist being https://gist.github.com/anonymous/0b254dd788285573b19bf3abd8194ac8 IRC chat: https://mozilla.logbot.info/servo/20180220#c14335616 and https://mozilla.logbot.info/servo/20180221#c14337818 and https://mozilla.logbot.info/servo/20180221#c14339978 |
|
|
d6fa6cc
to
598cedc
|
@asajeffrey I replaced some |
|
|
|
Closing due to inactivity. |
nox commentedFeb 16, 2018
•
edited by SimonSapin
Just pushing for people to take a look at it.
Things I want to do before we consider merging it:
'statictypes;Pinvalues out of order;UnpinnedDefaulttrait;TracedVectype that doesn't implementdrain, moving iterators, etc.This change is