aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2015-08-13 15:30:08 -0400
committerCorey Farwell <coreyf@rwell.org>2015-08-13 16:50:17 -0400
commit43429abce40d9a87fa271027094a36256909f3ee (patch)
treeca9889c56d64a202bb1e8310b44542de348afdc4 /components/script/dom/bindings/codegen/CodegenRust.py
parent1542a879a544ca4d32256748b1819567a5c3b6fa (diff)
downloadservo-43429abce40d9a87fa271027094a36256909f3ee.tar.gz
servo-43429abce40d9a87fa271027094a36256909f3ee.zip
Avoid marking codegen method bodies as unsafe twice
`CGAbstractMethod` takes a couple boolean parameters, among others: * `extern`: will mark the method as `unsafe` and `extern` * `unsafe`: will wrap the method body in an `unsafe` block Passing both as `True` should not mark it as `unsafe` twice. Example from a generated `HTMLCollectionBinding.rs`: Before: ``` unsafe extern fn get_length(..) -> u8 { unsafe { // code here } } ``` After ``` unsafe extern fn get_length(..) -> u8 { // code here } ```
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index d6ca15dd546..e426d8a22c3 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -2089,7 +2089,9 @@ class CGAbstractMethod(CGThing):
def define(self):
body = self.definition_body()
- if self.unsafe:
+
+ # Method will already be marked `unsafe` if `self.extern == True`
+ if self.unsafe and not self.extern:
body = CGWrapper(CGIndenter(body), pre="unsafe {\n", post="\n}")
return CGWrapper(CGIndenter(body),