mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
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>
This commit is contained in:
parent
c7a4e4f627
commit
163e477668
2 changed files with 8 additions and 4 deletions
|
@ -2694,7 +2694,7 @@ class CGAbstractMethod(CGThing):
|
||||||
"""
|
"""
|
||||||
def __init__(self, descriptor, name, returnType, args, inline=False,
|
def __init__(self, descriptor, name, returnType, args, inline=False,
|
||||||
alwaysInline=False, extern=False, unsafe=False, pub=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)
|
CGThing.__init__(self)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -2707,6 +2707,7 @@ class CGAbstractMethod(CGThing):
|
||||||
self.pub = pub
|
self.pub = pub
|
||||||
self.docs = docs
|
self.docs = docs
|
||||||
self.catchPanic = self.extern and not doesNotPanic
|
self.catchPanic = self.extern and not doesNotPanic
|
||||||
|
self.extra_decorators = extra_decorators
|
||||||
|
|
||||||
def _argstring(self):
|
def _argstring(self):
|
||||||
return ', '.join([a.declare() for a in self.args])
|
return ', '.join([a.declare() for a in self.args])
|
||||||
|
@ -2728,6 +2729,8 @@ class CGAbstractMethod(CGThing):
|
||||||
if self.alwaysInline:
|
if self.alwaysInline:
|
||||||
decorators.append('#[inline]')
|
decorators.append('#[inline]')
|
||||||
|
|
||||||
|
decorators.extend(self.extra_decorators)
|
||||||
|
|
||||||
if self.pub:
|
if self.pub:
|
||||||
decorators.append('pub')
|
decorators.append('pub')
|
||||||
|
|
||||||
|
@ -2904,7 +2907,7 @@ class CGWrapMethod(CGAbstractMethod):
|
||||||
Argument('CanGc', '_can_gc')]
|
Argument('CanGc', '_can_gc')]
|
||||||
retval = f'DomRoot<{descriptor.concreteType}>'
|
retval = f'DomRoot<{descriptor.concreteType}>'
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
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):
|
def definition_body(self):
|
||||||
unforgeable = CopyLegacyUnforgeablePropertiesToInstance(self.descriptor)
|
unforgeable = CopyLegacyUnforgeablePropertiesToInstance(self.descriptor)
|
||||||
|
@ -2996,7 +2999,7 @@ class CGWrapGlobalMethod(CGAbstractMethod):
|
||||||
Argument(f"Box<{descriptor.concreteType}>", 'object')]
|
Argument(f"Box<{descriptor.concreteType}>", 'object')]
|
||||||
retval = f'DomRoot<{descriptor.concreteType}>'
|
retval = f'DomRoot<{descriptor.concreteType}>'
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
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
|
self.properties = properties
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
|
@ -7249,6 +7252,7 @@ class CGCallback(CGClass):
|
||||||
constructors=self.getConstructors(),
|
constructors=self.getConstructors(),
|
||||||
methods=realMethods,
|
methods=realMethods,
|
||||||
decorators="#[derive(JSTraceable, PartialEq)]\n"
|
decorators="#[derive(JSTraceable, PartialEq)]\n"
|
||||||
|
"#[allow(crown::unrooted_must_root)]\n"
|
||||||
"#[crown::unrooted_must_root_lint::allow_unrooted_interior]")
|
"#[crown::unrooted_must_root_lint::allow_unrooted_interior]")
|
||||||
|
|
||||||
def getConstructors(self):
|
def getConstructors(self):
|
||||||
|
|
|
@ -169,7 +169,7 @@ pub mod xmlname;
|
||||||
/// Generated JS-Rust bindings.
|
/// Generated JS-Rust bindings.
|
||||||
#[allow(missing_docs, non_snake_case)]
|
#[allow(missing_docs, non_snake_case)]
|
||||||
pub mod codegen {
|
pub mod codegen {
|
||||||
#[allow(dead_code, crown::unrooted_must_root)]
|
#[allow(dead_code)]
|
||||||
pub mod Bindings {
|
pub mod Bindings {
|
||||||
include!(concat!(env!("OUT_DIR"), "/Bindings/mod.rs"));
|
include!(concat!(env!("OUT_DIR"), "/Bindings/mod.rs"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue