diff options
author | Josh Matthews <josh@joshmatthews.net> | 2025-01-16 15:22:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-16 20:22:40 +0000 |
commit | a014da590a0071a4e7cc825619a152268140560b (patch) | |
tree | d0d8cbb8f8883cd18db958357d58d05e24195cf2 /components | |
parent | 60dc3b26fb01ac3730475113033c270e95276a69 (diff) | |
download | servo-a014da590a0071a4e7cc825619a152268140560b.tar.gz servo-a014da590a0071a4e7cc825619a152268140560b.zip |
Support future uses of traits with associated types in rooting analysis (#34359)
* crown: Support Rc<T::Promise> and callback objects parameterized over a trait..
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* crown: Verify that attributes match between trait associated types and impls.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* crown: Check type aliases as part of associated type checks.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* crown: Add periods to all diagnostic messages.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Tidy.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Fix compile-fail test expectations.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components')
-rw-r--r-- | components/script/dom/console.rs | 1 | ||||
-rw-r--r-- | components/script/dom/testns.rs | 1 | ||||
-rw-r--r-- | components/script/dom/webxr/xrhand.rs | 20 |
3 files changed, 19 insertions, 3 deletions
diff --git a/components/script/dom/console.rs b/components/script/dom/console.rs index ae9ac12af3f..e1bcd13c7f1 100644 --- a/components/script/dom/console.rs +++ b/components/script/dom/console.rs @@ -31,6 +31,7 @@ const MAX_LOG_DEPTH: usize = 10; const MAX_LOG_CHILDREN: usize = 15; /// <https://developer.mozilla.org/en-US/docs/Web/API/Console> +#[crown::unrooted_must_root_lint::must_root] pub(crate) struct Console; impl Console { diff --git a/components/script/dom/testns.rs b/components/script/dom/testns.rs index bd9f8a20127..96dcf37aad0 100644 --- a/components/script/dom/testns.rs +++ b/components/script/dom/testns.rs @@ -4,4 +4,5 @@ // check-tidy: no specs after this line +#[crown::unrooted_must_root_lint::must_root] pub(crate) struct TestNS(()); diff --git a/components/script/dom/webxr/xrhand.rs b/components/script/dom/webxr/xrhand.rs index a9253ccb72b..b466cf32086 100644 --- a/components/script/dom/webxr/xrhand.rs +++ b/components/script/dom/webxr/xrhand.rs @@ -3,9 +3,12 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use dom_struct::dom_struct; +use js::jsapi::JSContext; +use js::rust::MutableHandleValue; use webxr_api::{FingerJoint, Hand, Joint}; use crate::dom::bindings::codegen::Bindings::XRHandBinding::{XRHandJoint, XRHandMethods}; +use crate::dom::bindings::conversions::ToJSValConvertible; use crate::dom::bindings::iterable::Iterable; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -163,19 +166,30 @@ impl XRHandMethods<crate::DomTypeHolder> for XRHand { } } +/// A wrapper to work around a crown error—Root<T> has a crown annotation on it that is not present +/// on the Iterable::Value associated type. The absence is harmless in this case. +pub(crate) struct ValueWrapper(pub DomRoot<XRJointSpace>); + +impl ToJSValConvertible for ValueWrapper { + #[allow(unsafe_code)] + unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { + self.0.to_jsval(cx, rval) + } +} + impl Iterable for XRHand { type Key = XRHandJoint; - type Value = DomRoot<XRJointSpace>; + type Value = ValueWrapper; fn get_iterable_length(&self) -> u32 { JOINT_SPACE_MAP.len() as u32 } - fn get_value_at_index(&self, n: u32) -> DomRoot<XRJointSpace> { + fn get_value_at_index(&self, n: u32) -> ValueWrapper { let joint = JOINT_SPACE_MAP[n as usize].1; self.spaces .get(joint) - .map(|j| DomRoot::from_ref(&**j)) + .map(|j| ValueWrapper(DomRoot::from_ref(&**j))) .expect("Failed to get joint pose") } |