mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
script: Feature-gate all crown support. (#35055)
* script: Feature-gate all crown support. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Use cfg(crown) instead of a cargo feature. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
1bd34a5781
commit
875e387004
223 changed files with 442 additions and 417 deletions
|
@ -41,7 +41,7 @@ pub(crate) enum ExceptionHandling {
|
|||
/// A common base class for representing IDL callback function and
|
||||
/// callback interface types.
|
||||
#[derive(JSTraceable)]
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) struct CallbackObject {
|
||||
/// The underlying `JSObject`.
|
||||
callback: Heap<*mut JSObject>,
|
||||
|
@ -62,7 +62,7 @@ pub(crate) struct CallbackObject {
|
|||
}
|
||||
|
||||
impl CallbackObject {
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
// These are used by the bindings and do not need `default()` functions.
|
||||
#[allow(clippy::new_without_default)]
|
||||
fn new() -> CallbackObject {
|
||||
|
@ -128,14 +128,14 @@ pub(crate) trait CallbackContainer {
|
|||
|
||||
/// A common base class for representing IDL callback function types.
|
||||
#[derive(JSTraceable, PartialEq)]
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) struct CallbackFunction {
|
||||
object: CallbackObject,
|
||||
}
|
||||
|
||||
impl CallbackFunction {
|
||||
/// Create a new `CallbackFunction` for this object.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
// These are used by the bindings and do not need `default()` functions.
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub(crate) fn new() -> CallbackFunction {
|
||||
|
@ -158,7 +158,7 @@ impl CallbackFunction {
|
|||
|
||||
/// A common base class for representing IDL callback interface types.
|
||||
#[derive(JSTraceable, PartialEq)]
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) struct CallbackInterface {
|
||||
object: CallbackObject,
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ pub(crate) struct CallSetup {
|
|||
|
||||
impl CallSetup {
|
||||
/// Performs the setup needed to make a call.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) fn new<T: CallbackContainer>(
|
||||
callback: &T,
|
||||
handling: ExceptionHandling,
|
||||
|
|
|
@ -2725,8 +2725,11 @@ def DomTypes(descriptors, descriptorProvider, dictionaries, callbacks, typedefs,
|
|||
traits += [f"crate::dom::bindings::codegen::Bindings::{namespace}::{iface_name}Methods<Self>"]
|
||||
isPromise = firstCap(iface_name) == "Promise"
|
||||
elements += [
|
||||
CGGeneric(" #[crown::unrooted_must_root_lint::must_root]\n"),
|
||||
CGGeneric(" #[crown::unrooted_must_root_lint::allow_unrooted_in_rc]\n" if isPromise else ""),
|
||||
CGGeneric(" #[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]\n"),
|
||||
CGGeneric(
|
||||
" #[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_in_rc)]\n"
|
||||
if isPromise else ""
|
||||
),
|
||||
CGGeneric(f" type {firstCap(iface_name)}: {' + '.join(traits)};\n")
|
||||
]
|
||||
elements += [CGGeneric("}\n")]
|
||||
|
@ -3017,7 +3020,8 @@ class CGWrapMethod(CGAbstractMethod):
|
|||
Argument('CanGc', '_can_gc')]
|
||||
retval = f'DomRoot<{descriptor.concreteType}>'
|
||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
||||
pub=True, unsafe=True, extra_decorators=['#[allow(crown::unrooted_must_root)]'])
|
||||
pub=True, unsafe=True,
|
||||
extra_decorators=['#[cfg_attr(crown, allow(crown::unrooted_must_root))]'])
|
||||
|
||||
def definition_body(self):
|
||||
unforgeable = CopyLegacyUnforgeablePropertiesToInstance(self.descriptor)
|
||||
|
@ -3109,7 +3113,8 @@ class CGWrapGlobalMethod(CGAbstractMethod):
|
|||
Argument(f"Box<{descriptor.concreteType}>", 'object')]
|
||||
retval = f'DomRoot<{descriptor.concreteType}>'
|
||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
||||
pub=True, unsafe=True, extra_decorators=['#[allow(crown::unrooted_must_root)]'])
|
||||
pub=True, unsafe=True,
|
||||
extra_decorators=['#[cfg_attr(crown, allow(crown::unrooted_must_root))]'])
|
||||
self.properties = properties
|
||||
|
||||
def definition_body(self):
|
||||
|
@ -7037,7 +7042,7 @@ class CGDictionary(CGThing):
|
|||
default = ""
|
||||
mustRoot = ""
|
||||
if self.membersNeedTracing():
|
||||
mustRoot = "#[crown::unrooted_must_root_lint::must_root]\n"
|
||||
mustRoot = "#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]\n"
|
||||
|
||||
# We can't unconditionally derive Default here, because union types can have unique
|
||||
# default values provided for each usage. Instead, whenever possible we re-use the empty()
|
||||
|
@ -7628,8 +7633,8 @@ class CGCallback(CGClass):
|
|||
constructors=self.getConstructors(),
|
||||
methods=realMethods,
|
||||
decorators="#[derive(JSTraceable, PartialEq)]\n"
|
||||
"#[allow(crown::unrooted_must_root)]\n"
|
||||
"#[crown::unrooted_must_root_lint::allow_unrooted_interior]")
|
||||
"#[cfg_attr(crown, allow(crown::unrooted_must_root))]\n"
|
||||
"#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)]")
|
||||
|
||||
def getConstructors(self):
|
||||
return [ClassConstructor(
|
||||
|
|
|
@ -55,7 +55,7 @@ pub(crate) trait Castable: IDLInterface + DomObject + Sized {
|
|||
|
||||
#[allow(missing_docs)]
|
||||
pub(crate) trait HasParent {
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
type Parent;
|
||||
fn as_parent(&self) -> &Self::Parent;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ impl TrustedPromise {
|
|||
/// Create a new `TrustedPromise` instance from an existing DOM object. The object will
|
||||
/// be prevented from being GCed for the duration of the resulting `TrustedPromise` object's
|
||||
/// lifetime.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) fn new(promise: Rc<Promise>) -> TrustedPromise {
|
||||
LIVE_REFERENCES.with(|r| {
|
||||
let r = r.borrow();
|
||||
|
@ -133,7 +133,7 @@ impl TrustedPromise {
|
|||
}
|
||||
|
||||
/// A task which will reject the promise.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) fn reject_task(self, error: Error) -> impl TaskOnce {
|
||||
let this = self;
|
||||
task!(reject_promise: move || {
|
||||
|
@ -143,7 +143,7 @@ impl TrustedPromise {
|
|||
}
|
||||
|
||||
/// A task which will resolve the promise.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) fn resolve_task<T>(self, value: T) -> impl TaskOnce
|
||||
where
|
||||
T: ToJSValConvertible + Send,
|
||||
|
@ -160,7 +160,7 @@ impl TrustedPromise {
|
|||
/// shared among threads for use in asynchronous operations. The underlying
|
||||
/// DOM object is guaranteed to live at least as long as the last outstanding
|
||||
/// `Trusted<T>` instance.
|
||||
#[crown::unrooted_must_root_lint::allow_unrooted_interior]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)]
|
||||
#[derive(MallocSizeOf)]
|
||||
pub(crate) struct Trusted<T: DomObject> {
|
||||
/// A pointer to the Rust DOM object of type T, but void to allow
|
||||
|
@ -226,7 +226,7 @@ impl<T: DomObject> Clone for Trusted<T> {
|
|||
|
||||
/// The set of live, pinned DOM objects that are currently prevented
|
||||
/// from being garbage collected due to outstanding references.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) struct LiveDOMReferences {
|
||||
// keyed on pointer to Rust DOM object
|
||||
reflectable_table: RefCell<HashMap<*const libc::c_void, Weak<TrustedReference>>>,
|
||||
|
@ -250,7 +250,7 @@ impl LiveDOMReferences {
|
|||
});
|
||||
}
|
||||
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
fn addref_promise(&self, promise: Rc<Promise>) {
|
||||
let mut table = self.promise_table.borrow_mut();
|
||||
table.entry(&*promise).or_default().push(promise)
|
||||
|
@ -301,7 +301,7 @@ fn remove_nulls<K: Eq + Hash + Clone, V>(table: &mut HashMap<K, Weak<V>>) {
|
|||
}
|
||||
|
||||
/// A JSTraceDataOp for tracing reflectors held in LIVE_REFERENCES
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) unsafe fn trace_refcounted_objects(tracer: *mut JSTracer) {
|
||||
trace!("tracing live refcounted references");
|
||||
LIVE_REFERENCES.with(|r| {
|
||||
|
|
|
@ -43,16 +43,16 @@ where
|
|||
}
|
||||
|
||||
/// A struct to store a reference to the reflector of a DOM object.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
#[derive(MallocSizeOf)]
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
// If you're renaming or moving this field, update the path in plugins::reflector as well
|
||||
pub(crate) struct Reflector {
|
||||
#[ignore_malloc_size_of = "defined and measured in rust-mozjs"]
|
||||
object: Heap<*mut JSObject>,
|
||||
}
|
||||
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
impl PartialEq for Reflector {
|
||||
fn eq(&self, other: &Reflector) -> bool {
|
||||
self.object.get() == other.object.get()
|
||||
|
|
|
@ -43,8 +43,8 @@ use crate::dom::bindings::trace::{trace_reflector, JSTraceable};
|
|||
use crate::dom::node::Node;
|
||||
|
||||
/// A rooted value.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[crown::unrooted_must_root_lint::allow_unrooted_interior]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)]
|
||||
pub(crate) struct Root<T: StableTraceObject> {
|
||||
/// The value to root.
|
||||
value: T,
|
||||
|
@ -59,7 +59,7 @@ where
|
|||
/// Create a new stack-bounded root for the provided value.
|
||||
/// It cannot outlive its associated `RootCollection`, and it gives
|
||||
/// out references which cannot outlive this new `Root`.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) unsafe fn new(value: T) -> Self {
|
||||
unsafe fn add_to_root_list(object: *const dyn JSTraceable) -> *const RootCollection {
|
||||
assert_in_script();
|
||||
|
@ -99,7 +99,7 @@ where
|
|||
// The JSTraceable impl for Reflector doesn't actually do anything,
|
||||
// so we need this shenanigan to actually trace the reflector of the
|
||||
// T pointer in Dom<T>.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
struct ReflectorStackRoot(Reflector);
|
||||
unsafe impl JSTraceable for ReflectorStackRoot {
|
||||
unsafe fn trace(&self, tracer: *mut JSTracer) {
|
||||
|
@ -118,7 +118,7 @@ where
|
|||
// The JSTraceable impl for Reflector doesn't actually do anything,
|
||||
// so we need this shenanigan to actually trace the reflector of the
|
||||
// T pointer in Dom<T>.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
struct MaybeUnreflectedStackRoot<T>(T);
|
||||
unsafe impl<T> JSTraceable for MaybeUnreflectedStackRoot<T>
|
||||
where
|
||||
|
@ -197,7 +197,7 @@ impl<T: DomObject> DomRoot<T> {
|
|||
///
|
||||
/// This should never be used to create on-stack values. Instead these values should always
|
||||
/// end up as members of other DOM objects.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) fn as_traced(&self) -> Dom<T> {
|
||||
Dom::from_ref(self)
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ where
|
|||
/// on the stack, the `Dom<T>` can point to freed memory.
|
||||
///
|
||||
/// This should only be used as a field in other DOM objects.
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) struct Dom<T> {
|
||||
ptr: ptr::NonNull<T>,
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ impl<T> Dom<T> {
|
|||
|
||||
impl<T: DomObject> Dom<T> {
|
||||
/// Create a `Dom<T>` from a `&T`
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) fn from_ref(obj: &T) -> Dom<T> {
|
||||
assert_in_script();
|
||||
Dom {
|
||||
|
@ -403,7 +403,7 @@ unsafe impl<T: DomObject> JSTraceable for Dom<T> {
|
|||
}
|
||||
|
||||
/// A traced reference to a DOM object that may not be reflected yet.
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) struct MaybeUnreflectedDom<T> {
|
||||
ptr: ptr::NonNull<T>,
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ impl<T> MaybeUnreflectedDom<T>
|
|||
where
|
||||
T: DomObject,
|
||||
{
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) unsafe fn from_box(value: Box<T>) -> Self {
|
||||
Self {
|
||||
ptr: Box::leak(value).into(),
|
||||
|
@ -444,7 +444,7 @@ where
|
|||
|
||||
/// An unrooted reference to a DOM object for use in layout. `Layout*Helpers`
|
||||
/// traits must be implemented on this.
|
||||
#[crown::unrooted_must_root_lint::allow_unrooted_interior]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)]
|
||||
pub(crate) struct LayoutDom<'dom, T> {
|
||||
value: &'dom T,
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ impl<T> Hash for LayoutDom<'_, T> {
|
|||
|
||||
impl<T> Clone for Dom<T> {
|
||||
#[inline]
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
fn clone(&self) -> Self {
|
||||
assert_in_script();
|
||||
Dom { ptr: self.ptr }
|
||||
|
@ -566,7 +566,7 @@ impl LayoutDom<'_, Node> {
|
|||
///
|
||||
/// This should only be used as a field in other DOM objects; see warning
|
||||
/// on `Dom<T>`.
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
#[derive(JSTraceable)]
|
||||
pub(crate) struct MutDom<T: DomObject> {
|
||||
val: UnsafeCell<Dom<T>>,
|
||||
|
@ -629,7 +629,7 @@ pub(crate) fn assert_in_layout() {
|
|||
///
|
||||
/// This should only be used as a field in other DOM objects; see warning
|
||||
/// on `Dom<T>`.
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
#[derive(JSTraceable)]
|
||||
pub(crate) struct MutNullableDom<T: DomObject> {
|
||||
ptr: UnsafeCell<Option<Dom<T>>>,
|
||||
|
@ -663,14 +663,14 @@ impl<T: DomObject> MutNullableDom<T> {
|
|||
|
||||
/// Retrieve a copy of the inner optional `Dom<T>` as `LayoutDom<T>`.
|
||||
/// For use by layout, which can't use safe types like Temporary.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<T>> {
|
||||
assert_in_layout();
|
||||
(*self.ptr.get()).as_ref().map(|js| js.to_layout())
|
||||
}
|
||||
|
||||
/// Get a rooted value out of this object
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) fn get(&self) -> Option<DomRoot<T>> {
|
||||
assert_in_script();
|
||||
unsafe { ptr::read(self.ptr.get()).map(|o| DomRoot::from_ref(&*o)) }
|
||||
|
@ -705,7 +705,7 @@ impl<T: DomObject> PartialEq<Option<&T>> for MutNullableDom<T> {
|
|||
}
|
||||
|
||||
impl<T: DomObject> Default for MutNullableDom<T> {
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
fn default() -> MutNullableDom<T> {
|
||||
assert_in_script();
|
||||
MutNullableDom {
|
||||
|
@ -727,7 +727,7 @@ impl<T: DomObject> MallocSizeOf for MutNullableDom<T> {
|
|||
///
|
||||
/// This should only be used as a field in other DOM objects; see warning
|
||||
/// on `Dom<T>`.
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) struct DomOnceCell<T: DomObject> {
|
||||
ptr: OnceCell<Dom<T>>,
|
||||
}
|
||||
|
@ -738,7 +738,7 @@ where
|
|||
{
|
||||
/// Retrieve a copy of the current inner value. If it is `None`, it is
|
||||
/// initialized with the result of `cb` first.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) fn init_once<F>(&self, cb: F) -> &T
|
||||
where
|
||||
F: FnOnce() -> DomRoot<T>,
|
||||
|
@ -749,7 +749,7 @@ where
|
|||
}
|
||||
|
||||
impl<T: DomObject> Default for DomOnceCell<T> {
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
fn default() -> DomOnceCell<T> {
|
||||
assert_in_script();
|
||||
DomOnceCell {
|
||||
|
@ -765,7 +765,7 @@ impl<T: DomObject> MallocSizeOf for DomOnceCell<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
unsafe impl<T: DomObject> JSTraceable for DomOnceCell<T> {
|
||||
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||
if let Some(ptr) = self.ptr.get() {
|
||||
|
|
|
@ -21,7 +21,7 @@ enum StackEntryKind {
|
|||
Entry,
|
||||
}
|
||||
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
#[derive(JSTraceable)]
|
||||
struct StackEntry {
|
||||
global: Dom<GlobalScope>,
|
||||
|
|
|
@ -116,7 +116,7 @@ unsafe impl<T> CustomTraceable for Sender<T> {
|
|||
///
|
||||
/// SAFETY: Inner type must not impl JSTraceable
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
#[crown::trace_in_no_trace_lint::must_not_have_traceable]
|
||||
#[cfg_attr(crown, crown::trace_in_no_trace_lint::must_not_have_traceable)]
|
||||
pub(crate) struct NoTrace<T>(pub(crate) T);
|
||||
|
||||
impl<T: Display> Display for NoTrace<T> {
|
||||
|
@ -146,7 +146,7 @@ impl<T: MallocSizeOf> MallocSizeOf for NoTrace<T> {
|
|||
/// HashMap wrapper, that has non-jsmanaged keys
|
||||
///
|
||||
/// Not all methods are reexposed, but you can access inner type via .0
|
||||
#[crown::trace_in_no_trace_lint::must_not_have_traceable(0)]
|
||||
#[cfg_attr(crown, crown::trace_in_no_trace_lint::must_not_have_traceable(0))]
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct HashMapTracedValues<K, V, S = RandomState>(pub(crate) HashMap<K, V, S>);
|
||||
|
||||
|
@ -289,7 +289,7 @@ pub(crate) fn trace_jsval(tracer: *mut JSTracer, description: &str, val: &Heap<J
|
|||
}
|
||||
|
||||
/// Trace the `JSObject` held by `reflector`.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) {
|
||||
trace!("tracing reflector {}", description);
|
||||
trace_object(tracer, description, reflector.rootable())
|
||||
|
@ -490,7 +490,7 @@ where
|
|||
/// If you have GC things like *mut JSObject or JSVal, use rooted!.
|
||||
/// If you have an arbitrary number of DomObjects to root, use rooted_vec!.
|
||||
/// If you know what you're doing, use this.
|
||||
#[crown::unrooted_must_root_lint::allow_unrooted_interior]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)]
|
||||
pub(crate) struct RootedTraceableBox<T: JSTraceable + 'static>(js::gc::RootedTraceableBox<T>);
|
||||
|
||||
unsafe impl<T: JSTraceable + 'static> JSTraceable for RootedTraceableBox<T> {
|
||||
|
|
|
@ -33,14 +33,14 @@ use crate::dom::bindings::trace::JSTraceable;
|
|||
pub(crate) const DOM_WEAK_SLOT: u32 = 1;
|
||||
|
||||
/// A weak reference to a JS-managed DOM object.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
#[crown::unrooted_must_root_lint::allow_unrooted_interior]
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)]
|
||||
pub(crate) struct WeakRef<T: WeakReferenceable> {
|
||||
ptr: ptr::NonNull<WeakBox<T>>,
|
||||
}
|
||||
|
||||
/// The inner box of weak references, public for the finalization in codegen.
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
pub(crate) struct WeakBox<T: WeakReferenceable> {
|
||||
/// The reference count. When it reaches zero, the `value` field should
|
||||
/// have already been set to `None`. The pointee contributes one to the count.
|
||||
|
@ -218,7 +218,7 @@ unsafe impl<T: WeakReferenceable> JSTraceable for MutableWeakRef<T> {
|
|||
|
||||
/// A vector of weak references. On tracing, the vector retains
|
||||
/// only references which still point to live objects.
|
||||
#[crown::unrooted_must_root_lint::allow_unrooted_interior]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)]
|
||||
#[derive(MallocSizeOf)]
|
||||
pub(crate) struct WeakRefVec<T: WeakReferenceable> {
|
||||
vec: Vec<WeakRef<T>>,
|
||||
|
@ -268,7 +268,7 @@ impl<T: WeakReferenceable> DerefMut for WeakRefVec<T> {
|
|||
|
||||
/// An entry of a vector of weak references. Passed to the closure
|
||||
/// given to `WeakRefVec::update`.
|
||||
#[crown::unrooted_must_root_lint::allow_unrooted_interior]
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)]
|
||||
pub(crate) struct WeakRefEntry<'a, T: WeakReferenceable> {
|
||||
vec: &'a mut WeakRefVec<T>,
|
||||
index: &'a mut usize,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue