servo: Merge #10545 - remove unreachable code in codegen (from amarant:unreachable-codegen); r=Ms2ger
authorArnaud Marant <arnaudmarant@gmail.com>
Wed, 13 Apr 2016 02:36:03 +0500
changeset 338495 9c7083d1c585bf48a7c1622e1c9b17711cd69565
parent 338494 64f005b0cc0406a0023ce3dff037cc68ed300197
child 338496 2b1045966e7712c4bc0055abd266f8fd6fd49edf
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
servo: Merge #10545 - remove unreachable code in codegen (from amarant:unreachable-codegen); r=Ms2ger code is unreachable after return, and identical to the upper block Source-Repo: https://github.com/servo/servo Source-Revision: 155e4052d150179ea8423a7ea626a84e25409718
servo/components/script/dom/bindings/codegen/CodegenRust.py
--- a/servo/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/servo/components/script/dom/bindings/codegen/CodegenRust.py
@@ -3795,32 +3795,16 @@ class CGUnionConversionStruct(CGThing):
         return CGWrapper(
             CGIndenter(CGList([
                 CGGeneric("type Config = ();"),
                 method,
             ], "\n")),
             pre="impl FromJSValConvertible for %s {\n" % self.type,
             post="\n}")
 
-        conversions.append(CGGeneric(
-            "throw_not_in_union(cx, \"%s\");\n"
-            "Err(())" % ", ".join(names)))
-        method = CGWrapper(
-            CGIndenter(CGList(conversions, "\n\n")),
-            pre="unsafe fn from_jsval(cx: *mut JSContext,\n"
-                "                     value: HandleValue, _option: ()) -> Result<%s, ()> {\n" % self.type,
-            post="\n}")
-        return CGWrapper(
-            CGIndenter(CGList([
-                CGGeneric("type Config = ();"),
-                method,
-            ], "\n")),
-            pre="impl FromJSValConvertible for %s {\n" % self.type,
-            post="\n}")
-
     def try_method(self, t):
         templateVars = getUnionTypeTemplateVars(t, self.descriptorProvider)
         returnType = "Result<Option<%s>, ()>" % templateVars["typeName"]
         jsConversion = templateVars["jsConversion"]
 
         return CGWrapper(
             CGIndenter(jsConversion, 4),
             pre="unsafe fn TryConvertTo%s(cx: *mut JSContext, value: HandleValue) -> %s {\n" % (t.name, returnType),