aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorSamson <16504129+sagudev@users.noreply.github.com>2024-10-03 12:14:43 +0200
committerGitHub <noreply@github.com>2024-10-03 10:14:43 +0000
commit163e47766841725201f683495f4506f35fc9614c (patch)
treeb7e33c89c380a2192aa20c393277e5cb9c53d81e /components/script/dom
parentc7a4e4f627f0bf331cedc1700ddeb92ffcba4e78 (diff)
downloadservo-163e47766841725201f683495f4506f35fc9614c.tar.gz
servo-163e47766841725201f683495f4506f35fc9614c.zip
Less `allow(crown::unrooted_must_root)` in bindings (#33630)
* Limit `allow(crown::unrooted_must_root)` in bindings Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * extra_decorators Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py10
-rw-r--r--components/script/dom/bindings/mod.rs2
2 files changed, 8 insertions, 4 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 86dafdddd29..9def8f5c178 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -2694,7 +2694,7 @@ class CGAbstractMethod(CGThing):
"""
def __init__(self, descriptor, name, returnType, args, inline=False,
alwaysInline=False, extern=False, unsafe=False, pub=False,
- templateArgs=None, docs=None, doesNotPanic=False):
+ templateArgs=None, docs=None, doesNotPanic=False, extra_decorators=[]):
CGThing.__init__(self)
self.descriptor = descriptor
self.name = name
@@ -2707,6 +2707,7 @@ class CGAbstractMethod(CGThing):
self.pub = pub
self.docs = docs
self.catchPanic = self.extern and not doesNotPanic
+ self.extra_decorators = extra_decorators
def _argstring(self):
return ', '.join([a.declare() for a in self.args])
@@ -2728,6 +2729,8 @@ class CGAbstractMethod(CGThing):
if self.alwaysInline:
decorators.append('#[inline]')
+ decorators.extend(self.extra_decorators)
+
if self.pub:
decorators.append('pub')
@@ -2904,7 +2907,7 @@ class CGWrapMethod(CGAbstractMethod):
Argument('CanGc', '_can_gc')]
retval = f'DomRoot<{descriptor.concreteType}>'
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
- pub=True, unsafe=True)
+ pub=True, unsafe=True, extra_decorators=['#[allow(crown::unrooted_must_root)]'])
def definition_body(self):
unforgeable = CopyLegacyUnforgeablePropertiesToInstance(self.descriptor)
@@ -2996,7 +2999,7 @@ 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)
+ pub=True, unsafe=True, extra_decorators=['#[allow(crown::unrooted_must_root)]'])
self.properties = properties
def definition_body(self):
@@ -7249,6 +7252,7 @@ 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]")
def getConstructors(self):
diff --git a/components/script/dom/bindings/mod.rs b/components/script/dom/bindings/mod.rs
index e31d79cc494..7d6d03d737a 100644
--- a/components/script/dom/bindings/mod.rs
+++ b/components/script/dom/bindings/mod.rs
@@ -169,7 +169,7 @@ pub mod xmlname;
/// Generated JS-Rust bindings.
#[allow(missing_docs, non_snake_case)]
pub mod codegen {
- #[allow(dead_code, crown::unrooted_must_root)]
+ #[allow(dead_code)]
pub mod Bindings {
include!(concat!(env!("OUT_DIR"), "/Bindings/mod.rs"));
}